【Java开源代码栏目提醒】:本文主要为网学会员提供AdvertiseClient.java,希望对需要AdvertiseClient.java网友有所帮助,学习一下!
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 AdvertiseClient extends JPanel implements ActionListener
{
public static void main(String[] args) {
if (args.length!=0 && args.length!=3) {
System.err.println("Usage: AdvertiseClient AgencyJNDI AdvertiseJNDI AdvertiseJobJNDI");
System.exit(1);
}
final JFrame window = new JFrame("Agency Advertise Job");
try {
final AdvertiseClient client = new AdvertiseClient(args.length==3?args[0]:null, args.length==3?args[1]:null, args.length==3?args[2]: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 advertiseJNDI = "java:comp/env/ejb/Advertise";
private String advertiseJobJNDI = "java:comp/env/ejb/AdvertiseJob";
private Agency agency;
private Advertise advertise;
private AdvertiseJob advertiseJob;
public AdvertiseClient(String agencyJNDI, String advertiseJNDI, String advertiseJobJNDI) {
if (agencyJNDI != null)
this.agencyJNDI = agencyJNDI;
if (advertiseJNDI != null)
this.advertiseJNDI = advertiseJNDI;
if (advertiseJobJNDI != null)
this.advertiseJobJNDI = advertiseJobJNDI;
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);
add (jobPanel(), BorderLayout.SOUTH);
loginButton.addActionListener(this);
logoffButton.addActionListener(this);
registerButton.addActionListener(this);
updateButton.addActionListener(this);
deleteButton.addActionListener(this);
selectJobButton.addActionListener(this);
allJobs.addActionListener(this);
createJobButton.addActionListener(this);
addSkillButton.addActionListener(this);
removeSkillButton.addActionListener(this);
updateJobButton.addActionListener(this);
deleteJobButton.addActionListener(this);
currentJob.setEnabled(false);
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 FixedField address1 = new FixedField(16);
private FixedField address2 = new FixedField(16);
private FixedField newJob = new FixedField(16);
private DefaultComboBoxModel jobs = new DefaultComboBoxModel();
private JComboBox allJobs = new JComboBox();
private FixedField currentJob = new FixedField(16);
private JTextArea description = 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 J