hello now i already know how to set it, at the moment to add to the contentpanel add .setlocation(x,y) it works for me. Play with the pixels and make your frame as you want
location components java
-
28-11-2021 - |
Question
Now i already have a panel with 25 Jbutton and its shows on the frame, but i neeed other panel with other information so i created another panel and add to this a button for example. But the location of this a dont know how to set it. Some advice for this. Remember i have other panel and i want the new one on the left side from panel with buttons
JPanel panel = new JPanel();
panel.setSize(100,100);
jPanel.setBorder(new TitledBorder(new EtchedBorder(), "hi"));
JButton b = new JButton("test");
panel.add(b);
frame.getContentPane().add(panel);
Solution 2
OTHER TIPS
To add your new panel on the left hand side of the JFrame
, you can simply add it to the BorderLayout.WEST
location:
frame.add(panel, BorderLayout.WEST);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow