swing - How to force a component to grow in MigLayout in Java -
I have a component that is composed of various components such as a slider and a few buttons, I want to add it to a scroll panel And the slider increases to fill all the remaining space. This is not a problem because this code shows:
public static zero main (string [] args) {JFrame f = new JFrame ("test"); JPNL C = New Zygel (New Miglite ("", "[] 5 [] 10 [mounting] 10 [] 0 [] 0 [] 0 []", "[]")); C.add (new jacobox ("")); C.add (new JLab ("name")); C.add (new JSlider ()); C.add (new pocket ("1"); C.add (new pocket ("2"); C.add (new pocket ("3"); Seed (new pocket ("4"); F.getContentPane () Add (New JScrollPane (c)); F.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE); F.pack (); F.setVisible (true); }
If you run it and change the size of the frame, then the slider fills everywhere. My problem lies in the fact that I want to add my component (one with slider) to another component which has different examples of this one, so for example it has 3 or 4 components, with sliders under the other. I thought this would work:
public static zero main (string [] args) {JFrame f = new JFrame ("Test"); JPNL C = New Zygel (New Miglite ("", "[] 5 [] 10 [mounting] 10 [] 0 [] 0 [] 0 []", "[]")); C.add (new jacobox ("")); C.add (new JLab ("name")); C.add (new JSlider ()); C.add (new pocket ("1"); C.add (new pocket ("2"); C.add (new pocket ("3"); Seed (new pocket ("4"); Jepineel a = new zpinal (new megallout ("rap 1")); A.add (c); F.getContentPane () Add (New JScrollPane (A)); F.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE); F.pack (); F.setVisible (true); }
But it's not. Any idea why and how to fix it?
Try changing JPanel a
:
jpnil a = new zpinal (new mangleout ("rap 1", "[grow, fill]"));
Comments
Post a Comment