请问我该怎样写才能让长方形变长并且将它移下,摆在中间 ?谢谢!public class SelectSeat extends JPanel { int a; Object source; int counter= 0; static JFrame frame = new JFrame("Select Seat"); public static void main(String[] args) { SwingUtilities.invokeLater(() -> { try { createAndShowGui(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } }); } static void createAndShowGui() throws Exception { frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().add(new SelectSeat()); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); } public SelectSeat() throws Exception { JPanel topPanel= new JPanel(new GridLayout(1, 15)); RectDraw rect= new RectDraw(); rect.setPreferredSize(new Dimension(30,25)); topPanel.add(rect); JToggleButton[] ButtonList = new JToggleButton[30]; JPanel ButtonPanel= new JPanel(new GridLayout(5,15,45,25)); // row,col,hgap,vgap for(int i = 0; i < 30; i++) { a=i+1; ButtonList[i]= new JToggleButton(""+a); ButtonPanel.add(ButtonList[i]); }
添加回答
举报
0/150
提交
取消