Skip to main content

Posts

Showing posts with the label grouplayout

Java - How to resize components in GroupLayout

., Hello, I have a problem with GroupLayout . My code is: public chat () { JTextField chatbox; JTextField msgbox; JButton sendbutton; GroupLayout layout; super(); chatbox = new JTextField(); msgbox = new JTextField(); sendbutton = new JButton("Send"); layout = new GroupLayout(this); sendbutton.setPreferredSize(new Dimension(60, 20)); setBackground(new Color(255, 255, 255)); setLayout(layout); layout.setAutoCreateGaps(true); layout.setAutoCreateContainerGaps(true); layout.setHorizontalGroup(layout.createParallelGroup() .addComponent(chatbox) .addGroup(layout.createSequentialGroup() .addComponent(msgbox) .addComponent(sendbutton)) ); layout.linkSize(SwingConstants.HORIZONTAL, sendbutton); layout.setVerticalGroup(layout.createSequentialGroup() .addComponent(chatbox)