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

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

?? adminclient.java

?? 21天學(xué)通J2EE的例子4
?? 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.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();
	}

}


?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲欧美日韩在线| 26uuu久久天堂性欧美| 91精品欧美久久久久久动漫| 日韩免费在线观看| 国产精品久久久久三级| 亚洲第一成年网| 国产盗摄一区二区| 欧美日韩中字一区| 久久久久久麻豆| 亚洲综合男人的天堂| 激情小说欧美图片| 色狠狠综合天天综合综合| 欧美一区二区三区啪啪| 国产视频一区在线播放| 亚洲成人你懂的| 国产成人av影院| 欧美日韩一二三区| 国产精品乱码妇女bbbb| 免费日韩伦理电影| 色婷婷激情综合| 久久久噜噜噜久噜久久综合| ●精品国产综合乱码久久久久| 蜜桃av一区二区| 91黄视频在线观看| 中文字幕av一区二区三区高| 视频一区欧美精品| av不卡免费电影| 2019国产精品| 偷拍一区二区三区| 日本韩国欧美在线| 欧美国产日本韩| 久草热8精品视频在线观看| 91黄色在线观看| 国产精品欧美综合在线| 久久99国产精品麻豆| 欧美日韩视频专区在线播放| 中文字幕一区二区三区不卡在线| 蜜桃av噜噜一区| 欧美另类久久久品| 亚洲激情中文1区| av福利精品导航| 久久久.com| 国产自产v一区二区三区c| 制服.丝袜.亚洲.中文.综合| 亚洲男同性视频| 不卡一区二区中文字幕| 国产夜色精品一区二区av| 精品一区在线看| 91精品国产综合久久久久| 一区二区三区四区中文字幕| 成人av免费观看| 亚洲国产精品国自产拍av| 韩国欧美国产1区| 欧美α欧美αv大片| 奇米888四色在线精品| 欧美日韩一区三区| 亚洲一区二区三区视频在线| 色欧美日韩亚洲| 亚洲同性同志一二三专区| 懂色av一区二区在线播放| 国产人久久人人人人爽| 国产伦理精品不卡| 欧美精品一区二区三区在线播放| 日本成人超碰在线观看| 欧美二区乱c少妇| 日韩中文字幕区一区有砖一区| 欧美午夜一区二区三区免费大片| 一区二区三区四区激情| 91福利视频久久久久| 亚洲美女淫视频| 欧美性淫爽ww久久久久无| 亚洲一区二区三区四区在线 | 亚洲日穴在线视频| 91丝袜呻吟高潮美腿白嫩在线观看| 国产精品视频免费| 成人动漫视频在线| 日韩理论片中文av| 在线免费av一区| 亚洲h动漫在线| 欧美一区二区日韩| 精品一区二区在线视频| 精品国产乱码91久久久久久网站| 国产一区二区三区黄视频| 国产欧美日韩综合精品一区二区| 成人精品免费网站| 亚洲欧美色综合| 欧美日韩黄色一区二区| 日韩国产欧美视频| 久久久三级国产网站| 成人美女视频在线看| 亚洲欧洲制服丝袜| 欧美日韩一本到| 久久99精品国产麻豆不卡| 日本一区二区三区电影| 91老师片黄在线观看| 亚洲主播在线播放| 日韩欧美久久一区| 丁香五精品蜜臀久久久久99网站| 综合av第一页| 欧美一区二区三区婷婷月色| 黄色资源网久久资源365| 国产精品动漫网站| 欧美老肥妇做.爰bbww视频| 久久精品久久精品| 国产精品伦理在线| 欧美人成免费网站| 国产另类ts人妖一区二区| 亚洲色图欧美激情| 777奇米成人网| 国产成人h网站| 亚洲一本大道在线| 久久伊99综合婷婷久久伊| 99精品国产视频| 蜜臀av性久久久久蜜臀aⅴ四虎| 久久久久久久久久久久电影| 色婷婷久久综合| 狠狠色丁香久久婷婷综合_中| 国产精品国产自产拍高清av| 欧美日韩国产首页| 福利一区二区在线观看| 亚洲成人综合网站| 国产精品乱人伦| 欧美一区二区三区啪啪| 97久久久精品综合88久久| 欧美a级一区二区| ...xxx性欧美| 26uuu精品一区二区| 欧美伊人久久久久久午夜久久久久| 国产在线视频一区二区| 亚洲高清一区二区三区| 国产精品视频麻豆| 91精品在线麻豆| 91在线国产观看| 国产综合成人久久大片91| 亚洲第一成年网| 国产精品久久久久久久久久免费看 | 欧美成人艳星乳罩| 在线视频国产一区| 国产成人免费视| 麻豆精品蜜桃视频网站| 一卡二卡三卡日韩欧美| 欧美极品美女视频| 日韩精品一区二区三区蜜臀| 欧美性色黄大片| 波多野结衣精品在线| 久久av资源网| 无吗不卡中文字幕| 亚洲黄色尤物视频| 国产精品二三区| 国产欧美日韩一区二区三区在线观看| 欧美一区二区人人喊爽| 91久久免费观看| www.欧美.com| 国产成人精品免费看| 国内成人免费视频| 麻豆中文一区二区| 丝袜a∨在线一区二区三区不卡| 亚洲欧美综合色| 日本一二三不卡| 国产亚洲精品aa| 欧美精品一区二区三区在线| 在线电影院国产精品| 欧美性大战xxxxx久久久| 色狠狠一区二区| 91蜜桃传媒精品久久久一区二区| 成人动漫av在线| 成人福利视频网站| 成人91在线观看| av亚洲精华国产精华| 成人高清av在线| 99久久婷婷国产综合精品电影| 成人综合在线观看| 国产高清一区日本| 国产精品1024| 成人免费看片app下载| 国产·精品毛片| 国产成人精品亚洲午夜麻豆| 国产精品18久久久久久久久久久久 | 欧美色综合网站| 欧美日本精品一区二区三区| 欧美亚洲图片小说| 欧美性猛片aaaaaaa做受| 欧美日韩一区视频| 欧美日韩国产成人在线免费| 欧美巨大另类极品videosbest | 麻豆91精品视频| 六月丁香婷婷久久| 国产一区二区三区四区在线观看| 国产在线精品一区二区夜色| 韩日av一区二区| 成人黄色免费短视频| 成人avav影音| 欧美性猛片xxxx免费看久爱| 欧美日韩成人综合在线一区二区| 欧美老年两性高潮| 26uuu精品一区二区三区四区在线| 亚洲精品一区二区精华| 亚洲国产成人在线| 一区二区三区四区中文字幕| 天天av天天翘天天综合网|