现在我正在尝试在框架旁边添加标签。我有一个标签文本,想把它对齐到中心,但它失败了,总是左对齐。请帮我!
Simulation sm = new Simulation(dm);
JFrame simulation = new JFrame();
simulation.setTitle("Traffic light and Car park Siumulation");
simulation.setSize(800,600);
simulation.setResizable(false);
simulation.setVisible(true);
simulation.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
simulation.add(sm, BorderLayout.CENTER);
//Carpark label
JLabel carparklb = new JLabel("abcd");
carparklb.setPreferredSize(new Dimension(200,600));
carparklb.setVerticalTextPosition(JLabel.CENTER);
carparklb.setHorizontalTextPosition(SwingConstants.CENTER);
simulation.add(carparklb, BorderLayout.EAST);