Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

JButtons + Paint help needed!

PersianGodPersianGod Member Posts: 1
im having a lot of troubles.i wanted to put my button where ever i wanted on my panel but after doing that using panel.setLayout(null); and button.setBounds(400,400,72,71); every image that i painted using .drawImage() won't paint. i tried setting the bounds for the paint and that got the paint back but now my button isn't showing. what a dilemma! heres my code without my paint class. It's really messy..
[code]import java.awt.event.*;
import javax.swing.*;
import java.awt.*;

public class NimaSlotMachine extends JFrame implements MouseListener
{paint paint= new paint();

//--------------------------Frames----------------------------------------------------------
JFrame welcomeFrame = new JFrame ("Welcome");
JButton spinGo = new JButton (new ImageIcon("spinButton.jpg"));
JPanel buttonGoPanel = new JPanel(new BorderLayout());

// JLabel spinGoO = new JLabel (spinGo);
// final Timer timer;
// JLabel pic1 = new JLabel(new ImageIcon("pic1.jpg"));
JPanel welcomePanel = new JPanel (new BorderLayout());
JButton startTimer = new JButton("Go!");
//boolean go = false;
//boolean go1 = false;

public static void main(String[] args)
{
new NimaSlotMachine();
}

NimaSlotMachine()
{





/* welcomePanel.add(pic1,BorderLayout.CENTER);
timer = new Timer(1000, new ActionListener()
{
public void actionPerformed(ActionEvent evt)
{
pic1.setIcon(new ImageIcon("pic2.jpg"));


if(go == true) pic1.setIcon(new ImageIcon("pic3.jpg"));
go = true;
if(go1 == true) pic1.setIcon(new ImageIcon("face.jpg"));
if(go == true)go1 = true;
}
});*/
welcomePanel.setLayout (null);
spinGo.addMouseListener(this);
paint.setBounds(0,0,600,600);
spinGo.setBounds(400,430,72,71);
welcomePanel.add(paint);
welcomePanel.add(spinGo);
welcomeFrame.setVisible(true);
welcomeFrame.setSize(600,600);
welcomeFrame.setLocationRelativeTo(null);
welcomeFrame.setContentPane(welcomePanel);
welcomePanel.setOpaque(false);

}
public void mouseClicked(MouseEvent e)
{
if(e.getSource() == spinGo)
{
paint.getGo(false);
paint.repaint();
}
//timer.start();
}
public void mouseEntered(MouseEvent e)
{
}
public void mouseExited(MouseEvent e)
{
}
public void mousePressed(MouseEvent e)
{
}
public void mouseReleased(MouseEvent e)
{
}


}
[/code]
Sign In or Register to comment.