/** Method declaration */
  private void initGUI() {

    Panel pQuery = new Panel();
    Panel pCommand = new Panel();

    pResult = new Panel();

    pQuery.setLayout(new BorderLayout());
    pCommand.setLayout(new BorderLayout());
    pResult.setLayout(new BorderLayout());

    Font fFont = new Font("Dialog", Font.PLAIN, 12);

    txtCommand = new TextArea(5, 40);

    txtCommand.addKeyListener(this);

    txtResult = new TextArea(20, 40);

    txtCommand.setFont(fFont);
    txtResult.setFont(new Font("Courier", Font.PLAIN, 12));

    butExecute = new Button("Execute");
    butClear = new Button("Clear");

    butExecute.addActionListener(this);
    butClear.addActionListener(this);
    pCommand.add("East", butExecute);
    pCommand.add("West", butClear);
    pCommand.add("Center", txtCommand);

    gResult = new Grid();

    setLayout(new BorderLayout());
    pResult.add("Center", gResult);
    pQuery.add("North", pCommand);
    pQuery.add("Center", pResult);
    fMain.add("Center", pQuery);

    tTree = new Tree();

    // (ulrivo): screen with less than 640 width
    Dimension d = Toolkit.getDefaultToolkit().getScreenSize();

    if (d.width >= 640) {
      tTree.setMinimumSize(new Dimension(200, 100));
    } else {
      tTree.setMinimumSize(new Dimension(80, 100));
    }

    gResult.setMinimumSize(new Dimension(200, 300));
    fMain.add("West", tTree);
    doLayout();
    fMain.pack();
  }
Example #2
0
  public void createGUI() {

    frame = new Frame();
    frame.setTitle("KeyMaskTest");
    frame.setLayout(new GridLayout(1, 6));

    button = new Button();
    button.addKeyListener(this);
    frame.add(button);

    buttonLW = new LWButton();
    buttonLW.addKeyListener(this);
    frame.add(buttonLW);

    textField = new TextField(5);
    textField.addKeyListener(this);
    frame.add(textField);

    textArea = new TextArea(5, 5);
    textArea.addKeyListener(this);
    frame.add(textArea);

    list = new List();
    for (int i = 1; i <= 5; ++i) {
      list.add("item " + i);
    }
    list.addKeyListener(this);
    frame.add(list);

    listLW = new LWList();
    for (int i = 1; i <= 5; ++i) {
      listLW.add("item " + i);
    }
    listLW.addKeyListener(this);
    frame.add(listLW);

    frame.setBackground(Color.gray);
    frame.setSize(500, 100);
    frame.setVisible(true);
    frame.toFront();
  }
  public babylonTextDialog(
      Frame parent,
      String myLabel,
      String contents,
      int columns,
      int rows,
      int scrollbars,
      boolean IsModal,
      String dismissString) {
    super(parent, myLabel, IsModal);

    parentFrame = parent;

    myLayout = new GridBagLayout();
    setLayout(myLayout);

    p = new Panel();
    p.setLayout(myLayout);

    textArea = new TextArea(contents, rows, columns, scrollbars);
    textArea.addKeyListener(this);
    textArea.setEditable(false);
    textArea.setFont(babylonPanel.smallFont);
    p.add(
        textArea,
        new babylonConstraints(
            0,
            0,
            1,
            1,
            1.0,
            1.0,
            GridBagConstraints.NORTHWEST,
            GridBagConstraints.BOTH,
            new Insets(0, 0, 5, 0),
            0,
            0));

    dismissButton = new Button(dismissString);
    dismissButton.setFont(babylonPanel.smallFont);
    dismissButton.addActionListener(this);
    dismissButton.addKeyListener(this);
    p.add(
        dismissButton,
        new babylonConstraints(
            0,
            1,
            1,
            1,
            1.0,
            1.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.NONE,
            new Insets(0, 0, 0, 0),
            0,
            0));

    add(
        p,
        new babylonConstraints(
            0,
            0,
            1,
            1,
            1.0,
            1.0,
            GridBagConstraints.NORTHWEST,
            GridBagConstraints.BOTH,
            new Insets(5, 5, 5, 5),
            0,
            0));

    pack();

    if ((parentFrame instanceof babylonWindow) || (parentFrame instanceof babylonServerWindow))
      babylonPanel.centerDialog(parentFrame, this);
    else babylonPanel.centerDialogOnScreen(this);

    addKeyListener(this);
    addWindowListener(this);
    setResizable(false);
    setVisible(true);
    dismissButton.requestFocus();
  }
Example #4
0
 /**
  * 新增視窗物件 設定物件屬性 內容
  *
  * @param o 物件instances
  * @param reg 物件位置
  * @param name 物件名稱
  * @param value 物件標籤 或 內容
  */
 protected void addObject(Object o, Rectangle reg, String name, String value) {
   if (o instanceof Label) {
     ((Label) o).setText(value);
     ((Label) o).setName(name);
     ((Label) o).setBounds(reg);
     ((Label) o).addMouseListener(this);
     this.add((Label) o);
   } else if (o instanceof TextField) {
     ((TextField) o).setText(value);
     ((TextField) o).setName(name);
     ((TextField) o).setBounds(reg);
     ((TextField) o).addMouseListener(this);
     ((TextField) o).addTextListener(this);
     ((TextField) o).addKeyListener(this);
     if (value.equalsIgnoreCase("password")) ((TextField) o).setEchoChar('*');
     this.add((TextField) o);
   } else if (o instanceof Button) {
     int len = (int) ((float) reg.width / FONTWIDTH);
     ((Button) o).setLabel(StringUtil_.splitStringSpace(value, len));
     ((Button) o).setName(name);
     ((Button) o).setBounds(reg);
     ((Button) o).addMouseListener(this);
     this.add((Button) o);
   } else if (o instanceof TextArea) {
     ((TextArea) o).setText(value);
     ((TextArea) o).setName(name);
     ((TextArea) o).setBounds(reg);
     ((TextArea) o).addMouseListener(this);
     ((TextArea) o).addTextListener(this);
     ((TextArea) o).addKeyListener(this);
     this.add((TextArea) o);
   } else if (o instanceof Choice) {
     String[] values = value.split(",");
     for (int ii = 0; ii < values.length; ii++) ((Choice) o).addItem(values[ii]);
     ((Choice) o).setName(name);
     ((Choice) o).setBounds(reg);
     ((Choice) o).addMouseListener(this);
     ((Choice) o).addItemListener(this);
     this.add((Choice) o);
   } else if (o instanceof Checkbox) {
     ((Checkbox) o).setLabel(value);
     ((Checkbox) o).setName(name);
     ((Checkbox) o).setBounds(reg);
     ((Checkbox) o).addMouseListener(this);
     ((Checkbox) o).addItemListener(this);
     this.add((Checkbox) o);
   } else if (o instanceof CheckboxGroup) {
     String[] values = value.split(",");
     for (int ii = 0; ii < values.length; ii++) {
       Checkbox chk = new Checkbox();
       chk.setLabel(values[ii]);
       chk.setName(name + ii);
       chk.setBounds(reg);
       reg.y += 25;
       chk.addMouseListener(this);
       chk.addItemListener(this);
       chk.setCheckboxGroup((CheckboxGroup) o);
       this.add(chk);
     }
   } else if (o instanceof List) {
     String[] values = value.split(",");
     ((List) o).setName(name);
     ((List) o).setBounds(reg);
     ((List) o).addMouseListener(this);
     ((List) o).addItemListener(this);
     for (int ii = 0; ii < values.length; ii++) ((List) o).add(values[ii]);
     this.add(((List) o));
   }
 }
Example #5
0
  public ServiceDialog(Image windowIconImage, String message, boolean serviceAvailable) {
    super(windowIconImage, SERVICE_TITLE);

    addWindowListener(
        new WindowAdapter() {
          @Override
          public void windowClosing(WindowEvent e) {
            finish();
          }
        });

    setLayout(new BorderLayout());
    setBackground(SystemColor.control);

    Panel p = new Panel(new FlowLayout(FlowLayout.LEFT, 15, 15));
    add("West", p); // $NON-NLS-1$

    Label c = new ImageLabel(SERVICE_ICON);
    c.setPreferredSize(new Dimension(48, 48));
    p.add(c);

    Panel tp = new Panel(new BorderLayout());
    add("Center", tp); // $NON-NLS-1$

    p = new Panel(new FlowLayout(FlowLayout.LEFT, 0, 15));
    tp.add("North", p); // $NON-NLS-1$
    Panel mp = new Panel(new BorderLayout());
    p.add(mp);

    mp.add("North", new Label(SERVICE_TITLE + ":")); // $NON-NLS-1$ //$NON-NLS-2$

    p = new Panel(new FlowLayout(FlowLayout.LEFT));
    mp.add("Center", p); // $NON-NLS-1$

    TextArea ta = new TextArea(message, 5, 70);
    ta.setEditable(false);

    ta.addFocusListener(
        new FocusAdapter() {
          @Override
          public void focusGained(FocusEvent e) {
            if (!m_focusRepaired) // OK button should be focused first
            {
              m_okButton.requestFocus();
            }
          }
        });

    ta.addKeyListener(
        new KeyAdapter() {
          @Override
          public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_ENTER) {
              finish();
            }
          }
        });

    p.add(ta);

    if (!serviceAvailable) {
      tp.add("South", new Label(SERVICE_NOT_AVAILABLE)); // $NON-NLS-1$
    }

    p = new Panel(new FlowLayout(FlowLayout.RIGHT, 15, 15));
    m_okButton = new Button(Messages.getString("ok")); // $NON-NLS-1$
    m_okButton.setPreferredSize(new Dimension(73, 20));

    m_okButton.addFocusListener(
        new FocusAdapter() {

          @Override
          public void focusGained(FocusEvent e) {
            m_focusRepaired = true;
          }
        });

    m_okButton.addActionListener(
        new ActionListener() {

          public void actionPerformed(ActionEvent e) {
            finish();
          }
        });

    m_okButton.addKeyListener(
        new KeyAdapter() {

          @Override
          public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_ENTER) {
              finish();
            }
          }
        });
    p.add(m_okButton);
    add("South", p); // $NON-NLS-1$

    pack();

    int width = Math.max(getWidth(), MIN_H_SIZE);
    int height = Math.max(getHeight(), MIN_V_SIZE);

    Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();

    setBounds((screen.width - width) / 2, (screen.height - height) / 2, width, height);
  }