Clip Board Problem
Hey
I'm looking for some help with the below code, As far as i can gather the code for the clip board is correct as i have it working in simple Jframe and it is working right.
I just cant get it to wotk on the code below, i had other methods in the action preformed, but i've taken them out so its easier to read. If any one can see the problem it would be great. The only error that i am getting is for the dimension size, but it jframe runs fine even with that.
Thanks
Ambrose
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import java.awt.datatransfer.*;
publicclass Sending_Mailextends JFrameimplements ActionListener, ClipboardOwner
{
private JButton b2;
private JButton b1;
private JTextArea ta1;
private JLabel lb1;
private JTextArea ta2;
private JLabel lb2;
private JTextArea ta3;
private JLabel lb3;
private JTextField t1;
private JLabel lb4;
private JLabel lb5;
private JTextField t2;
private JLabel lb6;
private JTextField t3;
private JComboBox cb1;
/*int rows = 20;
int cols = 30;
textarea = new JTextArea("Initial Text", rows, cols);*/
public String a ="Router A";
public String b ="Router B";
public String a_b ="A-B = 20 \nA-D-B = 30 \nA-C-B = 40 \nA-C-D-B = 50 \nA-D-E-C-B = 60";
public String b_a ="B-A / B-C-A / B-D-A / B-D-E-C-A / B-C-D-E-A";
publicint a_b1 = 100;
publicint b_a1 = 200;
publicint A_B = 100;
publicint A_D_B = 300;
publicint A_C_B = 250;
publicint A_C_D_B = 400;
publicint A_D_E_C_B = 500;
public Sending_Mail(){
//construct components
String[] jcomp7Items ={"Ireland","IP 1","IP 2","IP 3","IP 4","IP 5","America","IP1","IP2","IP3"};
b2 =new JButton ("Exit Application");
b1 =new JButton ("Main Menu");
ta1 =new JTextArea (3,10);
lb1 =new JLabel (" All Available Routes");
//Line Wrap
ta2 =new JTextArea ("Some\nInitial\nText", 3, 10);
ta2.setLineWrap(true);
lb2 =new JLabel (" Progress of E-mail");
ta3 =new JTextArea (3,10);
lb3 =new JLabel (" User Information");
t1 =new JTextField (5);
lb4 =new JLabel (" E-mail Size");
lb5 =new JLabel (" Sender Router");
t2 =new JTextField (5);
lb6 =new JLabel (" Destination Router");
t3 =new JTextField (5);
//set components properties
b2.setToolTipText ("Allows the User to exit the Application");
b1.setToolTipText ("Returns the User to the Main Menu");
ta1.setToolTipText ("Shows a List of all Available Routes");
ta2.setToolTipText ("Progress of Routing Algorthnm");
ta3.setToolTipText ("Tells the User whats Going on");
t1.setToolTipText ("Shows the size of the E-Mail Created Earlier");
t3.setToolTipText ("The Destination of the Router");
//adjust size and set layout
setPreferredSize (new Dimension (750, 480));
setLayout (null);
//add components
add (b2);
add (b1);
add (ta1);
add (lb1);
add (ta2);
add (lb2);
add (ta3);
add (lb3);
add (t1);
add (lb4);
add (lb5);
add (t2);
add (lb6);
add (t3);
//add (cb1);
//set component bounds (only needed by Absolute Positioning)
//Exit Application
b2.setBounds (255, 405, 140, 20);
//Main Menu
b1.setBounds (55, 405, 140, 20);
ta1.setBounds (360, 55, 150, 255);
lb1.setBounds (360, 20, 150, 25);
ta2.setBounds (185, 55, 150, 255);
lb2.setBounds (185, 20, 150, 25);
ta3.setBounds (10, 55, 150, 255);
lb3.setBounds (10, 20, 150, 25);
t1.setBounds (535, 55, 100, 25);
lb4.setBounds (530, 20, 95, 25);
lb5.setBounds (530, 100, 130, 25);
t2.setBounds (535, 130, 100, 25);
lb6.setBounds (535, 160, 125, 25);
t3.setBounds (535, 195, 100, 25);
//cb1.setBounds(25,600,95,20);
b1.addActionListener(this);
b2.addActionListener(this);
t3.addActionListener(this);
/*b4.addActionListener(this);
t5.addActionListener(this);*/
}
publicvoid lostOwnership(Clipboard cb, Transferable tr){};
publicvoid actionPerformed(ActionEvent event)
{
String cliptext = t1.getText();
Toolkit tk = this.getToolkit();
Clipboard cb = tk.getSystemClipboard();
cb.setContents(new StringSelection(cliptext),this);
}// public void actionPerformed()
publicstaticvoid main (String[] args){
Sending_Mail application =new Sending_Mail();
application.setDefaultCloseOperation(
JFrame.EXIT_ON_CLOSE );
/*JFrame frame = new JFrame ("Sending_Mail");
frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add (new Sending_Mail());
frame.pack();
frame.setVisible (true);*/
}
}

