Main Page   Packages   Class Hierarchy   Compound List   File List   Compound Members  

AddLineDialog Class Reference

Inheritance diagram for AddLineDialog::

ActionListener List of all members.

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

Detailed Description

Line add dialog. For each line both node ends must be defined. If node does not exist, new one with defined name is created.

Definition at line 726 of file Simulation.java.


Constructor & Destructor Documentation

AddLineDialog::AddLineDialog ( ActionListener action_listener ) [inline]
 

Default constructor. Reference to network panel is required.

Parameters:
action_listener   Reference to action listener.

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     }


Member Function Documentation

void AddLineDialog::actionPerformed ( ActionEvent event ) [inline]
 

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     }


Member Data Documentation

ActionListener AddLineDialog::action_listener [private]
 

Action listener.

Definition at line 731 of file Simulation.java.

Dialog AddLineDialog::add_line [private]
 

Add line dialog box.

Definition at line 734 of file Simulation.java.

Button AddLineDialog::button_cancel [private]
 

Add line Cancel button.

Definition at line 740 of file Simulation.java.

Button AddLineDialog::button_ok [private]
 

Add line OK button.

Definition at line 737 of file Simulation.java.

int AddLineDialog::capacity [private]
 

Capacity.

Definition at line 758 of file Simulation.java.

TextField AddLineDialog::capacity_field [private]
 

Capacity field.

Definition at line 755 of file Simulation.java.

Frame AddLineDialog::dummy [private]
 

Dummy frame required to aviod null-parent exception.

Definition at line 761 of file Simulation.java.

TextField AddLineDialog::left_field [private]
 

Left node name field.

Definition at line 743 of file Simulation.java.

String AddLineDialog::left_name [private]
 

Left node name.

Definition at line 746 of file Simulation.java.

TextField AddLineDialog::right_field [private]
 

Right node name field.

Definition at line 749 of file Simulation.java.

String AddLineDialog::right_name [private]
 

Right node name.

Definition at line 752 of file Simulation.java.


The documentation for this class was generated from the following file:
Generated at Thu Jun 28 03:04:22 2001 for Cyclops Network Simulator by doxygen1.2.7 written by Dimitri van Heesch, © 1997-2001