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

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

?? adminclient.java

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

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

public class AdminClient extends JPanel implements ActionListener, ListSelectionListener
{
	public static void main(String[] args) {
		if (args.length!=0 && args.length!=1) {
			System.err.println("Usage: AdminClient AgencyJNDI");
			System.exit(1);
		}
		final JFrame window = new JFrame("Agency Table Browser");
		try {
			final AdminClient client = new AdminClient(args.length==1?args[0]: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 Agency agency;
	
	private JList applicants;
	private JList customers;
	private DefaultListModel skills = new DefaultListModel();
	private JList skillList = new JList(skills);
	private DefaultListModel locations = new DefaultListModel();
	private JList locationList = new JList(locations);

	private FixedField descLocation = new FixedField(16);
	private FixedField locationDescription = new FixedField(16);
	private FixedField newLocation = new FixedField(16);
	private FixedField newLocationDescription = new FixedField(16);
	private JButton updateLocationButton = new JButton("Update");
	private JButton addLocationButton = new JButton("Add");
	private JButton removeLocationButton = new JButton("Remove");

	private FixedField descSkill = new FixedField(16);
	private FixedField skillDescription = new FixedField(16);
	private FixedField newSkill = new FixedField(16);
	private FixedField newSkillDescription = new FixedField(16);
	private JButton updateSkillButton = new JButton("Update");
	private JButton addSkillButton = new JButton("Add");
	private JButton removeSkillButton = new JButton("Remove");

	public AdminClient(String agencyJNDI) {
		if (agencyJNDI != null)
			this.agencyJNDI = agencyJNDI;
		try
		{
			setLayout(new BoxLayout(this,BoxLayout.Y_AXIS));
			agency = getAgency(this.agencyJNDI);
			loadTables(agency);
			add(topPanel());
			add(Box.createVerticalStrut(5));
			add(midPanel());
			add(Box.createVerticalStrut(5));
			add(bottomPanel());

			locationList.addListSelectionListener(this);
			skillList.addListSelectionListener(this);
			
			updateLocationButton.addActionListener(this);
			addLocationButton.addActionListener(this);
			removeLocationButton.addActionListener(this);
			updateSkillButton.addActionListener(this);
			addSkillButton.addActionListener(this);
			removeSkillButton.addActionListener(this);

			descLocation.setEnabled(false);
			descSkill.setEnabled(false);
			updateLocationButton.setEnabled(false);
			updateSkillButton.setEnabled(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 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 topPanel() {
		JPanel c = boxPanel("Customers");
		customers.setVisibleRowCount(4);
		c.add (new JScrollPane(customers));

		JPanel a = boxPanel("Applicants");
		applicants.setVisibleRowCount(4);
		a.add (new JScrollPane(applicants));

		JPanel p = new JPanel(new GridLayout(1,2));
		p.add (c);
		p.add (a);
		return p;
	}

	private JPanel midPanel() {
		locationList.setVisibleRowCount(4);
		JPanel l = boxPanel("Locations");
		l.add (new JScrollPane(locationList));
		l.add (removeLocationButton);
		
		JPanel m = boxPanel("Select Location");
		m.add (descLocation);
		m.add (new FixedLabel("Description:"));
		m.add (locationDescription);
		m.add (updateLocationButton);

		JPanel r = boxPanel("New location");
		m.add (new FixedLabel("Name:"));
		r.add (newLocation);
		r.add (new FixedLabel("Description:"));
		r.add (newLocationDescription);
		r.add (addLocationButton);

		JPanel all = new JPanel(new GridLayout(1,3));
		all.add(l);
		all.add(m);
		all.add(r);
		return all;
	}

	private JPanel bottomPanel() {
		skillList.setVisibleRowCount(4);		
		JPanel l = boxPanel("Skills");
		l.add (new JScrollPane(skillList));
		l.add (removeSkillButton);
		
		JPanel m = boxPanel("Select Skill");
		m.add (descSkill);
		m.add (new FixedLabel("Description:"));
		m.add (skillDescription);
		m.add (updateSkillButton);

		JPanel r = boxPanel("New skill");
		r.add (new FixedLabel("Name:"));
		r.add (newSkill);
		r.add (new FixedLabel("Description:"));
		r.add (newSkillDescription);
		r.add (addSkillButton);

		JPanel all = new JPanel(new GridLayout(1,3));
		all.add(l);
		all.add(m);
		all.add(r);
		return all;
	}
   
	public void actionPerformed(ActionEvent ev) {
		try {
			Object o = ev.getSource();
			if (o==updateLocationButton) {
				doUpdateLocation(agency);
			}
			else if (o==addLocationButton) {
				doAddLocation(agency);
			}
			else if (o==removeLocationButton) {
				doRemoveLocation(agency);
			}
			else if (o==updateSkillButton) {
				doUpdateSkill(agency);
			}
			else if (o==addSkillButton) {
				doAddSkill(agency);
			}
			else if (o==removeSkillButton) {
				doRemoveSkill(agency);
			}
			else
				warning("Unknown event","Unknown event: "+ev);
			validate();
		}
		catch (NotFoundException ex) {
			error("actionPerformed",ex.toString());
			ex.printStackTrace();
		}
		catch (DuplicateException ex) {
			error("actionPerformed",ex.toString());
			ex.printStackTrace();
		}
		catch (RemoteException ex) {
			error("actionPerformed",ex.toString());
			ex.printStackTrace();
		}
	}

	public void valueChanged(ListSelectionEvent ev) {
		if (!ev.getValueIsAdjusting() || ev.getFirstIndex()==-1)
			return;
		try {			
			Object o = ev.getSource();
			if (o==locationList) {
				doLocationDescription(agency);			
			}
			else if (o==skillList) {
				doSkillDescription(agency); 		
			}
			else
				warning("Unknown list event","Unknown event: "+ev);
		}
		catch (NotFoundException ex) {
			error("actionPerformed",ex.toString());
			ex.printStackTrace();
		}
		catch (RemoteException ex) {
			error("actionPerformed",ex.toString());
			ex.printStackTrace();
		}
	}
	
	public void shutdown() {
		try {
			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 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 boolean isNull (String s) {
		return s==null || s.length()==0;
	}
	
	private boolean isNull (JTextComponent c) {
		return isNull(c.getText());
	}

	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;}
	}

	// 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 {
		customers = new JList(agency.getCustomers().toArray());
		applicants = new JList(agency.getApplicants().toArray());
		locations.clear();
		Iterator it = agency.getLocations().iterator();
		while (it.hasNext())
			locations.addElement(it.next());
		skills.clear();
		it = agency.getSkills().iterator();
		while (it.hasNext())
			skills.addElement(it.next());

	}

	private void doLocationDescription(Agency agency) throws RemoteException, NotFoundException {
		Object[] location = (locationList.getSelectedValues());
		if (location.length != 1)
		{
			descLocation.setText("");
			locationDescription.setText("");
			locationDescription.setEnabled(false);
		}
		else
		{
			descLocation.setText((String)location[0]);
			locationDescription.setText(agency.getLocationDescription((String)location[0]));
			locationDescription.setEnabled(true);
		}
		updateLocationButton.setEnabled(location.length==1);
	}

	private void doUpdateLocation(Agency agency) throws RemoteException, NotFoundException {
		Object[] location = (locationList.getSelectedValues());
		if (location.length != 1)
			warning ("No Location","You must select a single Location to update the description");
		agency.updateLocation((String)location[0],locationDescription.getText());
	}

	private void doAddLocation(Agency agency) throws RemoteException, DuplicateException {
		if (isNull(newLocation))
			warning ("No Location","You must enter a name for the new Location");
		String s = newLocation.getText();
		
		if (!locations.contains(s)) {
			agency.addLocation(s,newLocationDescription.getText());
			locations.addElement(s);
			locationList.invalidate();
			newLocation.setText("");
			newLocationDescription.setText("");
		}
		else
			warning ("Duplicate Location",s+" already defined");
	}

	private void doRemoveLocation(Agency agency) throws RemoteException, NotFoundException {
		Object[] location = (locationList.getSelectedValues());
		if (location.length == 0)
			warning ("No Location","You must select a Location to remove from the Locations list");
		for (int i=0; i<location.length; i++) {
			if (locations.contains(location[i])) {
				agency.removeLocation((String)location[i]);
				locations.removeElement(location[i]);
			}
		}
		descLocation.setText("");
		locationDescription.setText("");
		locationList.invalidate();
	}
	
	private void doSkillDescription(Agency agency) throws RemoteException, NotFoundException {
		Object[] skill = (skillList.getSelectedValues());
		if (skill.length != 1)
		{
			descSkill.setText("");
			skillDescription.setText("");
			skillDescription.setEnabled(false);
		}
		else
		{
			descSkill.setText((String)skill[0]);
			skillDescription.setText(agency.getSkillDescription((String)skill[0]));
			skillDescription.setEnabled(true);
		}
		updateSkillButton.setEnabled(skill.length==1);
	}

	private void doUpdateSkill(Agency agency) throws RemoteException, NotFoundException {
		Object[] skill = (skillList.getSelectedValues());
		if (skill.length != 1)
			warning ("No Location","You must select a single Location to update the description");
		agency.updateSkill((String)skill[0],skillDescription.getText());
	}

	private void doAddSkill(Agency agency) throws RemoteException, DuplicateException {
		if (isNull(newSkill))
			warning ("No skill","You must enter a name for the new skill");
		String s = newSkill.getText();
		
		if (!skills.contains(s)) {
			agency.addSkill(s,newSkillDescription.getText());
			skills.addElement(s);
			skillList.invalidate();
			newSkill.setText("");
			newSkillDescription.setText("");
		}
		else
			warning ("Duplicate skill",s+" already defined");
	}

	private void doRemoveSkill(Agency agency) throws RemoteException, NotFoundException {
		Object[] skill = (skillList.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])) {
				agency.removeSkill((String)skill[i]);
				skills.removeElement(skill[i]);
			}
		}
		descSkill.setText("");
		skillDescription.setText("");
		skillList.invalidate();
	}

}


?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产一区二区精品久久99| 欧美午夜片在线观看| 91网站在线播放| 欧美丰满嫩嫩电影| 中文字幕永久在线不卡| 久久精品国产免费看久久精品| 99久久99久久精品免费观看| 精品国产一区二区亚洲人成毛片| 亚洲一区二区综合| 99视频在线观看一区三区| 久久免费看少妇高潮| 六月婷婷色综合| 欧美日韩国产一级二级| 亚洲一区免费视频| 在线一区二区三区| 亚洲免费在线观看| 成年人午夜久久久| 亚洲国产精品国自产拍av| 韩国精品免费视频| 日韩精品中文字幕在线不卡尤物 | 日韩一区二区在线观看视频播放| 亚洲另类中文字| 91在线观看高清| 国产精品久久久久7777按摩| 国产激情视频一区二区在线观看| 久久综合五月天婷婷伊人| 国内精品久久久久影院色| 欧美tickling网站挠脚心| 日本aⅴ精品一区二区三区| 91精品国产一区二区三区| 日韩国产精品久久久| 69成人精品免费视频| 婷婷中文字幕一区三区| 欧美久久久久中文字幕| 日韩av高清在线观看| 精品国产免费人成电影在线观看四季 | 蜜乳av一区二区| 欧美一区二区网站| 久久99精品国产| 久久综合网色—综合色88| 风间由美一区二区av101| 国产精品美女视频| 91亚洲精华国产精华精华液| 亚洲一区二区三区自拍| 欧美午夜在线一二页| 日韩精品一级中文字幕精品视频免费观看 | 久久久久亚洲蜜桃| 不卡一区二区在线| 午夜精品久久久久久| 欧美一级二级在线观看| 狠狠色狠狠色综合日日91app| 国产亚洲欧洲一区高清在线观看| 成人免费三级在线| 亚洲综合色自拍一区| 91精品国产丝袜白色高跟鞋| 国产精品18久久久久久久网站| 国产精品毛片大码女人| 欧美日韩一区二区三区在线看 | 国产成人av电影免费在线观看| 国产精品免费aⅴ片在线观看| 欧美午夜精品久久久久久孕妇| 日韩电影在线免费| 国产三级欧美三级日产三级99| 色悠悠久久综合| 麻豆精品一区二区三区| 最近中文字幕一区二区三区| 欧美巨大另类极品videosbest | 日韩电影免费在线看| 国产亚洲短视频| 欧美在线免费观看亚洲| 国内外成人在线| 亚洲综合免费观看高清完整版 | 成a人片国产精品| 日本一不卡视频| 一区视频在线播放| 精品国产免费视频| 欧美日韩高清在线| 不卡一区二区中文字幕| 极品美女销魂一区二区三区免费 | 色吧成人激情小说| 国产一区二区电影| 日本美女一区二区三区视频| 自拍偷拍亚洲综合| 久久久久久久久久久电影| 欧美日韩国产免费| 91在线一区二区| 国产成a人亚洲| 美女在线一区二区| 亚洲第一电影网| 中文字幕日韩一区二区| 久久九九国产精品| 欧美一级黄色片| 欧美高清性hdvideosex| 日本精品一区二区三区四区的功能| 国内久久精品视频| 美女尤物国产一区| 天天影视涩香欲综合网| 亚洲免费av高清| 国产精品久久久99| 国产精品美女久久久久aⅴ国产馆 国产精品美女久久久久av爽李琼 国产精品美女久久久久高潮 | 久久久国产一区二区三区四区小说 | 欧美日韩精品一区二区天天拍小说| 波多野结衣中文一区| 国产成人高清视频| 国产福利不卡视频| 国产精品主播直播| 国产精品一卡二| 国产精品一区二区你懂的| 另类小说欧美激情| 国内一区二区视频| 国产乱码精品一区二区三| 蜜桃免费网站一区二区三区| 男人操女人的视频在线观看欧美| 婷婷丁香激情综合| 调教+趴+乳夹+国产+精品| 日韩精品91亚洲二区在线观看| 亚洲国产综合人成综合网站| 亚洲国产精品一区二区www在线| 亚洲精品老司机| 亚洲国产三级在线| 秋霞午夜av一区二区三区| 日韩高清在线不卡| 精一区二区三区| 国产成人免费视频网站| 播五月开心婷婷综合| 在线观看视频91| 欧美一区二区网站| 国产午夜精品一区二区| 国产区在线观看成人精品| 日本一二三不卡| 一卡二卡欧美日韩| 蜜臀av性久久久久蜜臀aⅴ流畅| 国产毛片一区二区| 成人99免费视频| 欧美性高清videossexo| 日韩欧美黄色影院| 国产日产精品1区| 亚洲午夜精品一区二区三区他趣| 日本一道高清亚洲日美韩| 国产精品亚洲成人| 91福利精品视频| 日韩午夜激情av| 国产精品欧美久久久久无广告| 亚洲一区二区三区美女| 精品影院一区二区久久久| 99re视频精品| 91精品国产色综合久久| 国产精品天干天干在线综合| 亚洲在线一区二区三区| 国产综合久久久久久久久久久久| av中文一区二区三区| 91精品国产福利| 欧美韩国日本不卡| 午夜精品一区在线观看| 顶级嫩模精品视频在线看| 欧美日韩极品在线观看一区| 久久网这里都是精品| 亚洲国产日韩a在线播放性色| 极品美女销魂一区二区三区免费| 欧美亚洲国产一卡| 国产精品午夜在线| 日本不卡视频在线| 91国偷自产一区二区三区观看 | 国产一区二区毛片| 欧美精品久久99久久在免费线 | 国产情人综合久久777777| 午夜成人免费电影| 91麻豆文化传媒在线观看| 久久女同互慰一区二区三区| 日韩电影网1区2区| 欧美亚洲动漫精品| 亚洲欧洲一区二区三区| 国产成人在线观看| 日韩一区国产二区欧美三区| 一区二区三区欧美久久| 成人午夜精品在线| 久久美女艺术照精彩视频福利播放| 日韩精品电影在线| 欧美日韩精品一区二区三区| 亚洲视频在线一区观看| 国产a视频精品免费观看| 精品久久久三级丝袜| 日韩电影免费一区| 欧美日韩精品一区二区在线播放 | 久久电影网电视剧免费观看| 在线免费亚洲电影| 一区二区三区四区视频精品免费| 懂色一区二区三区免费观看| 精品国产免费一区二区三区四区 | 亚洲欧美在线另类| 大美女一区二区三区| 久久久久亚洲综合| 国产一区 二区 三区一级| 欧美精品一区二区精品网| 久久99精品一区二区三区| 91精品在线免费观看| 婷婷六月综合亚洲| 日韩一区二区三区观看| 久久精品二区亚洲w码| 欧美v日韩v国产v|