hi. i want to align heading to the top centre and i want to align rest of my fields and labels to the left after heading. i have tried alot but cant do it.
i want to do it like this
gH5Wq.png
public class Main { public static void main(String[] args) { Entry test = new Entry(); } } -------------------------- import java.awt.*; import javax.swing.*; public class Objects { JLabel top; // TextInput Fields JTextField SerialNo; JTextField RecDate; JTextField GatePassNo; JTextField BoxNo; public GridBagConstraints gbc = new GridBagConstraints(); public JPanel EntryPanel = new JPanel(new GridBagLayout()); JPanel HeadingPanel= new JPanel(); Objects() { top = new JLabel("Text1"); BoxNo = new JTextField(10); SerialNo = new JTextField(10); } } -------------------------- import java.awt.*; import javax.swing.*; public class Entry extends Objects{ public Entry() { JFrame entry= new JFrame("Text1"); entry.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); entry.setLocationRelativeTo(null); entry.setVisible(true); top.setFont(new Font("Serif",Font.BOLD,30)); entry.getContentPane().add(HeadingPanel,BorderLayout.PAGE_START); HeadingPanel.add(top); entry.getContentPane().add(EntryPanel,BorderLayout.WEST); gbc.gridx = 1; gbc.gridy=5; EntryPanel.add(BoxNo); entry.setSize(600,600); } }
cross-posted: http://www.coderanch.com/t/590070/GU...-GridBagLayout
http://www.java-forums.org/awt-swing...baglayout.html