powerOn, Пасибо, а на мой лад....
Код | class AddNewRecord implements ActionListener { public void actionPerformed(ActionEvent event) { int numDep, numPub, i, j; String publisher, department; Vector pub = new Vector(); Vector dep = new Vector(); i = 0; j = 0;
try { coos.writeObject("4"); new AddPokazateliDialog(a, true).setVisible(true); } catch (Exception e) { System.out.println("Can't create about dialog"); } } }
public void AddBook(Object[] AddArr) { Object[] Add = new Object[2]; for (int i = 0; i < 2; i++) { Add[i] = AddArr[i]; } try { coos.writeObject("5"); coos.writeObject(Add); } catch (Exception h) { } }
|
где AddPokazateliDialog новый класс диалога, ... У меня почему то не работает
Добавлено через 13 минут и 17 секунд powerOn, Прошу прощения, я ерундк какую-то выложил... Вобщем, мне нужно по нажатию кнопк, чтоб выскочило окошко, в котором 2 Jtextfield и один Jbutton юзер вводит данные в первый и второй textfield нажимает Ок и данные заносятся в базу... я делаю так
Код | class AddNewRecord implements ActionListener { public void actionPerformed(ActionEvent event) { int numDep, numPub, i, j; try { coos.writeObject("4"); new AddPokazateliDialog(a, true).setVisible(true); } catch (Exception e) { System.out.println("Can't create about dialog"); } } } public void AddPok(Object[] AddArr) { Object[] Add = new Object[2]; for (int i = 0; i < 2; i++) { Add[i] = AddArr[i]; } try { coos.writeObject("5"); coos.writeObject(Add); } catch (Exception h) { } }
|
и класс AddPokazateliDialog
Код | public class AddPokazateliDialog extends JDialog {
JTextField OP; JTextField OOPR; JLabel OPLabel; JLabel OOPRLabel; JButton Add; Object[] ArrAdd = new Object[6]; ClientS obj = new ClientS();
public AddPokazateliDialog(JFrame parent, boolean modal) { super(parent, modal); setSize(310,390); setLayout(null);
OPLabel = new JLabel("Объем продаж родукта фирмой"); OPLabel.setBounds(50,30,200,20); add(OPLabel);
OP = new JTextField(); OP.setBounds(50,50,200,20); add(OP);
OOPRLabel = new JLabel("общий объем продаж продукта на рынке"); OOPRLabel.setBounds(50,70,100,20); add(OOPRLabel);
OOPR = new JTextField(); OOPR.setBounds(50,90,200,20); add(OOPR);
Add = new JButton("Добавить"); Add.setBounds(50,280,200,20); Add.addActionListener(new OnAdd()); add(Add); }
class OnAdd implements ActionListener { public void actionPerformed(ActionEvent event) { ArrAdd[0] = OP.getText(); ArrAdd[1] = OOPR.getText(); obj.AddPok(ArrAdd); dispose(); } }
class SymWindow extends WindowAdapter { public void windowClosing(WindowEvent event){ Object object = event.getSource(); if (object == AddPokazateliDialog.this) Close_AddPokazateliDialog(event); } } void Close_AddPokazateliDialog(WindowEvent event) { Close_AddBookDialog_Interaction1(event); } void Close_AddBookDialog_Interaction1(WindowEvent event) { try { this.dispose(); } catch (Exception e) {} } }
|
|