package com;
import java.awt.Color;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JComboBox;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JTabbedPane;
import javax.swing.JToolBar;
import javax.swing.SwingConstants;
import javax.swing.JPanel;
import com.jgoodies.forms.factories.DefaultComponentFactory;
import java.awt.Scrollbar;
import javax.swing.JScrollPane;
import javax.swing.ScrollPaneConstants;
import javax.swing.JMenuBar;
public class Test3{
private JFrame frame;
private JTextField textField;
private JTextField textField_1;
private JTextField textField_2;
private JTextField textField_3;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
Test3 window = new Test3();
window.frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the application.
*/
public Test3() {
initialize();
}
/**
* Initialize the contents of the frame.
*/
private void initialize() {
frame = new JFrame();
frame.setBounds(100, 100, 1207, 765);
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().setLayout(null);
JLabel label = new JLabel("\u8BBE\u5907\u5730\u5740");
label.setBounds(27, 26, 60, 15);
frame.getContentPane().add(label);
textField = new JTextField();
textField.setBounds(97, 23, 82, 21);
textField.setText("000000000000");
textField.setColumns(10);
frame.getContentPane().add(textField);
JLabel label_1 = new JLabel("\u5BC6 \u7801");
label_1.setBounds(189, 26, 36, 15);
frame.getContentPane().add(label_1);
textField_1 = new JTextField();
textField_1.setBounds(243, 23, 66, 21);
textField_1.setText("00000000");
textField_1.setColumns(10);
frame.getContentPane().add(textField_1);
JLabel label_2 = new JLabel("\u7CFB\u7EDF\u65F6\u95F4\uFF1A2019/07/31 18:20:30");
label_2.setBounds(334, 26, 198, 15);
frame.getContentPane().add(label_2);
JLabel label_3 = new JLabel("\u901A\u8BAF\u4E32\u53E3");
label_3.setBounds(542, 26, 54, 15);
frame.getContentPane().add(label_3);
@SuppressWarnings("rawtypes")
JComboBox comboBox = new JComboBox();
comboBox.setBounds(606, 23, 66, 21);
frame.getContentPane().add(comboBox);
@SuppressWarnings("rawtypes")
JComboBox comboBox_1 = new JComboBox();
comboBox_1.setBounds(739, 23, 81, 21);
frame.getContentPane().add(comboBox_1);
JLabel label_4 = new JLabel("\u6CE2\u7279\u7387");
label_4.setBounds(682, 26, 47, 15);
frame.getContentPane().add(label_4);
JLabel label_5 = new JLabel("\u6821\u9A8C\u4F4D");
label_5.setBounds(830, 26, 47, 15);
frame.getContentPane().add(label_5);
@SuppressWarnings("rawtypes")
JComboBox comboBox_2 = new JComboBox();
comboBox_2.setBounds(887, 23, 71, 21);
frame.getContentPane().add(comboBox_2);
JButton button = new JButton("\u6253\u5F00\u4E32\u53E3");
button.setBounds(995, 22, 89, 23);
frame.getContentPane().add(button);
JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
tabbedPane.setBounds(27, 97, 1103, 578);
frame.getContentPane().add(tabbedPane);
JToolBar toolBar = new JToolBar();
toolBar.setOrientation(SwingConstants.VERTICAL);
toolBar.setToolTipText("");
tabbedPane.addTab("1.参数变量", null, toolBar, null);
JPanel panel = new JPanel();
panel.setBackground(Color.WHITE);
// panel.setPreferredSize(new Dimension(300,100));
// panel.setBorder(BorderFactory.createLineBorder(Color.GRAY, 3) );
toolBar.add(panel);
panel.setLayout(null);
JLabel lblNewJgoodiesTitle = DefaultComponentFactory.getInstance().createTitle(" \u5B9E\u65F6\u65F6\u949F");
lblNewJgoodiesTitle.setVerticalAlignment(SwingConstants.TOP);
lblNewJgoodiesTitle.setBounds(35, 10, 416, 29);
panel.add(lblNewJgoodiesTitle);
JLabel label_6 = new JLabel(" \u65E5\u671F");
label_6.setBounds(149, 49, 66, 15);
panel.add(label_6);
JLabel label_7 = new JLabel(" \u65F6\u95F4");
label_7.setBounds(149, 87, 66, 15);
panel.add(label_7);
textField_2 = new JTextField();
textField_2.setBounds(236, 49, 105, 21);
panel.add(textField_2);
textField_2.setColumns(10);
textField_3 = new JTextField();
textField_3.setColumns(10);
textField_3.setBounds(236, 84, 105, 21);
panel.add(textField_3);
JButton btnNewButton = new JButton("\u8BFB\u53D6");
btnNewButton.setBounds(517, 46, 93, 23);
panel.add(btnNewButton);
JButton button_7 = new JButton("\u8BFB\u53D6");
button_7.setBounds(517, 79, 93, 23);
panel.add(button_7);
JButton button_8 = new JButton("\u8BBE\u7F6E");
button_8.setBounds(620, 46, 93, 23);
panel.add(button_8);
JButton button_9 = new JButton("\u8BBE\u7F6E");
button_9.setBounds(620, 79, 93, 23);
panel.add(button_9);
JButton btnr = new JButton("\u5E7F\u64AD\r\n\u6821\u65F6");
btnr.setBounds(723, 50, 93, 48);
panel.add(btnr);
JLabel label_8 = DefaultComponentFactory.getInstance().createTitle(" \u8BBE\u5907\u4FE1\u606F");
label_8.setBounds(30, 137, 108, 15);
panel.add(label_8);
JPanel panel_2 = new JPanel();
panel_2.setBackground(Color.WHITE);
panel_2.setBounds(20, 10, 942, 117);
panel_2.setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY, 3) );
panel.add(panel_2);
JLabel label_9 = new JLabel(" \u901A\u8BAF\u5730\u5740");
label_9.setBounds(139, 162, 76, 15);
panel.add(label_9);
JLabel label_10 = new JLabel("\u8BBE\u5907\u53F7");
label_10.setBounds(149, 187, 66, 15);
panel.add(label_10);
JLabel label_11 = new JLabel("\u8D44\u4EA7\u7BA1\u7406\u7F16\u7801");
label_11.setBounds(149, 212, 66, 15);
panel.add(label_11);
JLabel label_12 = new JLabel("\u989D\u5B9A\u7535\u538B");
label_12.setBounds(149, 237, 66, 15);
panel.add(label_12);
JLabel label_13 = new JLabel("\u989D\u5B9A\u7535\u6D41");
label_13.setBounds(149, 262, 66, 15);
panel.add(label_13);
JLabel label_14 = new JLabel("\u58F3\u67B6\u7535\u6D41");
label_14.setBounds(149, 287, 66, 15);
panel.add(label_14);
JLabel label_15 = new JLabel("\u8BBE\u5907\u578B\u53F7");
label_15.setBounds(149, 314, 66, 15);
panel.add(label_15);
JLabel label_16 = new JLabel("\u751F\u4EA7\u65E5\u671F");
label_16.setBounds(149, 339, 66, 15);
panel.add(label_16);
JLabel label_17 = new JLabel("\u534F\u8BAE\u7248\u672C\u53F7");
label_17.setBounds(149, 364, 66, 15);
panel.add(label_17);
JLabel label_18 = new JLabel("\u5382\u5BB6\u5DE5\u5382\u4EE3\u7801");
label_18.setBounds(149, 395, 66, 15);
panel.add(label_18);
JLabel label_19 = new JLabel("\u56FA\u4EF6\u7248\u672C\u53F7");
label_19.setBounds(149, 424, 66, 15);
panel.add(label_19);
JLabel label_20 = new JLabel("\u786C\u4EF6\u7248\u672C\u53F7");
label_20.setBounds(149, 449, 66, 15);
panel.add(label_20);
JLabel label_21 = new JLabel("\u989D\u5B9A\u5269\u4F59\u7535\u6D41\u52A8\u4F5C\u503C");
label_21.setBounds(149, 474, 66, 15);
panel.add(label_21);
JLabel label_22 = new JLabel("\u751F\u4EA7\u65E5\u671F");
label_22.setBounds(149, 499, 66, 15);
panel.add(label_22);
Scrollbar scrollbar_1 = new Scrollbar();
scrollbar_1.setBounds(1079, 0, 17, 526);
// scrollbar_1.add(panel);
// JScrollPane scrollPane = new JScrollPane();
// scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
// scrollPane.setBounds(10, 0, 1060, 464);
// panel.add(scrollPane);
// JScrollPane scrollP = new JScrollPane(panel);
// scrollP.setBounds(10, 0, 1060, 464);
// frame.getContentPane().add(scrollP);
// frame.setVisible(true);
// frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// frame.getContentPane().add(panel);
// JScrollPane scrollPane = new JScrollPane(panel);
// scrollPane.setBounds(10, 10, 1076, 516);
// scrollPane = new JScrollPane(panel);
//// panel.add(scrollPane);
//// scrollPane.setBorder(new TitledBorder("发送区"));
// //滚动条自动出现
// scrollPane.setHorizontalScrollBarPolicy(
// JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
// scrollPane.setVerticalScrollBarPolicy(
// JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
// scrollPane.setBounds(48, 388, 500,127);
// frame.getContentPane().add(scrollPane);
JToolBar toolBar_1 = new JToolBar();//选项卡
toolBar_1.setOrientation(SwingConstants.VERTICAL);
tabbedPane.addTab("2.当前变量", null, toolBar_1, null);
JPanel panel_1 = new JPanel();
toolBar_1.add(panel_1);
panel_1.setLayout(null);
JScrollPane scrollPane = new JScrollPane();
scrollPane.setToolTipText("");
scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
scrollPane.setBounds(0, 10, 497, 311);
panel_1.add(scrollPane);
JMenuBar menuBar = new JMenuBar();
scrollPane.setViewportView(menuBar);
JButton btnNewButton_1 = new JButton("New button");
menuBar.add(btnNewButton_1);
JLabel lblNewLabel = new JLabel("New label");
menuBar.add(lblNewLabel);
JButton btnNewButton_2 = new JButton("New button");
menuBar.add(btnNewButton_2);
JLabel lblNewLabel_1 = new JLabel("New label");
menuBar.add(lblNewLabel_1);
JButton btnNewButton_3 = new JButton("New button");
menuBar.add(btnNewButton_3);
JButton btnNewButton_4 = new JButton("New button");
menuBar.add(btnNewButton_4);
Scrollbar scrollbar_2 = new Scrollbar();
scrollbar_2.setBounds(951, 0, 28, 526);
panel_1.add(scrollbar_2);
JToolBar toolBar_2 = new JToolBar();
toolBar_2.setOrientation(SwingConstants.VERTICAL);
tabbedPane.addTab("3.累计记录", null, toolBar_2, null);
JButton button_2 = new JButton("\u9009\u9879\u53613");
toolBar_2.add(button_2);
JToolBar toolBar_3 = new JToolBar();
toolBar_3.setOrientation(SwingConstants.VERTICAL);
tabbedPane.addTab("4.最值记录", null, toolBar_3, null);
JButton button_3 = new JButton("\u9009\u9879\u53614");
toolBar_3.add(button_3);
JToolBar toolBar_4 = new JToolBar();
toolBar_4.setOrientation(SwingConstants.VERTICAL);
tabbedPane.addTab("5.事件记录", null, toolBar_4, null);
JButton button_4 = new JButton("\u9009\u9879\u53615");
toolBar_4.add(button_4);
JToolBar toolBar_5 = new JToolBar();
toolBar_5.setOrientation(SwingConstants.VERTICAL);
tabbedPane.addTab("6.控制命令", null, toolBar_5, null);
JButton button_5 = new JButton("\u9009\u9879\u53616");
toolBar_5.add(button_5);
JToolBar toolBar_6 = new JToolBar();
tabbedPane.addTab("7.软件升级", null, toolBar_6, null);
JButton button_6 = new JButton("\u9009\u9879\u53617");
toolBar_6.add(button_6);
JToolBar toolBar_7 = new JToolBar();
tabbedPane.addTab("8.工厂定制", null, toolBar_7, null);
}
}
```javaSwing窗口布局,选项卡里的按钮、标题...如图还要往下添加按钮什么的,请问我如何使用滚动条继续往下添加按钮控件什么的,往各位大神帮忙![图片说明](https://img-ask.csdn.net/upload/201907/12/1562902250_879513.png)