FileDocCategorySizeDatePackage
Gui_1.javaAPI DocExample12176Tue Nov 04 13:26:42 GMT 2003org.eclipsebook.ch06

Gui_1

public class Gui_1 extends JFrame implements ActionListener
user code imports

Fields Summary
private JPanel
ivjFrame100ContentPane
private JButton
ivjButton100
private JTextField
ivjTextField100
Constructors Summary
public Gui_1()
Gui_1 constructor comment.

   
  
    super();
    initialize();

    // ---------- examples how to define a language locale ---------------

    //getGuiFacade().lang_init(java.util.Locale.US);
    //getGuiFacade().lang_init(new java.util.Locale("de", "CH"));

public Gui_1(String title)
Gui_1 constructor comment.

param
title java.lang.String

    super(title);
    initialize();

    // ---------- examples how to define a language locale ---------------

    //getGuiFacade().lang_init(java.util.Locale.US);
    //getGuiFacade().lang_init(new java.util.Locale("de", "CH"));

Methods Summary
public voidactionPerformed(java.awt.event.ActionEvent event)
user code methods V4ALL Entry Level

   if(event.getSource()==getButton100()){
       processEvent();
    }
private javax.swing.JButtongetButton100()
V4ALL Entry Level Return the Button100 property value.

return
javax.swing.JButtonl

    if (ivjButton100 == null) {
        try {
           ivjButton100 = new javax.swing.JButton();
           ivjButton100.setBounds(45, 76, 85, 25);
           ivjButton100.setMinimumSize(new java.awt.Dimension(85, 25));
           ivjButton100.setMaximumSize(new java.awt.Dimension(85, 25));
           ivjButton100.setName("Button100");
           ivjButton100.setBackground(new java.awt.Color(204, 204, 204));
           ivjButton100.setForeground(new java.awt.Color(0, 0, 0));
           ivjButton100.setFont(new java.awt.Font("Arial", 0, 12));
           ivjButton100.setOpaque(true);
           ivjButton100.setText("Click Me");
           ivjButton100.setActionCommand("");
           // user code begin {1} Swing
           // user code end
           // user code begin {1} SWT
           // user code end
           // user code begin {1} HTML
           // user code end
           // user code begin {1} Eclipse
           // user code end
           // user code begin {1} C#
           // user code end
        } catch (java.lang.Throwable ivjExc) {
           // user code begin {2} Swing
           // user code end
           // user code begin {2} SWT
           // user code end
           // user code begin {2} HTML
           // user code end
           // user code begin {2} Eclipse
           // user code end
           // user code begin {2} C#
           // user code end
        handleException(ivjExc);
        }
    }
    return ivjButton100;
private javax.swing.JPanelgetFrame100ContentPane()
Return the Frame100ContentPane property value.

return
javax.swing.JPanel

    if (ivjFrame100ContentPane == null) {
        try {
           ivjFrame100ContentPane = new javax.swing.JPanel();
           ivjFrame100ContentPane.setName("Frame100ContentPane");
           ivjFrame100ContentPane.setBackground(new java.awt.Color(204, 204, 204));
           ivjFrame100ContentPane.setForeground(new java.awt.Color(0, 0, 0));
           ivjFrame100ContentPane.setFont(new java.awt.Font("Arial", 0, 12));
           ivjFrame100ContentPane.setLayout(null);
           getFrame100ContentPane().add(getButton100(), getButton100().getName());
           getFrame100ContentPane().add(getTextField100(), getTextField100().getName());
           // user code begin {1} Swing
           // user code end
           // user code begin {1} SWT
           // user code end
           // user code begin {1} HTML
           // user code end
           // user code begin {1} Eclipse
           // user code end
           // user code begin {1} C#
           // user code end
        } catch (java.lang.Throwable ivjExc) {
           // user code begin {2} Swing
           // user code end
           // user code begin {2} SWT
           // user code end
           // user code begin {2} HTML
           // user code end
           // user code begin {2} Eclipse
           // user code end
           // user code begin {2} C#
           // user code end
        handleException(ivjExc);
        }
    }
    return ivjFrame100ContentPane;
private javax.swing.JTextFieldgetTextField100()
V4ALL Entry Level Return the TextField100 property value.

return
javax.swing.JTextFieldl

    if (ivjTextField100 == null) {
        try {
           ivjTextField100 = new javax.swing.JTextField();
           ivjTextField100.setBounds(168, 78, 80, 20);
           ivjTextField100.setMinimumSize(new java.awt.Dimension(80, 20));
           ivjTextField100.setMaximumSize(new java.awt.Dimension(80, 20));
           ivjTextField100.setName("TextField100");
           ivjTextField100.setBackground(new java.awt.Color(255, 255, 255));
           ivjTextField100.setForeground(new java.awt.Color(0, 0, 0));
           ivjTextField100.setFont(new java.awt.Font("Arial", 0, 12));
           ivjTextField100.setOpaque(true);
           // user code begin {1} Swing
           // user code end
           // user code begin {1} SWT
           // user code end
           // user code begin {1} HTML
           // user code end
           // user code begin {1} Eclipse
           // user code end
           // user code begin {1} C#
           // user code end
        } catch (java.lang.Throwable ivjExc) {
           // user code begin {2} Swing
           // user code end
           // user code begin {2} SWT
           // user code end
           // user code begin {2} HTML
           // user code end
           // user code begin {2} Eclipse
           // user code end
           // user code begin {2} C#
           // user code end
        handleException(ivjExc);
        }
    }
    return ivjTextField100;
private voidhandleException(java.lang.Throwable exception)
V4ALL Entry Level Called whenever the part throws an exception.

param
exception java.lang.Throwable

	/* Uncomment the following lines to print uncaught exceptions to stdout */
    // System.out.println("--------- UNCAUGHT EXCEPTION ---------");
    // exception.printStackTrace(System.out);
private voidinitConnections()
Initializes connections

exception
java.lang.Exception The exception description.

    getButton100().addActionListener(this);
    // user code begin {1} Swing
    // user code end
    // user code begin {1} SWT
    // user code end
    // user code begin {1} HTML
    // user code end
    // user code begin {1} Eclipse
    // user code end
    // user code begin {1} C#
    // user code end
    // user code begin {2} Swing
    // user code end
    // user code begin {2} SWT
    // user code end
    // user code begin {2} HTML
    // user code end
    // user code begin {2} Eclipse
    // user code end
    // user code begin {2} C#
    // user code end
private voidinitialize()
Initialize the class.

    try {
        // user code begin {1} Swing
        // user code end
        // user code begin {1} SWT
        // user code end
        // user code begin {1} HTML
        // user code end
        // user code begin {1} Eclipse
        // user code end
        // user code begin {1} C#
        // user code end
        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setSize(289, 161);
        setContentPane(getFrame100ContentPane());
        String plaf = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel";

        try{
        	javax.swing.UIManager.setLookAndFeel(plaf);
        	javax.swing.SwingUtilities.updateComponentTreeUI(this);
        }
        catch(javax.swing.UnsupportedLookAndFeelException ex1){
        	// System.out.println(ex1);
        }
        catch(ClassNotFoundException ex2){
        	// System.out.println(ex2);
        }
        catch(InstantiationException ex3){
        	// System.out.println(ex3);
        }
        catch(IllegalAccessException ex4){
        	// System.out.println(ex4);
        }
        initConnections();
        // user code begin {2} Swing
        // user code end
        // user code begin {2} SWT
        // user code end
        // user code begin {2} HTML
        // user code end
        // user code begin {2} Eclipse
        // user code end
        // user code begin {2} C#
        // user code end
     }
     catch (java.lang.Throwable ivjExc) {
         handleException(ivjExc);
     }
public static voidmain(java.lang.String[] args)
V4ALL Entry Level main entrypoint - starts the part when it is run as an application

param
args java.lang.String[]

    try {
        Gui_1 aGui_1;
        aGui_1 = new Gui_1();
        aGui_1.addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent e) {
                System.exit(0);
            };
        });
        aGui_1.show();
        java.awt.Insets insets = aGui_1.getInsets();
        aGui_1.setSize(aGui_1.getWidth() + insets.left + insets.right, aGui_1.getHeight() + insets.top + insets.bottom);
        showComponentCentered(aGui_1);
        aGui_1.setVisible(true);
    }
    catch (Throwable exception) {
        System.err.println("Exception occurred in main() of javax.swing.JFrame");
        exception.printStackTrace(System.out);
    }
 
public static voidpositionComponentCentered(java.awt.Component component)

	int height = java.awt.Toolkit.getDefaultToolkit().getScreenSize().height;
	int width  = java.awt.Toolkit.getDefaultToolkit().getScreenSize().width;
	int dialogHeight = component.getSize().height;
	int dialogWidth  = component.getSize().width;
	component.setLocation(width/2 - dialogWidth/2, height/2 - dialogHeight/2);
public voidprocessEvent()

    // user code begin {1} Swing
    // user code end
    // user code begin {1} SWT
    // user code end
    // user code begin {1} HTML
    // user code end
    // user code begin {1} Eclipse
    // user code end
    // user code begin {1} C#
    // user code end
public static voidshowComponentCentered(java.awt.Component component)

	positionComponentCentered(component);
	if(component instanceof javax.swing.JFrame){
		//((javax.swing.JFrame)component).toFront();
		((javax.swing.JFrame)component).show();
	}
	else if(component instanceof javax.swing.JDialog){
		//((javax.swing.JDialog)component).toFront();
		((javax.swing.JDialog)component).show();
	}
	else if(component instanceof javax.swing.JWindow){
		//((javax.swing.JWindow)component).toFront();
		((javax.swing.JWindow)component).show();
	}