实例 JTree(右键菜单,可拖拽)+Jtable(可翻页,列中含有按钮,隐藏列)(二)
_4.insets = new Insets(0, 0, 5, 5);
gbc_button_4.gridx = 5;
gbc_button_4.gridy = 0;
panel.add(button_4, gbc_button_4);
JScrollPane scrollPane = new JScrollPane();
GridBagConstraints gbc_scrollPane = new GridBagConstraints();
gbc_scrollPane.gridwidth = 7;
gbc_scrollPane.fill = GridBagConstraints.BOTH;
gbc_scrollPane.gridx = 0;
gbc_scrollPane.gridy = 1;
panel.add(scrollPane, gbc_scrollPane);
DefaultMutableTreeNode top = new DefaultMutableTreeNode("/");
createNodes(top);
tree = new JTree(top);
scrollPane.setViewportView(tree);
tree.setEditable(true);
tree.setDragEnabled(true);
this.setPopupMenu();
try {
tree.setTransferHandler(new DocsTreeTransferHanlder());
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
JPanel panel_1 = new JPanel();
contentPane.add(panel_1, BorderLayout.CENTER);
GridBagLayout gbl_panel_1 = new GridBagLayout();
gbl_panel_1.columnWidths = new int[] { 708, 0 };
gbl_panel_1.rowHeights = new int[] { 556, 0 };
gbl_panel_1.columnWeights = new double[] { 1.0, Double.MIN_VALUE };
gbl_panel_1.rowWeights = new double[] { 1.0, Double.MIN_VALUE };
panel_1.setLayout(gbl_panel_1);
JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
GridBagConstraints gbc_tabbedPane = new GridBagConstraints();
gbc_tabbedPane.fill = GridBagConstraints.BOTH;
gbc_tabbedPane.gridx = 0;
gbc_tabbedPane.gridy = 0;
panel_1.add(tabbedPane, gbc_tabbedPane);
JPanel panel_2 = new JPanel();
tabbedPane.addTab("\u6587\u4EF6\u4E0E\u76EE\u5F55\u7BA1\u7406", null,
panel_2, null);
GridBagLayout gbl_panel_2 = new GridBagLayout();
gbl_panel_2.columnWidths = new int[] { 166, 59, 0, 0, 0, 0, 0 };
gbl_panel_2.rowHeights = new int[] { 30, 0, 49, 0, 0, 0 };
gbl_panel_2.columnWeights = new double[] { 1.0, 0.0, 0.0, 0.0, 0.0,
0.0, Double.MIN_VALUE };
gbl_panel_2.rowWeights = new double[] { 0.0, 0.0, 1.0, 0.0, 0.0,
Double.MIN_VALUE };
panel_2.setLayout(gbl_panel_2);
currentDirLabel = new JLabel(
"\u5F53\u524D\u76EE\u5F55\uFF1Aone->
two->three");
GridBagConstraints gbc_lblonetwothree = new GridBagConstraints();
gbc_lblonetwothree.gridwidth = 6;
gbc_lblonetwothree.anchor = GridBagConstraints.WEST;
gbc_lblonetwothree.insets = new Insets(0, 0, 5, 0);
gbc_lblonetwothree.gridx = 0;
gbc_lblonetwothree.gridy = 0;
panel_2.add(currentDirLabel, gbc_lblonetwothree);
JButton button_3 = new JButton("\u5168\u9009/\u5168\u4E0D\u9009");
GridBagConstraints gbc_button_3 = new GridBagConstraints();
gbc_button_3.insets = new Insets(0, 0, 5, 5);
gbc_button_3.gridx = 3;
gbc_button_3.gridy = 1;
panel_2.add(button_3, gbc_button_3);
JButton button = new JButton("\u5220\u9664");
GridBagConstraints gbc_button = new GridBagConstraints();
gbc_button.insets = new Insets(0, 0, 5, 5);
gbc_button.gridx = 4;
gbc_button.gridy = 1;
panel_2.add(button, gbc_button);
JButton button_1 = new JButton("\u79FB\u52A8\u5230");
button_1.setToolTipText("\u8BF7\u5148\u9009\u62E9\u8981\u79FB\u52A8\u7684\u6587\u4EF6\uFF0C\u7136\u540E\u518D\u9009\u62E9\u4E00\u4E2A\u5DE6\u4FA7\u76EE\u5F55");
GridBagConstraints gbc_button_1 = new GridBagConstraints();
gbc_button_1.insets = new Insets(0, 0, 5, 0);
gbc_button_1.gridx = 5;
gbc_button_1.gridy = 1;
panel_2.add(