我正在向 a 添加两个JPanel
对象(面板包含表格)JSplitPane
,由于某种原因该表格不完全可见。我想添加一个屏幕截图以供参考,但堆栈溢出不允许我这样做:(。无论如何,与此相关的代码如下:请提出一些解决方案。
frame.setTitle(PAGE2);
final String[] stream_column_names = { "IP Address", "Port", "IP Address", "Port", "Transport" };
final String[] packet_column_names = { "#", "Direction", "Preview" };
final JScrollPane pane1 = new JScrollPane();
final JScrollPane pane2 = new JScrollPane();
final JLabel label1 = new JLabel();
final JLabel label2 = new JLabel();
splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, streamPanel, packetPanel);
splitPane.setOneTouchExpandable(true);
splitPane.setDividerLocation(350);
streamPanel = new JPanel();
streamPanel.setLayout(new BorderLayout());
pane1.setLayout(new ScrollPaneLayout());
label1.setText("STREAM:");
label1.setVerticalAlignment(SwingConstants.CENTER);
label1.setHorizontalAlignment(SwingConstants.LEFT);
streamInfoTable = new JTable();
pane1.setViewportView(streamInfoTable);
streamInfoTable.setModel(streamTableModel);
streamTableModel.setColumnIdentifiers(stream_column_names);
streamPanel.add(label1, BorderLayout.NORTH);
streamPanel.add(pane1);
streamPanel.getPreferredSize();
splitPane.add(streamPanel);
packetPanel = new JPanel();
packetPanel.setLayout(new BorderLayout());
pane2.setLayout(new ScrollPaneLayout());
label2.setText("PACKET:");
label2.setVerticalAlignment(SwingConstants.CENTER);
label2.setHorizontalAlignment(SwingConstants.LEFT);
packetInfoTable = new JTable();
pane2.setViewportView(packetInfoTable);
packetInfoTable.setModel(packetTableModel);
packetInfoTable.setRowSelectionAllowed(false);
packetInfoTable.setColumnSelectionAllowed(false);
packetTableModel.setColumnIdentifiers(packet_column_names);
packetPanel.add(label2, BorderLayout.NORTH);
packetPanel.add(pane2);
packetPanel.getPreferredSize();
splitPane.add(packetPanel);
centerPanel.add(splitPane);
frame.add(centerPanel, BorderLayout.CENTER);
frame.setVisible(true);
jDesktopPane.add(frame);