We are trying to implement a GUI in Jtcl. Its a java application which runs
a tcl script when the buttons are pressed. How should i pass the used
entered parameters in the GUI to my tcl script my_script.tcl? Please help
The code i have written is :
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import tcl.lang.*;
public class Ep {
public static void main(String [] args)
{
Frame frame = new Frame("EndPoint Creation");
Container cnt = new Container();
cnt.setLayout(null);
Label lab1=new Label("Camserver_IP: ");
TextField text1=new TextField();
Label lab2=new Label("CCM_IP: ");
TextField text2=new TextField();
Label lab3=new Label("Camport: ");
final TextField text3=new TextField();
Label lab4=new Label("Protocol: ");
TextField text4=new TextField();
List list=new List(2,false);
list.add("sipx");
list.add("skinny");
Label lab5=new Label("Mac_Address: ");
TextField text5=new TextField();
Button but1=new Button("Inservice");
Button but2=new Button("OutofService");
TextArea area=new TextArea();
Button but3=new Button("GetStatus");
lab1.setBounds(15,20,80,20);
text1.setBounds(105,20,100,20);
lab2.setBounds(15,50,80,20);
text2.setBounds(105,50,100,20);
lab3.setBounds(15,80,80,20);
text3.setBounds(105,80,100,20);
lab4.setBounds(15,110,80,20);
list.setBounds(105,110,100,40);
lab5.setBounds(15,180,100,20);
text5.setBounds(105,180,100,20);
but1.setBounds(50,210,80,20);
but2.setBounds(200,210,80,20);
area.setBounds(15,240,300,70);
but3.setBounds(135,340,80,20);
cnt.add(lab1);
cnt.add(text1);
cnt.add(lab2);
cnt.add(text2);
cnt.add(lab3);
cnt.add(text3);
cnt.add(lab4);
cnt.add(list);
cnt.add(lab5);
cnt.add(text5);
cnt.add(but1);
cnt.add(but2);
cnt.add(but3);
cnt.add(area);
frame.add(cnt);
frame.setSize(350,400);
frame.setVisible(true);
frame.toFront();
but1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
//Execute when button is pressed
System.out.println("You clicked the button");
int camport=10;
//String str=new String();
//str=text3.getText();
//System.out.println(str);
Interp i = new Interp();
try {
i.eval("source my_script.tcl");
i.eval("puts $camport");
i.dispose();
} catch (TclException eee) {
System.out.println("Exeption:" + eee.getMessage());
i.dispose();
}
}
});
}
}
|