Can I set a JPanel layout to null and use setBounds to position components? I have tried doing this but it does not work. It compiles, but does not show anything. Am I missing something here? JPanel panel = new JPanel(); JButton button = new JButton("Button"); panel.setLayout(null); panel.add(button); button.setBounds(20,30,20,30);
I think you need to set bounds before you add.... try that.
<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>"Those who cast the votes decide nothing. Those who count the<BR>votes decide<BR>everything." <BR> -Joseph Stalin<HR></BLOCKQUOTE>
Yes, actually I did try that and it did not work either. I ended up using GridBagLayout which is kind of a pain to use but it got the job done. I am still curious about setting a JPanel to null though. Thanks!!!
I had tried a similar thing sometime back and it worked. Have you done ? panel.setVisible(true) If you have done this, I can't think of any other reason
There are 10 kinds of people in this world. Those that understand binary get this tiny ad:
Gift giving made easy with the permaculture playing cards