在公司有机会学习java swing编程,是做一个腾讯云图形化界面测试工具。
界面难画,怕以后会用到,在此备份。相关代码 :
public void init(){
frame = new JFrame("腾讯云测试小公举");
frame.setBounds(520, 20, 620, 800);
frame.setLayout(null);
/*line1*/
secretIdLabel = new JLabel("SecretId");
secretIdLabel.setLocation(20, heightOfSecretId);
secretIdLabel.setSize(60, HEIGHT);
frame.add(secretIdLabel);
secretId = new JTextField("AKID3HS9VDHQeuydoopEaZtst6bf0Ephdu3n");
secretId.setLocation(90, heightOfSecretId);
secretId.setSize(360, HEIGHT);
frame.add(secretId);
/*Btn*/
startBtn = new JButton("开始");
startBtn.setLocation(480, heightOfSecretId+5);
startBtn.setSize(100, HEIGHT*2);
frame.add(startBtn);
/*line2*/
secretKeyLabel = new JLabel("SecretKey");
secretKeyLabel.setLocation(20, heightOfSecretKey);
secretKeyLabel.setSize(60, HEIGHT);
frame.add(secretKeyLabel);
secretKey = new JTextField("eG1rOSxEyQBbRpSs7TvMVCKlXuCt5keN");
secretKey.setLocation(90, heightOfSecretKey);
secretKey.setSize(360, HEIGHT);
frame.add(secretKey);
/*line3*/
moduleLabel = new JLabel("模块");
moduleLabel.setLocation(20, heightOfModule);
moduleLabel.setSize(30, HEIGHT);
frame.add(moduleLabel);
module = new JComboBox<String>(moduleStr);
module.setLocation(60, heightOfModule);
module.setSize(80, HEIGHT);
module.setSelectedIndex(0);
frame.add(module);
implLabel = new JLabel("接口");
implLabel.setLocation(150, heightOfModule);
implLabel.setSize(30, HEIGHT);
frame.add(implLabel);
impl = new JComboBox<String>(implStr[0]);
impl.setLocation(190, heightOfModule);
impl.setSize(150, HEIGHT);
impl.setSelectedItem(0);
frame.add(impl);
regionLabel = new JLabel("区域");
regionLabel.setLocation(350, heightOfModule);
regionLabel.setSize(30, HEIGHT);
frame.add(regionLabel);
region = new JComboBox<String>(regionStr);
region.setLocation(390, heightOfModule);
region.setSize(60, HEIGHT);
region.setSelectedItem(0);
frame.add(region);
requestMethodLabel = new JLabel("请求方法");
requestMethodLabel.setLocation(460, heightOfModule);
requestMethodLabel.setSize(60, HEIGHT);
frame.add(requestMethodLabel);
requestMethod = new JComboBox<String>(requestMethodStr);
requestMethod.setLocation(530, heightOfModule);
requestMethod.setSize(60, HEIGHT);
requestMethod.setSelectedItem(0);
frame.add(requestMethod);
/*输入*/
inputfont=new Font("宋体",Font.BOLD,18);
inputArea = new JTextArea(TIPS);
inputArea.setFont(inputfont);
inputScollPane = new JScrollPane(inputArea);
inputScollPane.setLocation(20, heightOfInputArea);
inputScollPane.setSize(560, 200);
frame.add(inputScollPane);
/*输出*/
outputfont=new Font("Arial",Font.PLAIN,16);
outputPane = new JTextPane();
outputPane.setFont(outputfont);
outputPane.setEditable(false);
outputScollPane = new JScrollPane(outputPane);
outputScollPane.setLocation(20, heightOfOutputArea);
outputScollPane.setSize(560, 420);
frame.add(outputScollPane);
/*message*/
message = new JLabel("");
message.setForeground(Color.RED);
message.setLocation(20, heightOfOutputArea + 420 );
message.setSize(600, 10);
message.setVisible(false);
frame.add(message);
frame.setVisible(true);
frame.setResizable(false);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}