📄 userinterface.java
字号:
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package sample.mtom.filetransfer.client;
import org.apache.axiom.om.OMElement;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.io.File;
import java.util.ArrayList;
public class UserInterface extends JPanel implements ActionListener {
public static final int WIDTH = 480;
public static final int HEIGHT = 560;
JButton brwsBut1;
JButton brwsBut2;
JButton addFileButton;
JButton removeButton;
JButton executeButton;
JRadioButton sendRadio;
JRadioButton sendRecRadio;
JRadioButton MTOMRadio;
JRadioButton SOAPRadio;
JCheckBox cacheBox;
DefaultListModel model;
JList fileList;
JScrollPane fileListScroller;
JFileChooser fileChooser;
File file = null;
JTextField cacheThresholdText;
JTextField cacheFolderText;
JTextField EPRText;
JTextField destFolderText;
JTextField fileField;
JLabel fileListLabel;
JLabel EPRLabel;
JLabel destDir;
JLabel opLabel;
JLabel MTOMSOAPLabel;
JLabel thresholdLabel;
JLabel cacheFolderLabel;
JLabel bytesLabel;
private boolean cacheEnable = false;
private String destFolder = null;
private String EPR = null;
private ArrayList files;
private MTOMClient parent;
private MTOMClientModel mtomTest;
public UserInterface(MTOMClient parent) {
this.parent = parent;
initComponents();
brwsBut1.addActionListener(this);
brwsBut2.addActionListener(this);
addFileButton.addActionListener(this);
removeButton.addActionListener(this);
fileField.addKeyListener(new KeyListener() {
public void keyTyped(KeyEvent e) {
addFileButton.setEnabled(true);
}
public void keyPressed(KeyEvent e) {
}
public void keyReleased(KeyEvent e) {
if (fileField.getText().length() == 0) {
addFileButton.setEnabled(false);
}
}
});
MTOMRadio.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
switchRadios(MTOMRadio, SOAPRadio);
}
});
SOAPRadio.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
switchRadios(SOAPRadio, MTOMRadio);
}
});
sendRadio.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
switchRadios(sendRadio, sendRecRadio);
cacheBox.setEnabled(false);
cacheBox.setSelected(false);
enableCaching();
}
});
sendRecRadio.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
switchRadios(sendRecRadio, sendRadio);
cacheBox.setEnabled(true);
enableCaching();
}
});
cacheBox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
enableCaching();
}
});
executeButton.addActionListener(this);
Container pane = parent.getContentPane();
this.setLayout(null);
pane.add(fileField);
pane.add(brwsBut1);
pane.add(addFileButton);
pane.add(removeButton);
pane.add(fileListLabel);
pane.add(fileListScroller);
pane.add(destDir);
pane.add(destFolderText);
pane.add(EPRLabel);
pane.add(EPRText);
pane.add(opLabel);
pane.add(MTOMRadio);
pane.add(SOAPRadio);
pane.add(MTOMSOAPLabel);
pane.add(sendRadio);
pane.add(sendRecRadio);
pane.add(cacheBox);
pane.add(thresholdLabel);
pane.add(cacheThresholdText);
pane.add(bytesLabel);
pane.add(cacheFolderLabel);
pane.add(cacheFolderText);
pane.add(brwsBut2);
pane.add(executeButton);
}
public void initComponents() {
files = new ArrayList(0);
fileField = new JTextField();
fileField.setBounds(20, 20, 320, 20);
this.brwsBut1 = new JButton("Browse");
brwsBut1.setBounds(350, 20, 100, 20);
brwsBut1.setToolTipText("Browse a file");
addFileButton = new JButton("Add");
addFileButton.setBounds(20, 50, 100, 20);
addFileButton.setToolTipText("Add file to the file list");
addFileButton.setEnabled(false);
removeButton = new JButton("Remove Selection");
removeButton.setBounds(140, 50, 150, 20);
removeButton.setToolTipText("Remove selected file from the file list");
removeButton.setEnabled(false);
fileListLabel = new JLabel("File List");
fileListLabel.setBounds(20, 80, 50, 20);
model = new DefaultListModel();
fileList = new JList(model);
fileListScroller = new JScrollPane(fileList);
fileListScroller.setBounds(20, 100, 430, 80);
destDir = new JLabel("Dest. Folder: ", JLabel.RIGHT);
destDir.setBounds(20, 200, 100, 20);
destFolderText = new JTextField();
destFolderText.setBounds(120, 200, 330, 20);
EPRLabel = new JLabel("End Point: ", JLabel.RIGHT);
EPRLabel.setBounds(20, 230, 100, 20);
EPRText = new JTextField();
EPRText.setText("http://127.0.0.1:8080/axis2/services/mtomSample");
EPRText.setBounds(120, 230, 330, 20);
MTOMSOAPLabel = new JLabel("Send Using");
MTOMSOAPLabel.setBounds(20, 270, 150, 20);
MTOMRadio = new JRadioButton("MTOM");
MTOMRadio.setBounds(20, 295, 100, 20);
MTOMRadio.setSelected(true);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -