📄 frame1.java
字号:
import java.awt.BorderLayout;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.ListModel;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JList;
import java.awt.Dimension;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JComboBox;
import java.awt.Rectangle;
import java.awt.Font;
import javax.swing.JPasswordField;
import java.awt.Point;
import java.awt.event.*;
import java.rmi.Naming;
import java.rmi.RemoteException;
import java.sql.SQLException;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.PreparedStatement;
/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class Frame1 extends JFrame implements ActionListener{
private static final long serialVersionUID = 1L;
private JButton jButton1;
private JButton jButton2;
private JLabel jLabel2;
private JLabel jLabel4;
private JTextField jTextField1;
private JTextField name;
private JLabel jLabel3;
private JLabel jLabel1;
private JButton jButton3;
private JPanel jContentPane = null;
private JComboBox jComboBox = null;
private JLabel jLabel = null;
private JPasswordField jPasswordField = null;
private CommunityServerInterface thecommunity; // @jve:decl-index=0:
private Virtualperson person;
private String url = null;
private boolean power = false;
/**
* This is the default constructor
*/
public Frame1() {
super();
initialize();
}
/**
* This method initializes this
*
* @return void
*/
private void initialize() {
this.setSize(313, 316);
this.setLocation(new Point(300, 150));
this.setTitle("社区登录");
this.setVisible(true);
this.setContentPane(getJContentPane());
}
/**
* This method initializes jContentPane
*
* @return javax.swing.JPanel
*/
private JPanel getJContentPane() {
if (jContentPane == null) {
jLabel = new JLabel();
jLabel.setBounds(new Rectangle(37, 4, 222, 34));
jLabel.setFont(new Font("Dialog", Font.BOLD, 18));
jLabel.setText("登录虚拟社区");
jContentPane = new JPanel();
jContentPane.setLayout(null);
jContentPane.add(getJButton1());
jContentPane.add(getJButton2());
jContentPane.add(getJButton3());
jContentPane.add(getJLabel1());
jContentPane.add(getJLabel2());
jContentPane.add(getJLabel3());
jContentPane.add(getJLabel4());
jContentPane.add(getname());
jContentPane.add(getJTextField1());
jContentPane.add(getJComboBox(), null);
jContentPane.add(jLabel, null);
jContentPane.add(getJPasswordField(), null);
}
return jContentPane;
}
private JButton getJButton1() {
if (jButton1 == null) {
jButton1 = new JButton("登录");
jButton1.setText("\u767b\u5f55");
jButton1.setBounds(35, 242, 62, 24);
jButton1.addActionListener(this);
}
return jButton1;
}
private JButton getJButton2() {
if (jButton2 == null) {
jButton2 = new JButton("注册");
jButton2.setText("\u6ce8\u518c");
jButton2.setBounds(122, 242, 62, 24);
jButton2.addActionListener(this);
}
return jButton2;
}
private JButton getJButton3() {
if (jButton3 == null) {
jButton3 = new JButton("取消");
jButton3.setText("\u53d6\u6d88");
jButton3.setBounds(211, 242, 65, 24);
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
System.exit(1); // TODO Auto-generated Event stub actionPerformed()
}
});
}
return jButton3;
}
private JLabel getJLabel1() {
if (jLabel1 == null) {
jLabel1 = new JLabel();
jLabel1.setText("\u7528\u6237\u540d\uff1a");
jLabel1.setBounds(24, 45, 55, 31);
}
return jLabel1;
}
private JLabel getJLabel2() {
if (jLabel2 == null) {
jLabel2 = new JLabel();
jLabel2.setText("\u5bc6\u7801\uff1a");
jLabel2.setBounds(24, 88, 55, 25);
}
return jLabel2;
}
private JLabel getJLabel3() {
if (jLabel3 == null) {
jLabel3 = new JLabel();
jLabel3.setText("\u767b\u5f55\u8eab\u4efd\uff1a");
jLabel3.setBounds(18, 132, 66, 23);
}
return jLabel3;
}
private JLabel getJLabel4() {
if (jLabel4 == null) {
jLabel4 = new JLabel();
jLabel4.setText("\u767b\u9646\u5730\u5740\uff1a");
jLabel4.setBounds(16, 177, 68, 29);
}
return jLabel4;
}
private JTextField getname() {
if (name == null) {
name = new JTextField();
name.setText("huangyuping");
name.setBounds(97, 48, 142, 24);
}
return name;
}
private JTextField getJTextField1() {
if (jTextField1 == null) {
jTextField1 = new JTextField();
jTextField1.setText("192.168.1.3");
jTextField1.setBounds(96, 179, 143, 24);
}
return jTextField1;
}
/**
* This method initializes jComboBox
*
* @return javax.swing.JComboBox
*/
private JComboBox getJComboBox() {
if (jComboBox == null) {
jComboBox = new JComboBox(new String[] {
"VirtualPerson", "VeditionCompany",
"EmpolderCompany"});
jComboBox.setBounds(new Rectangle(95, 131, 145, 27));
}
return jComboBox;
}
/**
* This method initializes jPasswordField
*
* @return javax.swing.JPasswordField
*/
private JPasswordField getJPasswordField() {
if (jPasswordField == null) {
jPasswordField = new JPasswordField();
jPasswordField.setBounds(new Rectangle(97, 88, 142, 26));
jPasswordField.setText("123456");
}
return jPasswordField;
}
public void actionPerformed(ActionEvent e){
if(e.getSource() == jButton2){
// System.out.println(jTextField1.getText());
if(jTextField1.getText()==null)
JOptionPane.showMessageDialog(null,"Please enter right ID!","ID error",JOptionPane.ERROR_MESSAGE);
else if(initializeRMI()){
url = jTextField1.getText();
this.setVisible(false);
Frame6 frame =new Frame6(url);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
else if(e.getSource() == jButton1){
if(initializeRMI()){
try{
power = thecommunity.getpermission(name.getText(), new String(jPasswordField.getPassword()),(String)jComboBox.getSelectedItem());
// System.out.println(power);
if(power){
// System.out.println(power);
this.setVisible(false);
Frame2 frame =new Frame2(name.getText(), new String(jPasswordField.getPassword()),(String)jComboBox.getSelectedItem(),url);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
else
JOptionPane.showMessageDialog(null,"Please enter right Message!","Message error",JOptionPane.ERROR_MESSAGE);
}
catch(Exception ex){
System.out.println(ex);
JOptionPane.showMessageDialog(null,"Internet is busy ,please retry!","Remote error",JOptionPane.ERROR_MESSAGE);
}
}
}
}
protected boolean initializeRMI(){
if(url!=null)
return true;
url = jTextField1.getText();
if(url.equals("default"))
url = "";
url = "rmi://"+url+"/";
try{
thecommunity = (CommunityServerInterface)Naming.lookup(url+"CommunityServerInterfaceImpl");
System.out.println("Server object "+thecommunity+" found");
url = jTextField1.getText();
return true;
}
catch(Exception ex){
System.out.println(url);
url = null;
System.out.println(ex);
JOptionPane.showMessageDialog(null,"Please enter right ID!","ID error",JOptionPane.ERROR_MESSAGE);
return false;
}
}
} // @jve:decl-index=0:visual-constraint="175,3"rmi://192.168.1.3/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -