尝试使用a
GridBagLayout并添加带有空
GridBagConstrants对象的面板。
例如:
public static void main(String[] args) { Jframe frame = new Jframe(); frame.setLayout(new GridBagLayout()); JPanel panel = new JPanel(); panel.add(new JLabel("This is a label")); panel.setBorder(new LineBorder(Color.BLACK)); // make it easy to see frame.add(panel, new GridBagConstraints()); frame.setSize(400, 400); frame.setLocationRelativeTo(null); frame.setDefaultCloseOperation(Jframe.EXIT_ON_CLOSE); frame.setVisible(true);}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)