⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 loginframe.java

📁 本系统是基于CORBA实现的选课系统,具有一般选课系统的基本功能(查看学生基本信息,选课退课,查看成绩等),本系统主要是推荐给对刚进行CORBA学习的初学者来说有很大的重要性
💻 JAVA
字号:
import choose.*;
import org.omg.CosNaming.*;
import org.omg.CosNaming.NamingContextPackage.*;
import org.omg.CORBA.*;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;

public class loginFrame extends JFrame implements ActionListener
{
	private JPanel aPanel = new JPanel();
	private JButton aButton;
	private JButton bButton;
	private JLabel aLabel;
	private JLabel bLabel;
	private JTextField aTextField;
	private JPasswordField aPasswordField;
	
	public loginFrame()
	{
		setTitle("登陆");
		setupGUI();
	}
	
	public void setupGUI()
	{
		setSize(400,300);
		setLocation(100,20);
		Container conten = this.getContentPane();
		
	    conten.add(aPanel);
	    
	    setupPanel();
	}
	
	public void setupPanel()
	{
		aPanel.setLayout(null);
		
		aLabel = new JLabel("用户名");
		aLabel.setSize(70,30);
		aLabel.setLocation(70,80);
		aPanel.add(aLabel);
		
		bLabel = new JLabel("密码");
		bLabel.setSize(70,30);
		bLabel.setLocation(70,130);
		aPanel.add(bLabel);
		
		aTextField = new JTextField();
		aTextField.setSize(120,30);
		aTextField.setLocation(120,80);
		aPanel.add(aTextField);
		
		aPasswordField = new JPasswordField();
		aPasswordField.setSize(120,30);
		aPasswordField.setLocation(120,130);
		aPanel.add(aPasswordField);
		
		aButton = new JButton("登陆");
		aButton.setSize(70,30);
		aButton.setLocation(100,180);
		aPanel.add(aButton);
		aButton.addActionListener(this);
		
		bButton = new JButton("取消");
		bButton.setSize(70,30);
		bButton.setLocation(200,180);
		aPanel.add(bButton);
		bButton.addActionListener(new ActionListener()
				{
			     public void actionPerformed(ActionEvent e)
			     {
			    	 System.exit(0);
			     }
				});
	}

	float res;
	public void actionPerformed(ActionEvent e)
	{
		if(e.getSource()==aButton)
		{
			try{
			// 创建和初始化 ORB
			String   defaultargs[]={"-ORBInitialPort","900","-ORBInitialHost","192.168.108.73",}; 
			//String   defaultargs[]={"-ORBInitialPort","2089","-ORBInitialHost","192.168.0.164",};
			
			ORB orb = ORB.init(defaultargs, null);
			// 获取根命名上下文
			org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService");
			NamingContext ncRef = NamingContextHelper.narrow(objRef);
			//解析命名中的对象引用
			NameComponent nc = new NameComponent("choose","Object");
			NameComponent path[] = {nc};
			choose.xuanke ShowRef = xuankeHelper.narrow(ncRef.resolve(path));
			// 调用 Show 服务对象并打印结果
			res=ShowRef.login(aTextField.getText(),aPasswordField.getText());
			if(res==1)
			    System.out.println("hello");
			else
			    System.out.println("world"); 
			//System.out.println(show);
			
			} catch (Exception e1) {
				System.out.println("ERROR : " + e1) ;
				e1.printStackTrace(System.out);
			}
			
			if(res==1)
			{
				FirstFrame aFrame = new FirstFrame(aTextField.getText());
				aFrame.show();
				this.dispose();
			}
			else
			{
				JOptionPane.showMessageDialog(null,"输入不匹配","Warning",JOptionPane.INFORMATION_MESSAGE);
				aTextField.setText("");
				aPasswordField.setText("");
			}
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -