Jump to content
  • Advertisement
Sign in to follow this  
Peter Conn

A problem with Swing

This topic is 4030 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hiya I am using java to make a GUI application, and I swing is doing something it hasn't before...
		main = new JFrame("Application");
		JPanel listPanel = new JPanel();
		JPanel dataPanel = new JPanel();
		entries = new JList();
		JScrollPane scroller = new JScrollPane(entries);
		listPanel.add(BorderLayout.CENTER, scroller);
		forename = new JTextField(10);
		surname = new JTextField(10);
		main.getContentPane().add(BorderLayout.WEST, listPanel);
		main.getContentPane().add(BorderLayout.EAST, dataPanel);
		main.setSize(480, 320);

What happens now is that the two text fields are shown side by side and overlapping with the list, I thought that panels were ment to stop such things from happening. Any help?

Share this post

Link to post
Share on other sites
You need to apply some useful layout manager to dataPanel.

For full control you should also look into GridBagLayout. Somewhat complex to use, but allows full control over layout.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!