java - How to Move JLabes Around -
import java.awt.flowlayout; import javax.swing.jframe; import javax.swing.jlabel; public class gui_window extends jframe { private jlabel main_l; public gui_window() { setlayout(new flowlayout()); main_l = new jlabel("did know possible bind keys?"); add(main_l); } public static void main (string args[]) { gui_window gui = new gui_window(); gui.setdefaultcloseoperation(jframe.exit_on_close); gui.setsize(300,300); gui.setvisible(true); gui.settitle("gamers audiomute"); gui.setresizable(true); } }
i know how move "did know" label around. state how align left, right, middle , how move around coordinates?
you can use methods included in swing classes. try
mainl.sethorizontalalignment(swingconstants.left); mainl.setverticalalignment(swingconstants.bottom);
the 2 methods sethorizontalaligment
, setveritcalalignment
both take integers set start of either horizontal or vertical component of label pixel integer within swing window.
you should read on swingconstants allow plug in pre-defined integers swing align texts desirable locations within panel. here's link
http://docs.oracle.com/javase/7/docs/api/javax/swing/swingconstants.html
they useful when manipulating different layouts such borderlayout
, gridlayout
.
Comments
Post a Comment