java - How can I align all my swing components to the top left of JPanel/JFrame -
hey guys i'm new swing in java ive created simple program has 1 jlabel says continue , 2 jbuttons 1 says yes , 1 says no.
i'm using gridbaglayout organize jpanel / jframe. program compiles , runs fine gridbaglayout centers components in center of jframe. since i'm new swing can show me how may possible align components top left of jframe?
thanks! :)
it might not real answer, anyway: stop using gridbaglayout. has many pitfalls , brittle use, please don't use it.
use better alternative such miglayout, , learn that. don't bother learning of java's default layout managers, except if really, need to.
an example using miglayout:
jpanel panel = new jpanel(new miglayout("","","")); panel.add(myjbutton1, "wrap"); panel.add(myjbutton2, "wrap"); panel.add(myjbutton3, "wrap"); panel.add(myjbutton4, "wrap"); panel.add(myjbutton5, "wrap"); panel.add(myjbutton6, "wrap");
Comments
Post a Comment