swing - How to set JTextField border size in java -


I want to set the border height, the width of the JTextField and put it in the JFrame center in Java. I tried those ideas, but these ideas do not work. SetSize (), SetPrefferedSize (), SetMaximumSize ();

Need help in advance thanks.

  Import java.awt.BorderLayout; Import javax.swing.JFrame; Import javax.swing.JTextField; Public class P {public static zero main (string [] args) {JFrame frame = new JFrame (); JTextField field = new JTextField (); Frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE); . Add frame.getContentPane () (BorderLayout.NORTH, region); Frame.setSize (350,300); Frame.setVisible (true); }}   JTextField    

GridBagLayout

For example ...

 TextField import java.awt.color; Import java.awt.EventQueue; Import java.awt.GridBagLayout; Import javax.swing.JFrame; Import javax.swing.JTextField; Import javax.swing.UIManager; Import javax.swing.UnsupportedLookAndFeelException; Import javax.swing.border.LineBorder; Public category border text {public static zero main (string [] args) {new border (); } Public border text () {EventQueue.invokeLater (New Runnabel) {@Override public void run () {try} JTextField area = new JTextField (10); Field.setBorder (New LineBorder (Color.RED, 10)); JFrame frame = new JFrame ("test"); Frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE); Frame.setLayout (New GridBagLayout ()); Frame.ed (field); Frame.pack (); Frame.Setlicin Serial (faucet); Frames.Seviable (true);}}); }}

See more for more information

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -