/*------------------------------------------- 3/4/2000 --------------------------------------------*/ /* ***************************************************************************** Copyright 2000 by Erica Andrews (cylikon@hotmail.com). All rights reserved. ./ButchWhipAppeal/ ./IcedPinky/ NO portion of this software may be used in ANY way by anyone other than myself without my express written consent. If it is downloaded for testing, it must be deleted from your system within 24 hours. Any other use constitutes piracy and fraudulent misuse of this software, punishable in a court of law. Copyright 2000 by Erica Andrews. All rights reserved. ***************************************************************************** */ import javax.swing.border.*; import java.net.*; import java.awt.*; import javax.swing.*; import java.awt.event.*; import java.util.*; import org.omg.CORBA.*; import java.io.*; public class CorbaMailClient extends JFrame { public static ClientPanel2 cp; public CorbaMailClient() { setTitle("CorbaMail Client"); setBounds(new Rectangle(130,90,516,395)); setSize(466,322); setBackground(new Color(226,0,0)); cp = new ClientPanel2(); getContentPane().add(cp); // pack(); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { hide(); dispose(); System.exit(0); } public void windowOpened(WindowEvent e) { resize(466,322); repaint(); cp.repaint(); } } ); show(); setResizable(false); } //end super method public static void main (String args[]) { new CorbaMailClient(); } } //end of class CorbaMailCLient // ********************MAIN PANEL************************* class ClientPanel2 extends JPanel { // Instance variables public JTextField jtextfield1; public JTextField jtextfield3; public JButton jbutton0; public JLabel jlabel0; public JLabel jlabel1; public TextArea textarea0; public ClientPanel2() { // Setup GUI this.setBounds(10,6,458,302); this.setSize(new Dimension(458,302)); this.setPreferredSize(new Dimension(1,1)); Border thisBorder0 = new EtchedBorder(); this.setBorder(thisBorder0); this.setName("this"); this.setLocation(new Point(10,6)); this.setMinimumSize(new Dimension(1,1)); this.setToolTipText("CorbaMail Client"); this.setBounds(new Rectangle(10,6,458,302)); this.setForeground(new Color(149,0,207)); this.setBackground(new Color(176,0,0)); this.setLayout(null); jtextfield1 = new JTextField(); jtextfield1.setPreferredSize(new Dimension(82,21)); jtextfield1.setSelectionEnd(13); jtextfield1.setToolTipText("Enter YOUR email address."); jtextfield1.setBounds(new Rectangle(87,16,199,21)); Border jtextfield1Border0 = new BevelBorder(1); jtextfield1.setBorder(jtextfield1Border0); jtextfield1.setSize(new Dimension(199,21)); jtextfield1.setName("jtextfield1"); jtextfield1.setForeground(new Color(255,255,255)); jtextfield1.setText(""); jtextfield1.setBackground(new Color(164,0,0)); jtextfield1.setLocation(new Point(87,16)); this.add(jtextfield1); jtextfield3 = new JTextField(); jtextfield3.setToolTipText("Subject"); jtextfield3.setBounds(new Rectangle(88,49,199,21)); Border jtextfield3Border0 = new BevelBorder(1); jtextfield3.setBorder(jtextfield3Border0); jtextfield3.setSize(new Dimension(199,21)); jtextfield3.setName("jtextfield3"); jtextfield3.setForeground(new Color(255,255,255)); jtextfield3.setBackground(new Color(164,0,0)); jtextfield3.setLocation(new Point(88,49)); jtextfield3.setLayout(null); this.add(jtextfield3); jbutton0 = new JButton(); jbutton0.setPreferredSize(new Dimension(79,45)); jbutton0.setToolTipText("Send"); jbutton0.setBounds(new Rectangle(308,17,143,55)); Border jbutton0Border1 = new EtchedBorder(); Border jbutton0Border0 = new TitledBorder(jbutton0Border1,""); jbutton0.setBorder(jbutton0Border0); jbutton0.setSize(new Dimension(143,55)); jbutton0.setMaximumSize(new Dimension(79,45)); jbutton0.setName("jbutton0"); jbutton0.setForeground(new Color(255,255,255)); jbutton0.setActionCommand("S"); jbutton0.setFont(new java.awt.Font("sansserif", 0, 24)); jbutton0.setText("SEND"); jbutton0.setBackground(new Color(226,0,0)); jbutton0.setMinimumSize(new Dimension(79,45)); jbutton0.setLocation(new Point(308,17)); this.add(jbutton0); // Mouse listener for Button jbutton0.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { SendTheMail(); } } ); jlabel0 = new JLabel(); jlabel0.setPreferredSize(new Dimension(47,24)); jlabel0.setBounds(new Rectangle(9,15,82,24)); jlabel0.setSize(new Dimension(82,24)); jlabel0.setMaximumSize(new Dimension(47,24)); jlabel0.setName("jlabel0"); jlabel0.setForeground(new Color(255,255,255)); jlabel0.setFont(new java.awt.Font("Arial", 1, 18)); jlabel0.setText("From:"); jlabel0.setMinimumSize(new Dimension(47,24)); jlabel0.setLocation(new Point(9,15)); jlabel0.setLayout(null); this.add(jlabel0); jlabel1 = new JLabel(); jlabel1.setPreferredSize(new Dimension(63,24)); jlabel1.setBounds(new Rectangle(9,48,84,23)); jlabel1.setSize(new Dimension(84,23)); jlabel1.setMaximumSize(new Dimension(63,24)); jlabel1.setName("jlabel1"); jlabel1.setForeground(new Color(255,255,255)); jlabel1.setFont(new java.awt.Font("Arial", 1, 18)); jlabel1.setText("Subject:"); jlabel1.setMinimumSize(new Dimension(63,24)); jlabel1.setLocation(new Point(9,48)); jlabel1.setLayout(null); this.add(jlabel1); textarea0 = new TextArea(); textarea0.setSize(new Dimension(440,190)); textarea0.setName("textarea0"); textarea0.setLocation(new Point(9,93)); textarea0.setText(""); textarea0.setBounds(new Rectangle(9,93,440,190)); textarea0.setForeground(new Color(255,255,255)); textarea0.setBackground(new Color(164,0,0)); textarea0.setFont(new java.awt.Font("Arial", 1, 14)); this.add(textarea0); } URL getURL(String txtURL) { // return a URL object given the URL try { if (txtURL == null) return new URL("file://"); else return new URL(txtURL); } catch(MalformedURLException mue) { return null; } } public String[][] getIconPathForComponent(Component comp, String methodName) { // return an Icon path(s) for a given Component/Method { String[][] rval = {{null}}; return rval; } } private String getReference(String[][] references, String methodName) { for (int i = 0; i < references.length; i++) if (references[i][0] == methodName) return references[i][1]; return null; } public void SendTheMail() { new MailerFrame(); } } // end of class Client Panel // ***********************DIALOG BOX PANEL******************************* class MailDialog2 extends JPanel { public static Color colors0190[] = { new Color(0,0,0) }; // Instance variables public TextArea jtextarea0; public JLabel jlabel0; public JButton jbutton0; public MailDialog2() { // Setup GUI this.setBounds(120,85,197,152); this.setSize(new Dimension(197,152)); this.setPreferredSize(new Dimension(1,1)); Border thisBorder0 = new EtchedBorder(); this.setBorder(thisBorder0); this.setName("this"); this.setLocation(new Point(120,85)); this.setMinimumSize(new Dimension(1,1)); this.setToolTipText("Mail Results"); this.setBounds(new Rectangle(120,85,197,152)); this.setForeground(new Color(166,0,0)); this.setBackground(new Color(255,255,255)); this.setLayout(null); jtextarea0 = new TextArea(); jtextarea0.setSize(new Dimension(187,90)); jtextarea0.setName("jtextarea0"); jtextarea0.setLocation(new Point(4,31)); jtextarea0.setBounds(new Rectangle(4,31,187,90)); jtextarea0.setForeground(new Color(0,0,0)); jtextarea0.setBackground(new Color(240,240,240)); jtextarea0.setEditable(false); jtextarea0.setFont(new java.awt.Font("dialog", 0, 12)); this.add(jtextarea0); jlabel0 = new JLabel(); jlabel0.setPreferredSize(new Dimension(102,24)); jlabel0.setBounds(new Rectangle(7,3,183,22)); jlabel0.setSize(new Dimension(183,22)); jlabel0.setMaximumSize(new Dimension(102,24)); jlabel0.setName("jlabel0"); jlabel0.setForeground(new Color(171,173,255)); jlabel0.setFont(new java.awt.Font("Arial", 1, 18)); jlabel0.setText(" Mail Results"); jlabel0.setBackground(new Color(255,255,255)); jlabel0.setHorizontalAlignment(0); jlabel0.setMinimumSize(new Dimension(102,24)); jlabel0.setLocation(new Point(7,3)); jlabel0.setLayout(null); this.add(jlabel0); jbutton0 = new JButton(); jbutton0.setPreferredSize(new Dimension(33,33)); jbutton0.setBounds(new Rectangle(20,122,158,28)); Border jbutton0Border0 = new LineBorder(new Color(0,0,0),1); jbutton0.setBorder(jbutton0Border0); jbutton0.setSize(new Dimension(158,28)); jbutton0.setMaximumSize(new Dimension(33,33)); jbutton0.setName("jbutton0"); jbutton0.setForeground(new Color(171,173,255)); jbutton0.setActionCommand("O"); jbutton0.setFont(new java.awt.Font("sansserif.bold", 1, 14)); jbutton0.setText("OK"); jbutton0.setBackground(new Color(255,255,255)); jbutton0.setMinimumSize(new Dimension(33,33)); jbutton0.setLocation(new Point(20,122)); this.add(jbutton0); } //end super URL getURL(String txtURL) { // return a URL object given the URL try { if (txtURL == null) return new URL("file://"); else return new URL(txtURL); } catch(MalformedURLException mue) { return null; } } public String[][] getIconPathForComponent(Component comp, String methodName) { // return an Icon path(s) for a given Component/Method { String[][] rval = {{null}}; return rval; } } private String getReference(String[][] references, String methodName) { for (int i = 0; i < references.length; i++) if (references[i][0] == methodName) return references[i][1]; return null; } } // end class MailDialog // ****************** DIALOG BOX FRAME ************************* class MailerFrame extends JFrame { public static MailDialog2 md; public MailerFrame() { setTitle("Results"); setBounds(new Rectangle(319,182,520,365)); setSize(210,185); setBackground(new Color(255,255,255)); md = new MailDialog2(); getContentPane().add(md); // pack(); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { hide(); } public void windowOpened(WindowEvent e) { resize(210,185); repaint(); } } ); // also adding a Mouse listener to the jbutton in the MailDialog JPanel(md) to allow the // user to exit the Dialog box // Mouse listener for Button md.jbutton0.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { hide(); dispose(); } } ); String FROM = CorbaMailClient.cp.jtextfield1.getText(); String SUBJECT = CorbaMailClient.cp.jtextfield3.getText(); String MESSAGE = CorbaMailClient.cp.textarea0.getText(); String USERINFO = " Localhost. Sent using the built-in client for LiL CJs CorbaMail software."; // Finally let's send the mail by simply calling the String SendMail in the EJB's Remote // interface. The string will be displayed in the JTextArea of the MailerFrame (the // JTextArea comes from the JPanel created through md = new MailDialog() ). show(); // showing the JFrame repaint(); setResizable(false); md.jtextarea0.setText("Sending Mail..."); // a "wait" message, while we create and bind the client-side orb setTitle("Sending..."); try { // initializing the client-side orb org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init((new String[0]),null); CorbaMail.Mail mailorb = CorbaMail.MailHelper.bind(orb,"MailServer"); // now that the orb has been initialized and bound, we can call the method available // to the mailorb = SendMail(String, String, String, String); // now, we can send the mail and get the mail status message in one action. // The mail will be sent when we set the text for the jtextarea0 md.jtextarea0.setText(mailorb.SendMail(FROM,MESSAGE,SUBJECT,USERINFO)); // mail status message was printed to the textarea setTitle("Results"); } catch (Throwable e) { md.jtextarea0.setText("ERROR:\n"); StringTokenizer st = new StringTokenizer(e.toString(),"#",false); while(st.hasMoreElements()) { String trans = st.nextToken(); md.jtextarea0.appendText(trans+"\n"); } //end while System.out.print(e+e.getMessage()); setTitle("ERROR"); md.setToolTipText("Error Sending Mail. Mail Was Not Sent."); } // end catch // all error messages will be displayed in the small textarea } //end super method } //end of class MailerFrame