package logSFTP;
import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.Toolkit;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
public class AddMenu1 extends JFrame
{
private JTextField url = new JTextField(); //SFTP服务器地址
private JTextField port = new JTextField(); //SFTP服务器端口
private JTextField username = new JTextField(); //用户名
private JPasswordField password = new JPasswordField(); //密码
private JComboBox<String> select = new JComboBox<String>();
JScrollPane fileScrollPane;
private Dimension faceSize = new Dimension(300, 300); //框架大小
private String[] str = {"portal debug", "portal interface", "portal error", "portal warning"};
public AddMenu1()
{
init();
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //添加框架的关闭事件处理
this.pack();
this.setSize(faceSize); //设置框架的大小
//设置运行时窗口的位置
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
this.setLocation( (int)(screenSize.width - faceSize.getWidth()) / 2,
(int)(screenSize.height - faceSize.getHeight()) / 2);
this.setResizable(true);
this.setTitle("SFTP服务端"); //设置标题
setVisible(true);
this.addWindowListener( //关闭程序时的操作
new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
}
);
}
void init ()
{
Container contentPane = getContentPane(); //获取面板
contentPane.setLayout(new BorderLayout()); //设置布局
JPanel up = new JPanel(); //设置面板上方控件布局
up.setLayout(new GridLayout(5,2,10,8));
JPanel no1 = new JPanel();
no1.setLayout(new BorderLayout());
no1.add(new JLabel("服务器:"),BorderLayout.WEST);
no1.add(url,BorderLayout.CENTER);
no1.setSize(10, 20);
JPanel no2 = new JPanel();
no2.setLayout(new BorderLayout());
no2.add(new JLabel("端口号:"),BorderLayout.WEST);
no2.add(port,BorderLayout.CENTER);
JPanel no3 = new JPanel();
no3.setLayout(new BorderLayout());
no3.add(new JLabel("用户名:"),BorderLayout.WEST);
no3.add(username,BorderLayout.CENTER);
JPanel no4 = new JPanel();
no4.setLayout(new BorderLayout());
no4.add(new JLabel("密 码:"),BorderLayout.WEST);
no4.add(password,BorderLayout.CENTER);
JPanel no5 = new JPanel();
no5.setLayout(new BorderLayout());
for (String s : str)
{
select.addItem(s);
}
no5.add(new JLabel("日志文件:"),BorderLayout.WEST);
no5.add(select,BorderLayout.CENTER);
up.add(no1);
up.add(no2);
up.add(no3);
up.add(no4);
up.add(no5);
this.add(up,BorderLayout.NORTH);
}
public static void main(String[] args) {
new AddMenu1();
}
}