Jump to content

My GUI is invisible until I hover over it?


creationx

Recommended Posts

private void createGUI(){
		  gui = new JFrame("GUI");													
		  gui.setBounds(100, 100, 136, 227);											
		  gui.setVisible(true);															
		  gui.setResizable(false);														
		  JPanel panel = new JPanel();
		  gui.add(panel);
			panel.setBorder(new EmptyBorder(5, 5, 5, 5));
			JLabel lblRockCrabs = new JLabel("ROCK CRABS");
			lblRockCrabs.setFont(new Font("Arial", Font.BOLD, 14));
			lblRockCrabs.setBounds(10, 11, 100, 14);
			panel.add(lblRockCrabs);
			
			JLabel lblFood = new JLabel("Food");
			lblFood.setBounds(45, 94, 30, 14);
			panel.add(lblFood);
			
			JComboBox<String> comboBox_1 = new JComboBox<String>();
			comboBox_1.setBounds(10, 112, 95, 20);
			comboBox_1.addItem("SELECT ONE");
			comboBox_1.addItem("Lobster");
			comboBox_1.addItem("Swordfish");
			comboBox_1.addItem("Shark");
			comboBox_1.addItem("Lobster");
			comboBox_1.addActionListener(e -> foodSelected = comboBox_1.getSelectedItem().toString());
			panel.add(comboBox_1);
			
			JLabel lblVersion = new JLabel("version 1.0");
			lblVersion.setBounds(20, 22, 54, 14);
			panel.add(lblVersion);
			
			JButton btnStartScript = new JButton("START");
			btnStartScript.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent e) {
					started = true;
					gui.setVisible(false);
				}
			});
			btnStartScript.setBounds(24, 154, 71, 23);
			panel.add(btnStartScript);
	    }
	

For some reason the GUI is not showing up fully. It pops up with nothing on it, and I have to hover my mouse over it to suddenly make everything show up. Then it acts normally and I can select my options and move on. 

What is happening? I followed two tutorials the best I could, but there is clearly something I missed, as other scripts have no problem.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...