Note that there are some explanatory texts on larger screens.

plurals
  1. POExtra button keeps appearing
    primarykey
    data
    text
    <p>I'm kind of new to java and I experienced this little problem on every computer I run my program. My code is </p> <pre><code> import javax.swing.*; import java.awt.*; import java.awt.event.ActionListener; import java.awt.event.ActionEvent; public class FrameTest2 { public static void main(String[] args){ String s = "Catch Torchic"; MainMenu m = new MainMenu(s); } } class MainMenu extends JFrame { JButton autoa, manualb, createc, exitd; public MainMenu(String s){ super(s); setBackground(new Color(247,247,111)); setSize(640,600); setVisible(true); setResizable(false); setLocationRelativeTo(null); setDefaultCloseOperation(EXIT_ON_CLOSE); Container contentPane = getContentPane(); setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS)); CustomPanel panel = new CustomPanel(); panel.setAlignmentX(Component.CENTER_ALIGNMENT); panel.setMinimumSize(new Dimension(600,365)); panel.setPreferredSize(new Dimension(600,365)); panel.setMaximumSize(new Dimension(600,365)); panel.setBackground(new Color(247,247,111)); contentPane.add(panel); JPanel btnPanel = new JPanel(); btnPanel.setLayout( new BoxLayout(btnPanel, BoxLayout.Y_AXIS)); btnPanel.setBackground(new Color(247,247,111)); autoa = new JButton("AutoPlay"); autoa.setAlignmentX(Component.CENTER_ALIGNMENT); btnPanel.add(autoa); manualb = new JButton("Manual Play"); manualb.setAlignmentX(Component.CENTER_ALIGNMENT); btnPanel.add(manualb); createc = new JButton("Create Maze"); createc.setAlignmentX(Component.CENTER_ALIGNMENT); btnPanel.add(createc); exitd = new JButton("Exit"); exitd.setAlignmentX(Component.CENTER_ALIGNMENT); btnPanel.add(exitd); btnPanel.setAlignmentX(Component.CENTER_ALIGNMENT); contentPane.add(btnPanel); setContentPane(contentPane); ButtonHandler handler = new ButtonHandler(this); autoa.addActionListener(handler); manualb.addActionListener(handler); createc.addActionListener(handler); exitd.addActionListener(handler); } } class ButtonHandler implements ActionListener{ MainMenu mm; public ButtonHandler(MainMenu mm){ this.mm = mm; } public void actionPerformed(ActionEvent e){ if(e.getSource() == mm.autoa) System.out.println("Clicked on Auto"); else if(e.getSource() == mm.manualb) System.out.println("Clicked on Manual"); else if(e.getSource() == mm.createc) System.out.println("Clicked on Create"); else System.exit(0); } } class CustomPanel extends JPanel{ public void paintComponent (Graphics painter){ Image pic = Toolkit.getDefaultToolkit().getImage("logo.png"); if(pic != null) painter.drawImage(pic, 105, 30, this); } } </code></pre> <p>This code results into this: <a href="http://a3.sphotos.ak.fbcdn.net/hphotos-ak-ash4/318155_424290814251286_100000111130260_1871937_131988334_n.jpg" rel="nofollow">http://a3.sphotos.ak.fbcdn.net/hphotos-ak-ash4/318155_424290814251286_100000111130260_1871937_131988334_n.jpg</a></p> <p>where there is always the extra button on the upper left corner, My question is, how do I remove this? the button appears at random intervals, sometimes it does not.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload