我正在使用JPanel和BoxLayout,我想把它放在窗口中心,我有这个代码:
JPanel jorder = new JPanel();
jorder.setLayout(new BoxLayout(jorder, BoxLayout.Y_AXIS));
jorder.setBorder(BorderFactory.createTitledBorder("Order"));
JLabel jusuari = new JLabel("User name: edetorres");
JLabel jproduct = new JLabel("Product: Tallat");
JButton jserve = new JButton("Serve");
jorder.add(jusuari);
jorder.add(jproduct);
jorder.add(jserve);
然后它返回(仅照片的左侧面板):