Ich hoffe mir kann jemand helfen:
Ich möchte mittels Jlink ein neues Fenster (Swing) erstellen. In dem Fenster befindet sich 1 Button der mir 2 Parameter ans Pro-E übergeben soll (Model_Type, Model_Name)! Er bleibt aber in dem Java-Fenster stehen und rührt sich nicht mehr!
Hier mein Code:
public void new_window() [wird von einem Menü aufgerufen]
{
JFrame win = new JFrame();
win.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
win.setSize( 600, 100 );
win.setTitle("Neues Model");
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
win.setLocation( (d.width - win.getSize().width ) / 2,
(d.height - win.getSize().height) / 2 );
JLabel text_1 = new JLabel( "Create New " );
JLabel text_2 = new JLabel (" Name:");
JTextField doc_number = new JTextField("12345678901", 8);
final JTextField model_name = new JTextField (10);
final JComboBox model_type = new JComboBox();
model_type.addItem( "PRT" );
model_type.addItem( "ASM" );
model_type.addItem( "DRW" );
JComboBox model_indicator = new JComboBox();
model_indicator.addItem( "_-_" );
model_indicator.addItem( "_b_" );
model_indicator.addItem( "_n_" );
JButton neu = new JButton ("Neu");
Container con = win.getContentPane();
win.setLayout( new FlowLayout() );
con.add (text_1);
con.add (model_type);
con.add (text_2);
con.add (doc_number);
con.add (model_indicator );
con.add (model_name);
con.add (neu);
win.setVisible( true );
ActionListener al = new ActionListener()
{
public void actionPerformed( ActionEvent e )
{
System.exit( 0 );
new_model(model_type.getToolTipText (),model_name.getText());
}
};
neu.addActionListener (al);
}
public Model new_model(/* String type , String model_name */)
{
Session session;
String model_std_path;
String model_std_name;
Model cur_model;
ModelType model_type;
ModelDescriptor descr;
String model_name;
model_name = "test-1";
try { session = pfcGlobal.GetProESession (); }
catch(jxthrowable x) {
System.out.println("Nicht mit Proe Verbunden");
return (null);
}
/* if (type == "prt")
{ */
model_type = ModelType.MDL_ASSEMBLY;
model_std_name = "_template_vie.prt";
model_std_path = "S:\templates_wf20";
try {
descr = pfcModel.ModelDescriptor_Create ( model_type, model_std_name, null);
descr.SetPath (model_std_path);
cur_model = session.RetrieveModel(descr);
return cur_model.CopyAndRetrieve (model_name, null);
}
catch (jxthrowable x) {
System.out.println ("Error in Creating new Part"+x);
return (null);
}
/*
else return (null); */
}
Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP