我正在尝试构建一个寄存器,这样当单击一个按钮时,表格上会出现一个新条目.理想情况下,我希望在屏幕左侧构建一个表格,当单击按钮时会出现两行和新列.我希望表具有固定的大小,但是在一定数量的条目之后它应该是可滚动的.到目前为止,我已经创建并格式化了JButton我想要单击的对象以显示新条目.我也知道我应该用a JTable来追求这个.
我该怎么做这个动态表?
代码:
private void addRegister(JPanel pane) {
JPanel everythingPane = new JPanel();
JPanel pluPane = new JPanel();
Dimension button = new Dimension(200,150);
JTable pluTable = new JTable();
JPanel buttonPane = new JPanel();
buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.Y_AXIS));
//JPanel buttonPane = new JPanel (new FlowLayout (FlowLayout.LEFT));
JPanel subPane1 = new JPanel();
subPane1.setAlignmentX(LEFT_ALIGNMENT);
JPanel subPane2 = new JPanel();
subPane2.setAlignmentX(LEFT_ALIGNMENT);
JPanel subPane3 = new JPanel();
subPane3.setAlignmentX(LEFT_ALIGNMENT);
JPanel subPane4 = new JPanel();
subPane4.setAlignmentX(LEFT_ALIGNMENT);
JPanel subPane5 = new JPanel();
subPane5.setAlignmentX(LEFT_ALIGNMENT);
JPanel alignmentLayer …Run Code Online (Sandbox Code Playgroud)