Inheritance diagram for AddLineDialog::
Public Methods | |
AddLineDialog (ActionListener action_listener) | |
void | actionPerformed (ActionEvent event) |
Private Attributes | |
ActionListener | action_listener |
Dialog | add_line |
Button | button_ok |
Button | button_cancel |
TextField | left_field |
String | left_name |
TextField | right_field |
String | right_name |
TextField | capacity_field |
int | capacity |
Frame | dummy |
Definition at line 726 of file Simulation.java.
|
Default constructor. Reference to network panel is required.
Definition at line 767 of file Simulation.java. 00768 { 00769 this.action_listener = action_listener; 00770 00771 dummy = new Frame(); 00772 add_line = new Dialog(dummy, "Dodaj liniju"); 00773 button_ok = new Button("U redu"); 00774 button_cancel = new Button("Odustani"); 00775 left_field = new TextField("ime", 30); 00776 right_field = new TextField("ime", 30); 00777 capacity_field = new TextField("20", 30); 00778 00779 Label left_label = new Label("Lijevi \u010dvor", Label.RIGHT); 00780 Label right_label = new Label("Desni \u010dvor", Label.RIGHT); 00781 Label capacity_label = new Label("Kapacitet", Label.RIGHT); 00782 00783 add_line.setLayout(new BorderLayout()); 00784 add_line.setLayout(new GridLayout(4,2)); 00785 add_line.add(left_label); 00786 add_line.add(left_field); 00787 add_line.add(right_label); 00788 add_line.add(right_field); 00789 add_line.add(capacity_label); 00790 add_line.add(capacity_field); 00791 add_line.add(button_ok); 00792 add_line.add(button_cancel); 00793 00794 right_field.addActionListener(this); 00795 left_field.addActionListener(this); 00796 capacity_field.addActionListener(this); 00797 button_ok.addActionListener(this); 00798 button_cancel.addActionListener(this); 00799 00800 add_line.pack(); 00801 add_line.setResizable(false); 00802 add_line.show(); 00803 } |
|
Action handler. Wait for OK or Cancel button and then reads input and terminates dialog. Definition at line 809 of file Simulation.java. 00810 { 00811 Object source = event.getSource(); 00812 00813 /* left_field event */ 00814 if (source == left_field) 00815 { 00816 left_name = left_field.getText(); 00817 } 00818 /* right_field event */ 00819 if (source == right_field) 00820 { 00821 right_name = right_field.getText(); 00822 } 00823 /* capacity event */ 00824 if (source == capacity_field) 00825 { 00826 capacity = Integer.valueOf(capacity_field.getText()).intValue(); 00827 } 00828 /* button_ok event */ 00829 if (source == button_ok) 00830 { 00831 left_name = left_field.getText(); 00832 right_name = right_field.getText(); 00833 capacity = Integer.valueOf(capacity_field.getText()).intValue(); 00834 add_line.dispose(); 00835 if (left_name.equals(right_name)) 00836 { 00837 action_listener.actionPerformed(new ActionEvent(this, 1, "Cancel")); 00838 } 00839 else 00840 { 00841 action_listener.actionPerformed(new ActionEvent(this, 1, "OK")); 00842 } 00843 } 00844 /* button_cancel event */ 00845 if (source == button_cancel) 00846 { 00847 add_line.dispose(); 00848 action_listener.actionPerformed(new ActionEvent(this, 0, "Cancel")); 00849 } 00850 } |
|
Action listener. Definition at line 731 of file Simulation.java. |
|
Add line dialog box. Definition at line 734 of file Simulation.java. |
|
Add line Cancel button. Definition at line 740 of file Simulation.java. |
|
Add line OK button. Definition at line 737 of file Simulation.java. |
|
Capacity. Definition at line 758 of file Simulation.java. |
|
Capacity field. Definition at line 755 of file Simulation.java. |
|
Dummy frame required to aviod null-parent exception. Definition at line 761 of file Simulation.java. |
|
Left node name field. Definition at line 743 of file Simulation.java. |
|
Left node name. Definition at line 746 of file Simulation.java. |
|
Right node name field. Definition at line 749 of file Simulation.java. |
|
Right node name. Definition at line 752 of file Simulation.java. |