亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來(lái)到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? registerclient.java

?? 21天學(xué)通J2EE的例子3
?? JAVA
字號(hào):
package client;

import agency.*;
import javax.ejb.*;
import javax.naming.*;
import java.rmi.*;
import javax.rmi.*;
import javax.swing.*;
import javax.swing.text.*;
import javax.swing.border.*;
import java.awt.*;
import java.awt.event.*;

public class RegisterClient extends JPanel implements ActionListener
{
    public static void main(String[] args) {
    	if (args.length!=0 && args.length!=2) {
    		System.err.println("Usage: RegisterClient AgencyJNDI RegisterJNDI");
    		System.exit(1);
    	}
   		final JFrame window = new JFrame("Agency Register Applicant");
   		try {
	        final RegisterClient client = new RegisterClient(args.length==2?args[0]:null, args.length==2?args[1]:null);
	    	window.addWindowListener(new WindowAdapter() {
	    		public void windowClosing(WindowEvent ev) {
	    			client.shutdown();
	    			window.dispose();
					System.exit(0);
	    		}
	    	});
	    	String title = client.getAgencyName();
	    	window.setTitle(title);
	    	Container cp = window.getContentPane();
	    	cp.add(heading(title),BorderLayout.NORTH);
	    	cp.add(client,BorderLayout.CENTER);
	   		window.pack();
	    	window.setVisible(true);
            }
    	catch (Exception ex) {
 	    	System.err.println(ex);
	    	window.dispose();
	    	System.exit(1);
    	}
    }

    private static JLabel heading(String s) {
    	JLabel label = new JLabel(s,SwingConstants.CENTER);
    	Font old = label.getFont();
    	Font f = new Font(old.getName(),old.getStyle()|Font.BOLD|Font.ITALIC,(int)(old.getSize()*1.20));
    	label.setFont(f);
    	return label;
    }

	private String agencyJNDI = "java:comp/env/ejb/Agency";
	private String registerJNDI = "java:comp/env/ejb/Register";

    private Agency agency;
    private Register register;

    public RegisterClient(String agencyJNDI, String registerJNDI) {
    	if (agencyJNDI != null)
    		this.agencyJNDI = agencyJNDI;
    	if (registerJNDI != null)
	    	this.registerJNDI = registerJNDI;
    	try
    	{
    		setLayout(new BorderLayout());
	    	agency = getAgency(this.agencyJNDI);
	    	loadTables(agency);
	    	Box b = Box.createHorizontalBox();
	 		b.add (nwPanel());
	 		b.add (nePanel());
	 		add (b, BorderLayout.NORTH);
	    	add (mainPanel(), BorderLayout.CENTER);
	    	loginButton.addActionListener(this);
	    	logoffButton.addActionListener(this);
	    	registerButton.addActionListener(this);
	    	updateButton.addActionListener(this);
	    	addSkillButton.addActionListener(this);
	    	removeSkillButton.addActionListener(this);
	    	deleteButton.addActionListener(this);
	    	enableForm(false);
    	}
    	catch (NamingException ex) {
    		abort("getAgency",ex.toString());
    	}
    	catch (CreateException ex) {
    		abort("getAgency",ex.toString());
    	}
    	catch (RemoteException ex) {
    		abort("getAgency",ex.toString());
    	}
    	catch (ClassCastException ex) {
    		abort("getAgency",ex.toString());
    	}
    }

    private FixedField login = new FixedField(16);

    private FixedField addLogin = new FixedField(16);
    private FixedField addName = new FixedField(16);
    private FixedField addEmail = new FixedField(16);

    private FixedField name = new FixedField(16);
    private FixedField email = new FixedField(16);
    private JTextArea summary = new JTextArea(4,32);
    private JComboBox location;
    private JList allSkills;
    private DefaultListModel skills = new DefaultListModel();
    private JList actualSkills = new JList(skills);

    private JButton loginButton = new JButton("Login");
    private JButton logoffButton = new JButton("Logoff");
    private JButton updateButton = new JButton("Update");
    private JButton registerButton = new JButton("Register");
    private JButton addSkillButton = new JButton("Add");
    private JButton removeSkillButton = new JButton("Remove");
    private JButton deleteButton = new JButton("Delete Registration");

	private JPanel boxPanel(String name) {
    	JPanel p = new JPanel();
    	Border border = BorderFactory.createEtchedBorder();
    	border = BorderFactory.createTitledBorder(border,name);
    	p.setLayout (new BoxLayout(p,BoxLayout.Y_AXIS));
    	p.setBorder(border);
    	return p;
	}

	private JPanel panelRow(JComponent l, JComponent r) {
		JPanel p = new JPanel(new FlowLayout(FlowLayout.LEFT));
		p.add (l);
		if (r != null)
			p.add (r);
		return p;
	}

    private JPanel nwPanel() {
    	JPanel panel = boxPanel("Login");
    	panel.add (panelRow(new FixedLabel("Login name:"),login));
    	panel.add (Box.createVerticalGlue());
    	panel.add(panelRow(loginButton,logoffButton));
    	return panel;
    }

    private JPanel nePanel() {
    	JPanel panel = boxPanel("Register");
    	panel.add (panelRow(new FixedLabel("Login name:"),addLogin));
    	panel.add (panelRow(new FixedLabel("Full name:"),addName));
    	panel.add (panelRow(new FixedLabel("Email address:"),addEmail));
    	panel.add (Box.createVerticalGlue());
    	panel.add(panelRow(registerButton,null));
    	return panel;
    }

    private JPanel mainPanel() {
    	actualSkills.setVisibleRowCount(4);

    	JPanel panel = boxPanel("Applicant details");
	    Box left = Box.createVerticalBox();
    	left.add (panelRow(new FixedLabel("Full name:"),name));
    	left.add (panelRow(new FixedLabel("Email address:"),email));
    	left.add (panelRow(new FixedLabel("Location:"),location));
	   	left.add(panelRow(new FixedLabel("Skills:"),new JScrollPane(actualSkills)));
    	left.add(panelRow(new FixedLabel(""),removeSkillButton));

	    Box right = Box.createVerticalBox();
    	right.add (panelRow(new FixedLabel("Summary:"),new JScrollPane(summary)));
    	right.add(panelRow(new FixedLabel("Available skills:"),new JScrollPane(allSkills)));
    	right.add(panelRow(new FixedLabel(""),addSkillButton));

	    Box t = Box.createHorizontalBox();
    	t.add (left);
    	t.add (Box.createHorizontalGlue());
    	t.add (right);
    	panel.add(t);

    	panel.add (Box.createVerticalGlue());
    	panel.add(panelRow(updateButton,deleteButton));
    	return panel;
    }

	public void actionPerformed(ActionEvent ev) {
		try {
			Object o = ev.getSource();
			if (o == loginButton)
				doLogin();
			else if (o == logoffButton)
				doLogoff();
			else if (o == updateButton)
				doUpdate();
			else if (o == registerButton)
				doRegister();
			else if (o == addSkillButton)
				doAddSkill();
			else if (o == removeSkillButton)
				doRemoveSkill();
			else if (o == deleteButton)
				doDelete();
			else
				warning("Unknown event","Unknown event: "+ev);
    	}
    	catch (NamingException ex) {
    		error("actionPerformed",ex.toString());
    		ex.printStackTrace();
    	}
    	catch (CreateException ex) {
    		error("actionPerformed",ex.toString());
    		ex.printStackTrace();
    	}
    	catch (RemoveException ex) {
    		error("actionPerformed",ex.toString());
    		ex.printStackTrace();
    	}
    	catch (RemoteException ex) {
    		error("actionPerformed",ex.toString());
    		ex.printStackTrace();
    	}
    	catch (ClassCastException ex) {
    		error("actionPerformed",ex.toString());
    		ex.printStackTrace();
    	}
	}

    public void shutdown() {
     	try {
	    	if (register != null)
	    		register.remove();
	    	if (agency != null)
	    		agency.remove();
    	}
    	catch (RemoveException ex) {
    		error("actionPerformed",ex.toString());
    		ex.printStackTrace();
    	}
    	catch (RemoteException ex) {
    		error("actionPerformed",ex.toString());
    		ex.printStackTrace();
    	}
    }

	private void enableForm(boolean on)
	{
		loginButton.setEnabled(!on);
		logoffButton.setEnabled(on);
		updateButton.setEnabled(on);
    	addSkillButton.setEnabled(on);
    	removeSkillButton.setEnabled(on);
    	deleteButton.setEnabled(on);
    	login.setEnabled(!on);
	}

    private void abort (String title, String message) {
    	error (title, message);
    	shutdown ();
    	throw new RuntimeException(message);
    }

    private void error (String title, String message) {
    	JOptionPane.showMessageDialog(this,message,title,JOptionPane.ERROR_MESSAGE);
    }

    private void warning (String title, String message) {
    	JOptionPane.showMessageDialog(this,message,title,JOptionPane.WARNING_MESSAGE);
    }

    private void info (String title, String message) {
    	JOptionPane.showMessageDialog(this,message,title,JOptionPane.INFORMATION_MESSAGE);
    }

	private static class FixedField extends JTextField
	{
		public FixedField (int n) { super(n); }
		public Dimension getMinimumSize() { return getPreferredSize(); }
		public Dimension getMaximumSize() { return getPreferredSize(); }
		public float getAlignmentX() { return 0;}
		public float getAlignmentY() { return 0;}
	}

	private static final JLabel sample = new JLabel("abcdefghijklmn");

	private static class FixedLabel extends JLabel
	{
		private Dimension size;
		public FixedLabel (String s) {
			super(s);
			size = super.getPreferredSize();
			size.width = sample.getPreferredSize().width;
		}
		public Dimension getPreferredSize() { return size; }
		public Dimension getMinimumSize() { return size; }
		public Dimension getMaximumSize() { return size; }
		public float getAlignmentX() { return 0;}
		public float getAlignmentY() { return 0;}
	}

	private boolean isNull (String s) {
		return s==null || s.length()==0;
	}

	private boolean isNull (JTextComponent c) {
		return isNull(c.getText());
	}

	// EJB stuff from here

    private Agency getAgency(String agencyJNDI)
    	throws NamingException, RemoteException, CreateException, ClassCastException {
        InitialContext ic = new InitialContext();
        Object lookup = ic.lookup(agencyJNDI);
        AgencyHome home = (AgencyHome)PortableRemoteObject.narrow(lookup, AgencyHome.class);
    	return home.create();
    }

    public String getAgencyName() {
    	try {
    		return agency.getAgencyName();
    	}
    	catch (RemoteException ex) {
    		error("getAgencyName",ex.toString());
    		ex.printStackTrace();
    	}
		return "Agency";
    }

    private void loadTables(Agency agency) throws RemoteException {
    	location = new JComboBox(agency.getLocations().toArray());
    	allSkills = new JList(agency.getSkills().toArray());
    	allSkills.setVisibleRowCount(4);
    }

    private void resetDetails() throws RemoveException, RemoteException {
		if (register != null)
		{
			register.remove();
			register = null;
		}
		enableForm (false);
		login.setText("");
		name.setText("");
		email.setText("");
		summary.setText("");
		location.setSelectedIndex(0);
		skills.clear();
    }

	private RegisterHome regHome;

    private void doLogin()
    	throws NamingException, RemoteException, RemoveException, CreateException, ClassCastException {
    	String name = login.getText();
    	if (isNull(name)) {
    		error ("Login","No login name specified");
    		return;
    	}
    	resetDetails();
    	login.setText(name);
		if (regHome == null) {
    		InitialContext ic = new InitialContext();
	        Object lookup = ic.lookup(registerJNDI);
	        regHome = (RegisterHome)PortableRemoteObject.narrow(lookup, RegisterHome.class);
		}

    	register = regHome.create(name);
    	loadDetails (register);
    	enableForm(true);
    }

    private void doLogoff() throws RemoveException, RemoteException {
    	resetDetails();
    	enableForm(false);
    }

    private void loadDetails (Register register) throws RemoteException {
    	name.setText(register.getName());
    	email.setText(register.getEmail());
    	summary.setText(register.getSummary());
    	String[] skillList = register.getSkills();
    	location.setSelectedItem(register.getLocation());
    	skills.clear();
    	for (int i=0; i<skillList.length; i++)
    		skills.addElement(skillList[i]);
    }

    private void doRegister()
       	throws NamingException, RemoveException, RemoteException, CreateException, ClassCastException {
    	if (isNull(addLogin) || isNull(addName) || isNull(addEmail)) {
    		error("Null field","You must provide a login, full name and email address");
    		return;
    	}
    	resetDetails();
    	try {
	    	agency.createApplicant(addLogin.getText(),addName.getText(),addEmail.getText());
	    	login.setText(addLogin.getText());
	    	doLogin();
    	}
    	catch (DuplicateException ex) {
    		error ("Duplicate Login","Login name already in use - try another");
    	}
    }

    private void doUpdate() throws RemoteException {
    	if (register == null) {
    		error ("No applicant", "You must login or register before updating your details");
    		return;
    	}
    	String[] skillList = new String[skills.size()];
    	skills.copyInto (skillList);
		register.updateDetails (name.getText(),email.getText(),(String)location.getSelectedItem(),summary.getText(),skillList);
		info ("Update Complete","Database updated successfully");
    }

    private void doDelete() throws RemoveException, RemoteException {
    	if (register == null) {
    		error ("No applicant", "You must login before deleting your entry");
    		return;
    	}
    	try {
	    	agency.deleteApplicant(login.getText());
	    	resetDetails();
			info ("Delete Complete","Applicant entry deleted successfully");
    	}
    	catch (NotFoundException ex) {
    		error ("Missing Login","Internal error - applcation entry not found");
    	}
    }

    private void doAddSkill() throws RemoteException {
    	if (register == null) {
    		error ("No applicant", "You must login or register before modifying skills");
    		return;
    	}
    	Object[] skill = allSkills.getSelectedValues();
    	if (skill.length == 0)
	    	warning ("No skill","You must select a skill to add from the available skills list");

   		for (int i=0; i<skill.length; i++) {
	    	if (!skills.contains(skill[i]))
	    		skills.addElement(skill[i]);
	    	else
	    		warning ("Duplicate skill",skill[i]+" already selected");
    	}
    	//actualSkills.invalidate();
    	//validate();
    }

    private void doRemoveSkill() throws RemoteException {
    	if (register == null) {
    		error ("No applicant", "You must login or register before modifying skills");
    		return;
    	}
    	Object[] skill = (actualSkills.getSelectedValues());
     	if (skill.length == 0)
	    	warning ("No skill","You must select a skill to remove from the skills list");
 	  	for (int i=0; i<skill.length; i++) {
	    	if (skills.contains(skill[i]))
	    		skills.removeElement(skill[i]);
    	}
    }
}


?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品一区二区无线| 国产伦精品一区二区三区免费迷| 91精品国产麻豆| 成人app网站| 蓝色福利精品导航| 亚洲影院免费观看| 国产日韩欧美不卡| 777午夜精品免费视频| 国产自产高清不卡| 亚洲欧洲中文日韩久久av乱码| 2020日本不卡一区二区视频| 欧美性感一区二区三区| 国产91精品一区二区麻豆亚洲| 亚洲成人一二三| 亚洲精品免费播放| 国产欧美日韩在线观看| 欧美一区二区三区喷汁尤物| 色又黄又爽网站www久久| 国产精品一二三| 精品在线免费视频| 奇米影视7777精品一区二区| 亚洲狼人国产精品| 国产精品电影一区二区| 久久久蜜桃精品| 日韩视频免费观看高清完整版 | 岛国av在线一区| 青青青伊人色综合久久| 亚洲精品视频在线看| 国产农村妇女精品| 久久久99久久| 久久久久久久久免费| 日韩欧美国产电影| 777色狠狠一区二区三区| 99国产精品久| 91免费国产在线| 99这里只有久久精品视频| 国产成a人亚洲精| 国产成人免费视| 国产成人高清在线| 国产精品羞羞答答xxdd| 国产真实乱子伦精品视频| 精品中文字幕一区二区小辣椒| 蜜桃视频一区二区三区| 九色|91porny| 国产一区二区成人久久免费影院| 黄色成人免费在线| 国产福利一区在线观看| 日韩欧美国产高清| 日韩精品中文字幕在线不卡尤物 | 国产精品一区二区x88av| 五月天亚洲精品| 一区二区三区91| 亚洲另类在线一区| 一区二区三区免费观看| 亚洲韩国精品一区| 五月婷婷久久综合| 精品一区二区三区视频| 国产一区二区三区四区五区入口| 国产精品白丝av| av在线播放一区二区三区| 91色九色蝌蚪| 欧美色网一区二区| 欧美一卡2卡三卡4卡5免费| 日韩欧美一区二区在线视频| 亚洲精品在线免费播放| 国产丝袜美腿一区二区三区| 亚洲国产精品成人久久综合一区| 成人免费小视频| 亚洲国产日产av| 蜜臀久久久99精品久久久久久| 狠狠色丁香久久婷婷综合_中| 成人激情小说网站| 欧美日韩午夜影院| 日韩久久精品一区| 国产精品久久久久精k8| 三级久久三级久久久| 国产毛片精品视频| 色www精品视频在线观看| 制服.丝袜.亚洲.另类.中文 | 亚洲国产精品激情在线观看| 一区二区久久久久久| 免费成人在线网站| 成人91在线观看| 91精品国产色综合久久不卡蜜臀 | 久久久久久久久伊人| 亚洲人精品午夜| 久久精品国产秦先生| 91丨国产丨九色丨pron| 91精品国产高清一区二区三区蜜臀| 久久奇米777| 一二三四社区欧美黄| 国产在线精品一区二区不卡了| 91色porny| 久久先锋影音av鲁色资源| 亚洲综合999| 成人午夜私人影院| 欧美一卡2卡三卡4卡5免费| 亚洲天天做日日做天天谢日日欢| 免费观看在线色综合| 91无套直看片红桃| 久久九九国产精品| 日本成人中文字幕在线视频| 91在线一区二区三区| 久久综合给合久久狠狠狠97色69| 亚洲一区二区在线观看视频| 国产suv精品一区二区三区| 欧美一级久久久| 一区二区三区在线视频播放| 国产91精品精华液一区二区三区| 欧美日韩国产bt| 亚洲人午夜精品天堂一二香蕉| 国产成人av电影在线观看| 日韩欧美自拍偷拍| 日韩av一区二| 欧美色精品在线视频| 亚洲欧美日韩国产综合| 不卡区在线中文字幕| 久久人人97超碰com| 久久精品国产亚洲5555| 制服视频三区第一页精品| 亚洲成av人片在www色猫咪| 色婷婷av一区二区三区软件| 亚洲欧洲精品天堂一级| 白白色 亚洲乱淫| 中文字幕免费一区| 国产999精品久久| 久久久99免费| 国产成人鲁色资源国产91色综| 精品成人a区在线观看| 久色婷婷小香蕉久久| 欧美一区二区视频在线观看2020| 亚洲成人www| 欧美精品久久天天躁| 亚洲妇熟xx妇色黄| 欧美日韩精品欧美日韩精品一综合 | 91国偷自产一区二区三区成为亚洲经典| 久久久午夜电影| 国产精品正在播放| 国产三级久久久| 成人午夜av影视| 国产精品久久久久久久蜜臀| voyeur盗摄精品| 亚洲免费av在线| 欧美色网站导航| 免费一级片91| 精品国产亚洲在线| 国产成人免费视频网站高清观看视频| 久久精品亚洲国产奇米99| 成人看片黄a免费看在线| 亚洲日穴在线视频| 欧美网站一区二区| 麻豆一区二区99久久久久| 久久综合久久综合久久| 国产99久久久国产精品| 亚洲美女精品一区| 欧美探花视频资源| 久久99日本精品| 国产精品嫩草影院av蜜臀| 91日韩在线专区| 日韩中文欧美在线| 精品美女在线观看| av高清不卡在线| 亚洲mv大片欧洲mv大片精品| 精品毛片乱码1区2区3区| 国产精品白丝jk白祙喷水网站| 亚洲欧美在线高清| 欧美精品 国产精品| 国产一区二区在线免费观看| 中文字幕第一区综合| 欧美色成人综合| 激情五月激情综合网| 亚洲欧美日韩国产成人精品影院| 91麻豆精品国产91久久久久久久久 | 水蜜桃久久夜色精品一区的特点| 日韩免费福利电影在线观看| 国产河南妇女毛片精品久久久| 亚洲精品v日韩精品| 亚洲精品一线二线三线无人区| 91视频国产观看| 精品一二三四区| 一个色妞综合视频在线观看| 欧美精品一区二区在线观看| 日本韩国欧美在线| 黑人精品欧美一区二区蜜桃| 亚洲品质自拍视频网站| 欧美精品一区二区三区在线播放| 99re成人精品视频| 精品亚洲porn| 亚洲国产成人av网| 中文一区二区在线观看| 7878成人国产在线观看| 99re热这里只有精品视频| 另类人妖一区二区av| 一区二区三区日韩| 久久久久久免费| 欧美一三区三区四区免费在线看| av在线这里只有精品| 国产米奇在线777精品观看| 午夜精品久久久久久不卡8050| 国产精品―色哟哟|