Exemple #1
52
 /**
  * Show the given message in a dialog box or independent window, depending on whether the source
  * component is contained in a Frame or not.
  *
  * @param c The Controller that calls this method, or null if it is not called by a Controller.
  *     (The Controller, if any, will be notified when the error message is cleared.)
  * @param message The message to display.
  */
 public void setErrorMessage(Controller c, String message) {
   if (popup != null) clearErrorMessage();
   if (message == null) return;
   errorSource = c;
   errorMessage = message;
   Component parent = source;
   while (parent != null && !(parent instanceof Frame)) parent = parent.getParent();
   if (parent != null) popup = new Dialog((Frame) parent, "Error Message", true); // modal dialog
   else popup = new Frame("Error Message"); // independent window
   popup.setBackground(Color.white);
   popup.add(new MC(message), BorderLayout.CENTER);
   Panel buttonBar = new Panel();
   buttonBar.setLayout(new FlowLayout(FlowLayout.RIGHT, 10, 10));
   Button OK = new Button("    OK    ");
   OK.addActionListener(this);
   buttonBar.add(OK);
   popup.add(buttonBar, BorderLayout.SOUTH);
   popup.pack();
   if (parent == null) popup.setLocation(100, 80);
   else popup.setLocation(parent.getLocation().x + 50, parent.getLocation().y + 30);
   popup.addWindowListener(
       new WindowAdapter() {
         public void windowClosing(WindowEvent evt) {
           popup.dispose();
         }
       });
   popup.show(); // make the dialog visible.
 }
  public void frameInit() {
    ta.setBackground(Color.white);
    p = new Panel();
    p2 = new Panel();
    p3 = new Panel();

    b = new Button("close");
    status = new Label("Status:", Label.LEFT);

    p2.setLayout(new GridLayout(2, 1, 5, 5));
    p2.add(status);

    p.setLayout(new FlowLayout());
    p.add(b);

    p3.setLayout(new GridLayout(2, 1, 0, 0));
    p3.add(p2);
    p3.add(p);

    setLayout(new BorderLayout());
    add("Center", ta);

    add("South", p3);

    b.addActionListener(this);
  }
Exemple #3
0
  void jbInit() throws Exception {
    panel1.setLayout(borderLayout1);
    panel2.setBackground(Color.yellow);
    panel2.setLayout(borderLayout2);
    ButtonOK.setLabel("OK");
    ButtonOK.addMouseListener(
        new java.awt.event.MouseAdapter() {

          public void mouseClicked(MouseEvent e) {
            ButtonOK_mouseClicked(e);
          }
        });

    String s1 = CallingApp.MotherApplet.GetName();

    textArea1.setBackground(SystemColor.control);
    textArea1.setEditable(false);

    panel1.add(panel2, BorderLayout.CENTER);
    panel2.add(textArea1, BorderLayout.CENTER);
    panel1.add(panel3, BorderLayout.SOUTH);
    panel3.add(ButtonOK, null);
    String s =
        s1
            + " v:"
            + CallingApp.MotherApplet.GetVersionNum()
            + "\n"
            + CallingApp.MotherApplet.GetInfos();
    textArea1.setText(s);
  }
Exemple #4
0
 /**
  * Adds a group of checkboxs using a grid layout.
  *
  * @param rows the number of rows
  * @param columns the number of columns
  * @param labels the labels
  * @param defaultValues the initial states
  * @param headings the column headings Example:
  *     http://imagej.nih.gov/ij/plugins/multi-column-dialog/index.html
  */
 public void addCheckboxGroup(
     int rows, int columns, String[] labels, boolean[] defaultValues, String[] headings) {
   Panel panel = new Panel();
   int nRows = headings != null ? rows + 1 : rows;
   panel.setLayout(new GridLayout(nRows, columns, 6, 0));
   int startCBIndex = cbIndex;
   if (checkbox == null) checkbox = new Vector(12);
   if (headings != null) {
     Font font = new Font("SansSerif", Font.BOLD, 12);
     for (int i = 0; i < columns; i++) {
       if (i > headings.length - 1 || headings[i] == null) panel.add(new Label(""));
       else {
         Label label = new Label(headings[i]);
         label.setFont(font);
         panel.add(label);
       }
     }
   }
   int i1 = 0;
   int[] index = new int[labels.length];
   for (int row = 0; row < rows; row++) {
     for (int col = 0; col < columns; col++) {
       int i2 = col * rows + row;
       if (i2 >= labels.length) break;
       index[i1] = i2;
       String label = labels[i1];
       if (label == null || label.length() == 0) {
         Label lbl = new Label("");
         panel.add(lbl);
         i1++;
         continue;
       }
       if (label.indexOf('_') != -1) label = label.replace('_', ' ');
       Checkbox cb = new Checkbox(label);
       checkbox.addElement(cb);
       cb.setState(defaultValues[i1]);
       cb.addItemListener(this);
       if (Recorder.record || macro) saveLabel(cb, labels[i1]);
       if (IJ.isLinux()) {
         Panel panel2 = new Panel();
         panel2.setLayout(new BorderLayout());
         panel2.add("West", cb);
         panel.add(panel2);
       } else panel.add(cb);
       i1++;
     }
   }
   c.gridx = 0;
   c.gridy = y;
   c.gridwidth = 2;
   c.anchor = GridBagConstraints.WEST;
   c.insets = getInsets(10, 0, 0, 0);
   grid.setConstraints(panel, c);
   add(panel);
   y++;
 }
  /** 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();
  }
  // Color gre;
  Rules(String se) {
    email = se;
    conti = new Button("Continue");
    rules = new Button("ClicK Here For Rules");
    p1 = new JOptionPane();
    Icon image = new ImageIcon("books.jpg");
    Icon image1 = new ImageIcon("girl.jpg");
    Icon image2 = new ImageIcon("uit.jpg");
    gl = new GridBagLayout();
    gbc = new GridBagConstraints();
    conti.addActionListener(this);
    rules.addActionListener(this);
    // gre=new Color(117,102,185);
    p = new Panel();
    p2 = new Panel();
    p3 = new Panel();
    p4 = new Panel();
    f = new Frame();
    pic = new JLabel(image);
    pic1 = new JLabel(image1);
    pic2 = new JLabel(image2);
    gbc.anchor = GridBagConstraints.SOUTHWEST;
    gl.setConstraints(pic1, gbc);
    gbc.anchor = GridBagConstraints.SOUTHEAST;
    gl.setConstraints(pic, gbc);
    Insets is = new Insets(30, 30, 30, 30);
    gbc.insets = is;
    gbc.ipadx = 14;
    gbc.ipady = 8;
    gl.setConstraints(rules, gbc);
    gl.setConstraints(conti, gbc);
    p2.setLayout(gl);
    p4.add(pic2);
    p2.add(pic);
    p3.setLayout(gl);
    p3.add(pic1);
    p.add(conti);
    p.add(rules);
    p.setLayout(gl);
    f.add(p4, "North");
    f.add(p3, "East");
    f.add(p2, "West");

    f.add(p, "Center");
    f.setTitle("RULES BOOK");
    // f.setBackground(gre);
    f.setVisible(true);
    f.setSize(900, 600);
    f.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent we) {
            System.exit(0);
          }
        });
  }
Exemple #7
0
 public void init(GUI gui) {
   m_gui = gui;
   // Create the display
   // width, height
   addWindowListener(
       new WindowAdapter() {
         public void windowClosing(WindowEvent e) {
           dispose();
         }
       });
   setSize(new Dimension(100, 100));
   setBackground(Color.white);
   setFont(new Font("Helvetica", Font.PLAIN, 14));
   GridBagLayout gridbag = new GridBagLayout();
   setLayout(gridbag);
   GridBagConstraints c = new GridBagConstraints();
   c.fill = GridBagConstraints.BOTH;
   c.weightx = 1.0;
   recency = new TextField(Truline.userProps.getProperty("RecencyDays", "28"), 5);
   setRow(c, gridbag, new Label("Recency Days"), recency);
   maxdays = new TextField(Truline.userProps.getProperty("MaxDays", "120"), 5);
   setRow(c, gridbag, new Label("Max Days"), maxdays);
   maxvariant = new TextField(Truline.userProps.getProperty("MaxVariant", "25"), 5);
   setRow(c, gridbag, new Label("Max Variant"), maxvariant);
   maiden = new TextField(Truline.userProps.getProperty("UseMaiden", "Y"), 2);
   setRow(c, gridbag, new Label("Use Maiden"), maiden);
   betFactorVersion = new TextField(Truline.userProps.getProperty("BetFactorVersion", " "), 7);
   setRow(c, gridbag, new Label("Bet Factor Version"), betFactorVersion);
   datadir = new TextField(Truline.userProps.getProperty("DATADIR", "."), 40);
   setRow(c, gridbag, new Label("Data Directory"), datadir);
   fontsize = new TextField(Truline.userProps.getProperty("FontSize", "8"), 40);
   setRow(c, gridbag, new Label("Print Font Size (8,9,10)"), fontsize);
   printProgram =
       new TextField(Truline.userProps.getProperty("PrintProgram", "WordPad.exe /p"), 40);
   setRow(c, gridbag, new Label("Print program"), printProgram);
   // shell = new TextField(Truline.userProps.getProperty("Shell", "command"),
   // 40);
   // setRow(c, gridbag, new Label("Shell program"), shell);
   Panel panel1 = new Panel();
   panel1.setLayout(new BorderLayout());
   Button OKButton = new Button(" OK ");
   OKButton.setActionCommand("ok");
   OKButton.addActionListener(this);
   panel1.add(OKButton, BorderLayout.CENTER);
   Panel panel2 = new Panel();
   panel2.setLayout(new BorderLayout());
   Button cancelButton = new Button("Cancel");
   cancelButton.setActionCommand("cancel");
   cancelButton.addActionListener(this);
   panel2.add(cancelButton, BorderLayout.CENTER);
   setRow(c, gridbag, panel2, panel1);
   pack();
   show();
 }
  private void updateDebugPanelState(String result, boolean debug, boolean test) {
    result = result == null ? "nothing" : result;

    List<Component> componentList = Arrays.asList(getComponents());
    if (!componentList.contains(p_debug)) {

      choice = new Label(String.format("Your choice is: %s", result));
      isDebug = new Label(String.format("Debug mode: %b", debug));
      isTest = new Label(String.format("Test mode: %b", test));
      GridBagLayout layout = new GridBagLayout();
      GridBagConstraints constraints = new GridBagConstraints();
      layout.setConstraints(choice, constraints);
      constraints.gridy = 1;
      layout.setConstraints(isDebug, constraints);
      constraints.gridy = 2;
      layout.setConstraints(isTest, constraints);

      p_debug.setLayout(layout);
      p_debug.add(choice);
      p_debug.add(isDebug);
      p_debug.add(isTest);
      add(p_debug, BorderLayout.SOUTH);

    } else {
      choice.setText(String.format("Your choice is: %s", result));
      isDebug.setText(String.format("Debug mode: %b", debug));
      isTest.setText(String.format("Test mode: %b", test));
    }
  }
Exemple #9
0
  public void launchCalc() {
    f.add(tf, BorderLayout.NORTH);
    p2 = new Panel();
    p2.setLayout(new GridLayout(4, 5));
    p2.add(b1);
    p2.add(b2);
    p2.add(b3);
    p2.add(b18);
    p2.add(b10);
    p2.add(b6);
    p2.add(b7);
    p2.add(b8);
    p2.add(b19);
    p2.add(b4);
    p2.add(b11);
    p2.add(b12);
    p2.add(b13);
    p2.add(b14);
    p2.add(b9);
    p2.add(b16);
    p2.add(b17);
    p2.add(b20);
    p2.add(b15);
    p2.add(b5);

    f.add(p2, BorderLayout.CENTER);
    f.pack();
    f.setSize(250, 200);
    f.setVisible(true);
  }
Exemple #10
0
 /**
  * Adds a radio button group.
  *
  * @param label group label (or null)
  * @param items radio button labels
  * @param rows number of rows
  * @param columns number of columns
  * @param defaultItem button initially selected
  */
 public void addRadioButtonGroup(
     String label, String[] items, int rows, int columns, String defaultItem) {
   Panel panel = new Panel();
   int n = items.length;
   panel.setLayout(new GridLayout(rows, columns, 0, 0));
   CheckboxGroup cg = new CheckboxGroup();
   for (int i = 0; i < n; i++) {
     Checkbox cb = new Checkbox(items[i], cg, items[i].equals(defaultItem));
     cb.addItemListener(this);
     panel.add(cb);
   }
   if (radioButtonGroups == null) radioButtonGroups = new Vector();
   radioButtonGroups.addElement(cg);
   Insets insets = getInsets(5, 10, 0, 0);
   if (label == null || label.equals("")) {
     label = "rbg" + radioButtonGroups.size();
     insets.top += 5;
   } else {
     setInsets(10, insets.left, 0);
     addMessage(label);
     insets.top = 2;
     insets.left += 10;
   }
   c.gridx = 0;
   c.gridy = y;
   c.gridwidth = 2;
   c.anchor = GridBagConstraints.WEST;
   c.insets = new Insets(insets.top, insets.left, 0, 0);
   grid.setConstraints(panel, c);
   add(panel);
   if (Recorder.record || macro) saveLabel(cg, label);
   y++;
 }
 /** Component initialization */
 private void jbInit() throws Exception {
   contentPane = (JPanel) this.getContentPane();
   contentPane.setLayout(bd);
   ThreadPanel tp1 = new ThreadPanel("Passengers", Color.blue);
   ThreadPanel tp2 = new ThreadPanel("Car(2)", Color.blue);
   ThreadPanel tp3 = new ThreadPanel("Car(3)", Color.blue);
   NumberCanvas nc1 = new NumberCanvas("Platform");
   NumberCanvas nc2 = new NumberCanvas("In Car(2)");
   NumberCanvas nc3 = new NumberCanvas("In Car(3)");
   Panel p1 = new Panel();
   p1.setLayout(new BorderLayout());
   Panel p2 = new Panel();
   p2.setLayout(new BorderLayout());
   Panel p3 = new Panel();
   p3.setLayout(new BorderLayout());
   p1.add(nc1, BorderLayout.CENTER);
   p1.add(tp1, BorderLayout.SOUTH);
   p2.add(nc2, BorderLayout.CENTER);
   p2.add(tp2, BorderLayout.SOUTH);
   p3.add(nc3, BorderLayout.CENTER);
   p3.add(tp3, BorderLayout.SOUTH);
   Panel grid = new Panel();
   grid.setLayout(new GridLayout(1, 3));
   grid.add(p1);
   grid.add(p2);
   grid.add(p3);
   contentPane.add(grid, BorderLayout.CENTER);
   // construct threads, monitor & go button
   final Controller c = new Controller(nc1);
   final PlatformAccess pa = new PlatformAccess();
   Button go = new Button("Go Now");
   go.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent e) {
           c.goNow();
         }
       });
   contentPane.add(go, BorderLayout.SOUTH);
   tp1.start(new Passengers(c));
   tp2.start(new CoasterCar(2, c, pa, nc2));
   tp3.start(new CoasterCar(3, c, pa, nc3));
   this.setSize(new Dimension(470, 350));
   this.setTitle("Roller Coaster Laboratory Exercise");
 }
  /** Constructor. */
  private HeaderPanel() {
    setBackground(BACKGROUND_COLOR);
    setLayout(cardLayout);

    add(functionCard, FUNCTION);
    add(messageCard, MESSAGE);

    functionCard.setBackground(BACKGROUND_COLOR);
    functionCard.setLayout(new BorderLayout());

    messageCard.setBackground(BACKGROUND_COLOR);
    messageCard.setLayout(new BorderLayout());

    label.setFont(new Font("Dialog", Font.BOLD, 12));
    label.setAlignment(Label.CENTER);
    label.setForeground(Color.black);

    messageCard.add(label, BorderLayout.CENTER);
  }
  public YesNoCancelDialog(Frame parent, String title, String msg) {
    super(parent, title, true);
    setLayout(new BorderLayout());
    Panel panel = new Panel();
    panel.setLayout(new FlowLayout(FlowLayout.LEFT, 10, 10));
    MultiLineLabel message = new MultiLineLabel(msg);
    message.setFont(new Font("Dialog", Font.PLAIN, 12));
    panel.add(message);
    add("North", panel);

    panel = new Panel();
    panel.setLayout(new FlowLayout(FlowLayout.RIGHT, 15, 8));
    if (IJ.isMacintosh() && msg.startsWith("Save")) {
      yesB = new Button("  Save  ");
      noB = new Button("Don't Save");
      cancelB = new Button("  Cancel  ");
    } else {
      yesB = new Button("  Yes  ");
      noB = new Button("  No  ");
      cancelB = new Button(" Cancel ");
    }
    yesB.addActionListener(this);
    noB.addActionListener(this);
    cancelB.addActionListener(this);
    yesB.addKeyListener(this);
    noB.addKeyListener(this);
    cancelB.addKeyListener(this);
    if (IJ.isMacintosh()) {
      panel.add(noB);
      panel.add(cancelB);
      panel.add(yesB);
      setResizable(false);
    } else {
      panel.add(yesB);
      panel.add(noB);
      panel.add(cancelB);
    }
    add("South", panel);
    pack();
    GUI.center(this);
    show();
  }
Exemple #14
0
 public CipherChatClient() {
   super("Cipher Chat Client");
   // Establish keys for RSA cipher
   makeKeys();
   // Lay out the components and display the frame
   setLayout(new GridLayout(2, 1));
   top.setLayout(new GridLayout(3, 1));
   add(top);
   bottom.setLayout(new GridLayout(1, 1));
   add(bottom);
   connectButton.addActionListener(this);
   enterField.setEnabled(false);
   enterField.addActionListener(this);
   top.add(serverField);
   top.add(connectButton);
   top.add(enterField);
   bottom.add(displayArea);
   setSize(400, 300);
   show();
 }
Exemple #15
0
 public ToeTestNew() {
   setTitle("Toe Test");
   Panel p = new Panel();
   p.setLayout(new GridLayout(2, 2));
   p.add(new Label("Rows", Label.CENTER));
   p.add(rows);
   p.add(new Label("Columns", Label.CENTER));
   p.add(cols);
   add(p, BorderLayout.NORTH);
   Button b = new Button("go");
   b.addActionListener(new BL());
   add(b, BorderLayout.SOUTH);
 }
Exemple #16
0
 /**
  * Adds a numeric field. The first word of the label must be unique or command recording will not
  * work.
  *
  * @param label the label
  * @param defaultValue value to be initially displayed
  * @param digits number of digits to right of decimal point
  * @param columns width of field in characters
  * @param units a string displayed to the right of the field
  */
 public void addNumericField(
     String label, double defaultValue, int digits, int columns, String units) {
   String label2 = label;
   if (label2.indexOf('_') != -1) label2 = label2.replace('_', ' ');
   Label theLabel = makeLabel(label2);
   c.gridx = 0;
   c.gridy = y;
   c.anchor = GridBagConstraints.EAST;
   c.gridwidth = 1;
   if (firstNumericField) c.insets = getInsets(5, 0, 3, 0);
   else c.insets = getInsets(0, 0, 3, 0);
   grid.setConstraints(theLabel, c);
   add(theLabel);
   if (numberField == null) {
     numberField = new Vector(5);
     defaultValues = new Vector(5);
     defaultText = new Vector(5);
   }
   if (IJ.isWindows()) columns -= 2;
   if (columns < 1) columns = 1;
   String defaultString = IJ.d2s(defaultValue, digits);
   if (Double.isNaN(defaultValue)) defaultString = "";
   TextField tf = new TextField(defaultString, columns);
   if (IJ.isLinux()) tf.setBackground(Color.white);
   tf.addActionListener(this);
   tf.addTextListener(this);
   tf.addFocusListener(this);
   tf.addKeyListener(this);
   numberField.addElement(tf);
   defaultValues.addElement(new Double(defaultValue));
   defaultText.addElement(tf.getText());
   c.gridx = 1;
   c.gridy = y;
   c.anchor = GridBagConstraints.WEST;
   tf.setEditable(true);
   // if (firstNumericField) tf.selectAll();
   firstNumericField = false;
   if (units == null || units.equals("")) {
     grid.setConstraints(tf, c);
     add(tf);
   } else {
     Panel panel = new Panel();
     panel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
     panel.add(tf);
     panel.add(new Label(" " + units));
     grid.setConstraints(panel, c);
     add(panel);
   }
   if (Recorder.record || macro) saveLabel(tf, label);
   y++;
 }
 /* WARNING: THIS METHOD WILL BE REGENERATED. */
 private java.awt.Panel getPanel1() {
   if (ivjPanel1 == null) {
     try {
       ivjPanel1 = new java.awt.Panel();
       ivjPanel1.setName("Panel1");
       ivjPanel1.setLayout(getPanel1FlowLayout());
       getPanel1().add(getokButton(), getokButton().getName());
       // user code begin {1}
       // user code end
     } catch (java.lang.Throwable ivjExc) {
       // user code begin {2}
       // user code end
       handleException(ivjExc);
     }
   }
   return ivjPanel1;
 }
Exemple #18
0
  public memoDialog(Frame fr, Field f) {
    super(fr, f.getName(), true);
    addWindowListener(this);
    f1 = f;

    text.setText(f1.get());
    this.add("Center", text);

    Panel p = new Panel();
    p.setLayout(new FlowLayout(FlowLayout.CENTER, 15, 15));
    p.add(Okay);
    Okay.addActionListener(this);
    this.add("East", p);
    p.add(Cancel);
    Cancel.addActionListener(this);
    this.add("West", p);
    this.pack();
  }
 /* WARNING: THIS METHOD WILL BE REGENERATED. */
 private java.awt.Panel getbutonPanel() {
   if (ivjbutonPanel == null) {
     try {
       ivjbutonPanel = new java.awt.Panel();
       ivjbutonPanel.setName("butonPanel");
       ivjbutonPanel.setLayout(new java.awt.FlowLayout());
       getbutonPanel().add(getfindButton(), getfindButton().getName());
       getbutonPanel().add(getaddButton(), getaddButton().getName());
       // user code begin {1}
       // user code end
     } catch (java.lang.Throwable ivjExc) {
       // user code begin {2}
       // user code end
       handleException(ivjExc);
     }
   }
   return ivjbutonPanel;
 }
 /* WARNING: THIS METHOD WILL BE REGENERATED. */
 private java.awt.Panel getContentsPane() {
   if (ivjContentsPane == null) {
     try {
       ivjContentsPane = new java.awt.Panel();
       ivjContentsPane.setName("ContentsPane");
       ivjContentsPane.setLayout(new java.awt.BorderLayout());
       getContentsPane().add(getPanel1(), "South");
       getContentsPane().add(getLabel1(), "North");
       // user code begin {1}
       // user code end
     } catch (java.lang.Throwable ivjExc) {
       // user code begin {2}
       // user code end
       handleException(ivjExc);
     }
   }
   return ivjContentsPane;
 }
Exemple #21
0
    public ModalDialog(Frame owner, String title, String msg, String[] buttons) {
      super(owner, title, true);

      setBackground(Color.lightGray);
      setLayout(new BorderLayout());
      setResizable(false);
      add(new Label(msg), BorderLayout.CENTER);

      Panel panel = new Panel();
      panel.setLayout(new FlowLayout(FlowLayout.CENTER));

      for (int i = 0; i < buttons.length; i++) {
        Button button = new Button(buttons[i]);
        button.addActionListener(this);
        panel.add(button);
      }

      add(panel, BorderLayout.SOUTH);
      pack();
    }
Exemple #22
0
  Board() {
    addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            exit();
          }
        });
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    setSize(screenSize);
    setLocation(0, 0);
    r3 = Math.sqrt(3);
    Button ng, eg, ab;
    ng = new Button("New Game");
    eg = new Button("Exit Game");
    ab = new Button("About");
    gold = new ImageIcon("./coin2.jpg").getImage();
    silver = new ImageIcon("./coin1.jpg").getImage();
    Panel pan = new Panel();
    pan.setLayout(new FlowLayout());
    pan.add(ng);
    pan.add(eg);
    pan.add(ab);
    setLayout(new BorderLayout());
    add(pan, BorderLayout.NORTH);

    newGame();
    ng.addActionListener(this);
    eg.addActionListener(this);
    ab.addActionListener(this);

    addMouseListener(
        new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
            int mx = e.getX(), my = e.getY();
            place(mx, my);
          }
        });
  }
Exemple #23
0
  public MessageBox(String title, String message) {
    super(title);
    setLayout(new BorderLayout());

    // Panel at the bottom with a flow layout to put an OK button
    Panel bottom = new Panel();
    bottom.setLayout(new FlowLayout());
    Button ok = new Button("Grrr!!!");
    ok.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            dispose();
          }
        });
    bottom.add(ok);

    // Add a message label.
    add("Center", new Label(message, Label.CENTER));
    // Add the panel with the button to the south
    add("South", bottom);
    // Frame requires explicit setVisible(true)
    setVisible(true);
  }
  /**
   * Constructor.
   *
   * @param functions the array of functions to plot
   * @param graphPanel the parent graph panel
   */
  HeaderPanel(Plottable functions[], GraphPanel graphPanel) {
    this();
    this.graphPanel = graphPanel;

    fpDimensions = maxFunctionDimensions(functions);

    buttonPanel.setLayout(new FlowLayout());
    buttonPanel.add(headerButton);

    imagePanel.setSize(fpDimensions);

    functionCard.add(buttonPanel, BorderLayout.WEST);
    functionCard.add(imagePanel, BorderLayout.CENTER);

    cardLayout.show(this, FUNCTION);

    // Header button handler.
    headerButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ev) {
            HeaderPanel.this.graphPanel.doHeaderAction(); // callback
          }
        });
  }
Exemple #25
0
  public void setupDBFields(String dbname) throws Exception {

    viewPane.setLayout(null);
    Dimension dimView = sp.getSize();
    int height = 0, width = 50;
    viewPane.removeAll();
    db = new DBF(dbname);
    setTitle(dbname);

    gb = new GridBagLayout();
    gbc = new GridBagConstraints();
    viewPane.setLayout(gb);

    int i, j;
    fldObjects = new Vector(db.getFieldCount());
    for (i = 1; i <= db.getFieldCount(); i++) {
      j = i - 1;
      f = db.getField(i);
      if (f.isMemoField() || f.isPictureField()) {
        b = new Button(db.getField(i).getName());
        b.addActionListener(this);
        addComponent(
            viewPane, b, 1, j, 1, 1, GridBagConstraints.HORIZONTAL, GridBagConstraints.EAST);
        fldObjects.addElement(b);
      } else if (f.getType() == 'L') {
        c = new Checkbox(db.getField(i).getName(), true);
        addComponent(
            viewPane, c, 1, j, 1, 1, GridBagConstraints.HORIZONTAL, GridBagConstraints.EAST);
        fldObjects.addElement(c);
      } else {
        l = new Label(db.getField(i).getName(), Label.RIGHT);
        addComponent(
            viewPane, l, 0, j, 1, 1, GridBagConstraints.HORIZONTAL, GridBagConstraints.EAST);
        int ln = f.getLength();
        if (ln > 100) {
          ln = 100;
        }
        t = new TextField(db.getField(i).getName(), ln);
        if (width < ln * 10) {
          width = ln * 10;
        }
        addComponent(
            viewPane, t, 1, j, ln, 1, GridBagConstraints.HORIZONTAL, GridBagConstraints.EAST);
        fldObjects.addElement(t);
        t.setEditable(true);
      }
      height += 10;
    }

    crl.setText("Record " + db.getCurrentRecordNumber());
    trl.setText(" of " + db.getRecordCount());
    SBrecpos.setMaximum(db.getRecordCount());
    addComponent(viewPane, crl, 0, i, 1, 1, GridBagConstraints.HORIZONTAL, GridBagConstraints.EAST);
    addComponent(viewPane, trl, 1, i, 1, 1, GridBagConstraints.HORIZONTAL, GridBagConstraints.EAST);
    i++;
    addComponent(
        viewPane, SBrecpos, 0, i, 2, 1, GridBagConstraints.HORIZONTAL, GridBagConstraints.EAST);
    addComponent(
        viewPane, delCB, 2, i, 1, 1, GridBagConstraints.HORIZONTAL, GridBagConstraints.EAST);
    i++;
    addComponent(
        viewPane, Prev, 0, i, 1, 1, GridBagConstraints.HORIZONTAL, GridBagConstraints.EAST);
    addComponent(
        viewPane, Next, 1, i, 1, 1, GridBagConstraints.HORIZONTAL, GridBagConstraints.EAST);
    i++;
    addComponent(viewPane, Add, 0, i, 1, 1, GridBagConstraints.HORIZONTAL, GridBagConstraints.EAST);
    addComponent(
        viewPane, Update, 1, i, 1, 1, GridBagConstraints.HORIZONTAL, GridBagConstraints.EAST);
    addComponent(
        viewPane, Clear, 2, i, 1, 1, GridBagConstraints.HORIZONTAL, GridBagConstraints.EAST);
    Prev.setEnabled(false);
    prevRecord.setEnabled(false);
    if (db.getRecordCount() == 0) {
      Update.setEnabled(false);
      updateRecord.setEnabled(false);
      Next.setEnabled(false);
      nextRecord.setEnabled(false);
    }

    dimView.setSize(width + 150, height + 150);
    sp.setSize(dimView);

    goTo(1);
  }
  public babylonServerWindow(babylonServer parent, String Name) {
    super(Name);
    server = parent;

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

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

    listening = new Label(server.strings.get(thisClass, "listenport") + " " + server.port);
    p.add(
        listening,
        new babylonConstraints(
            0,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.NORTHWEST,
            GridBagConstraints.NONE,
            new Insets(0, 0, 0, 0),
            0,
            0));

    logChat = new Checkbox(server.strings.get(thisClass, "logchats"), server.logChats);
    logChat.addItemListener(this);
    p.add(
        logChat,
        new babylonConstraints(
            1,
            0,
            1,
            1,
            1.0,
            1.0,
            GridBagConstraints.NORTHWEST,
            GridBagConstraints.NONE,
            new Insets(0, 0, 0, 0),
            0,
            0));

    userList = new List(4, false);
    userList.addItemListener(this);
    p.add(
        userList,
        new babylonConstraints(
            0,
            1,
            1,
            5,
            1.0,
            1.0,
            GridBagConstraints.NORTHWEST,
            GridBagConstraints.BOTH,
            new Insets(0, 0, 5, 0),
            0,
            0));

    userAdmin = new Button(server.strings.get(thisClass, "usermanagement"));
    userAdmin.addActionListener(this);
    p.add(
        userAdmin,
        new babylonConstraints(
            1,
            1,
            1,
            1,
            1.0,
            1.0,
            GridBagConstraints.NORTHWEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(0, 0, 0, 0),
            0,
            0));

    console = new Button(server.strings.get(thisClass, "adminclient"));
    console.addActionListener(this);
    p.add(
        console,
        new babylonConstraints(
            1,
            2,
            1,
            1,
            1.0,
            1.0,
            GridBagConstraints.NORTHWEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(0, 0, 0, 0),
            0,
            0));

    disconnect = new Button(server.strings.get(thisClass, "disconnectuser"));
    disconnect.setEnabled(false);
    disconnect.addActionListener(this);
    p.add(
        disconnect,
        new babylonConstraints(
            1,
            3,
            1,
            1,
            1.0,
            1.0,
            GridBagConstraints.NORTHWEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(0, 0, 0, 0),
            0,
            0));

    disconnectAll = new Button(server.strings.get(thisClass, "disconnectall"));
    disconnectAll.setEnabled(false);
    disconnectAll.addActionListener(this);
    p.add(
        disconnectAll,
        new babylonConstraints(
            1,
            4,
            1,
            1,
            1.0,
            1.0,
            GridBagConstraints.NORTHWEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(0, 0, 0, 0),
            0,
            0));

    shutdown = new Button(server.strings.get(thisClass, "shutdown"));
    shutdown.addActionListener(this);
    p.add(
        shutdown,
        new babylonConstraints(
            1,
            5,
            1,
            1,
            1.0,
            1.0,
            GridBagConstraints.NORTHWEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(0, 0, 0, 0),
            0,
            0));

    stats =
        new TextField(
            server.strings.get(thisClass, "connectionscurrent")
                + " 0  "
                + server.strings.get(thisClass, "connectionspeak")
                + " 0  "
                + server.strings.get(thisClass, "connectionstotal")
                + " 0",
            40);
    stats.setEditable(false);
    p.add(
        stats,
        new babylonConstraints(
            0,
            7,
            2,
            1,
            1.0,
            1.0,
            GridBagConstraints.NORTHWEST,
            GridBagConstraints.BOTH,
            new Insets(0, 0, 0, 0),
            0,
            0));

    logWindow =
        new TextArea(
            server.strings.get(thisClass, "activitylog") + "\n",
            10,
            40,
            TextArea.SCROLLBARS_VERTICAL_ONLY);
    logWindow.setEditable(false);
    p.add(
        logWindow,
        new babylonConstraints(
            0,
            8,
            2,
            1,
            1.0,
            1.0,
            GridBagConstraints.NORTHWEST,
            GridBagConstraints.BOTH,
            new Insets(0, 0, 5, 0),
            0,
            0));

    canvas = new babylonPictureCanvas(this);
    p.add(
        canvas,
        new babylonConstraints(
            0,
            9,
            2,
            1,
            1.0,
            1.0,
            GridBagConstraints.NORTHWEST,
            GridBagConstraints.BOTH,
            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));

    try {
      URL url = new URL("file", "localhost", "babylonPic.jpg");
      Image image = getToolkit().getImage(url);

      canvas.setimage(image);
    } catch (Exception e) {
      System.out.println(e);
    }

    try {
      URL iconUrl = new URL("file", "localhost", "babylonIcon.jpg");
      ImageIcon icon = new ImageIcon(iconUrl);
      this.setIconImage(icon.getImage());
    } catch (Exception e) {
      /* Not important */
    }

    addWindowListener(this);

    setSize(600, 600);
    pack();
  }
  public babylonServerShutdownDialog(babylonServerWindow serverWindow, babylonServer theServer) {
    super(serverWindow, theServer.strings.get(babylonServerWindow.class, "servershutdown"), true);
    parentWindow = serverWindow;
    server = theServer;

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

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

    message1 = new Label(server.strings.get(babylonServerWindow.class, "areyousure1"));
    p.add(
        message1,
        new babylonConstraints(
            0,
            0,
            2,
            1,
            0.0,
            0.0,
            GridBagConstraints.NORTHWEST,
            GridBagConstraints.NONE,
            new Insets(0, 0, 0, 0),
            0,
            0));

    message2 = new Label(server.strings.get(babylonServerWindow.class, "areyousure2"));
    p.add(
        message2,
        new babylonConstraints(
            0,
            1,
            2,
            1,
            0.0,
            0.0,
            GridBagConstraints.NORTHWEST,
            GridBagConstraints.NONE,
            new Insets(0, 0, 0, 0),
            0,
            0));

    yes = new Button(server.strings.get(babylonServerWindow.class, "yes"));
    yes.addKeyListener(this);
    yes.addActionListener(this);
    p.add(
        yes,
        new babylonConstraints(
            0,
            2,
            1,
            1,
            1.0,
            1.0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(0, 0, 0, 0),
            0,
            0));

    cancel = new Button(server.strings.get("cancel"));
    cancel.addKeyListener(this);
    cancel.addActionListener(this);
    p.add(
        cancel,
        new babylonConstraints(
            1,
            2,
            1,
            1,
            1.0,
            1.0,
            GridBagConstraints.WEST,
            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.NONE,
            new Insets(5, 5, 5, 5),
            0,
            0));

    setBackground(Color.lightGray);
    pack();
    setResizable(false);
    parentWindow.centerDialog(this);

    addKeyListener(this);
    addWindowListener(this);
    setVisible(true);
    yes.requestFocus();
  }
Exemple #28
0
  RecordingFrame(VncViewer v) {
    super("Teambox Screen Sharing Session Recording");

    viewer = v;

    // Determine initial filename for next saved session.
    // FIXME: Check SecurityManager.

    String fname =
        nextNewFilename(
            System.getProperty("user.dir")
                + System.getProperty("file.separator")
                + "vncsession.fbs");

    // Construct new panel with file name field and "Browse" button.

    Panel fnamePanel = new Panel();
    GridBagLayout fnameGridbag = new GridBagLayout();
    fnamePanel.setLayout(fnameGridbag);

    GridBagConstraints fnameConstraints = new GridBagConstraints();
    fnameConstraints.gridwidth = GridBagConstraints.RELATIVE;
    fnameConstraints.fill = GridBagConstraints.BOTH;
    fnameConstraints.weightx = 4.0;

    fnameField = new TextField(fname, 64);
    fnameGridbag.setConstraints(fnameField, fnameConstraints);
    fnamePanel.add(fnameField);
    fnameField.addActionListener(this);

    fnameConstraints.gridwidth = GridBagConstraints.REMAINDER;
    fnameConstraints.weightx = 1.0;

    browseButton = new Button("Browse");
    fnameGridbag.setConstraints(browseButton, fnameConstraints);
    fnamePanel.add(browseButton);
    browseButton.addActionListener(this);

    // Construct the frame.

    GridBagLayout gridbag = new GridBagLayout();
    setLayout(gridbag);

    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbc.fill = GridBagConstraints.BOTH;
    gbc.weighty = 1.0;
    gbc.insets = new Insets(10, 0, 0, 0);

    Label helpLabel = new Label("File name to save next recorded session in:", Label.CENTER);
    gridbag.setConstraints(helpLabel, gbc);
    add(helpLabel);

    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.weighty = 0.0;
    gbc.insets = new Insets(0, 0, 0, 0);

    gridbag.setConstraints(fnamePanel, gbc);
    add(fnamePanel);

    gbc.fill = GridBagConstraints.BOTH;
    gbc.weighty = 1.0;
    gbc.insets = new Insets(10, 0, 10, 0);

    statusLabel = new Label("", Label.CENTER);
    gridbag.setConstraints(statusLabel, gbc);
    add(statusLabel);

    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.weightx = 1.0;
    gbc.weighty = 0.0;
    gbc.gridwidth = 1;
    gbc.insets = new Insets(0, 0, 0, 0);

    recordButton = new Button("Record");
    gridbag.setConstraints(recordButton, gbc);
    add(recordButton);
    recordButton.addActionListener(this);

    nextButton = new Button("Next file");
    gridbag.setConstraints(nextButton, gbc);
    add(nextButton);
    nextButton.addActionListener(this);

    closeButton = new Button("Close");
    gridbag.setConstraints(closeButton, gbc);
    add(closeButton);
    closeButton.addActionListener(this);

    // Set correct text, font and color for the statusLabel.
    stopRecording();

    pack();

    addWindowListener(this);
  }
Exemple #29
0
  /**
   * If 'applet' is not null, creates a new ImageJ frame that runs as an applet. If 'mode' is
   * ImageJ.EMBEDDED and 'applet is null, creates an embedded (non-standalone) version of ImageJ.
   */
  public ImageJ(java.applet.Applet applet, int mode) {
    super("ImageJ");
    if ((mode & DEBUG) != 0) IJ.setDebugMode(true);
    mode = mode & 255;
    if (IJ.debugMode) IJ.log("ImageJ starting in debug mode: " + mode);
    embedded = applet == null && (mode == EMBEDDED || mode == NO_SHOW);
    this.applet = applet;
    String err1 = Prefs.load(this, applet);
    setBackground(backgroundColor);
    Menus m = new Menus(this, applet);
    String err2 = m.addMenuBar();
    m.installPopupMenu(this);
    setLayout(new BorderLayout());

    // Tool bar
    toolbar = new Toolbar();
    toolbar.addKeyListener(this);
    add("Center", toolbar);

    // Status bar
    statusBar = new Panel();
    statusBar.setLayout(new BorderLayout());
    statusBar.setForeground(Color.black);
    statusBar.setBackground(backgroundColor);
    statusLine = new JLabel();
    statusLine.setFont(new Font("SansSerif", Font.PLAIN, 13));
    statusLine.addKeyListener(this);
    statusLine.addMouseListener(this);
    statusBar.add("Center", statusLine);
    progressBar = new ProgressBar(120, 20);
    progressBar.addKeyListener(this);
    progressBar.addMouseListener(this);
    statusBar.add("East", progressBar);
    add("South", statusBar);

    IJ.init(this, applet);
    addKeyListener(this);
    addWindowListener(this);
    setFocusTraversalKeysEnabled(false);
    m.installStartupMacroSet(); // add custom tools
    runStartupMacro();

    Point loc = getPreferredLocation();
    Dimension tbSize = toolbar.getPreferredSize();
    setCursor(Cursor.getDefaultCursor()); // work-around for JDK 1.1.8 bug
    if (mode != NO_SHOW) {
      if (IJ.isWindows())
        try {
          setIcon();
        } catch (Exception e) {
        }
      setLocation(loc.x, loc.y);
      setResizable(!IJ.isMacOSX());
      pack();
      setVisible(true);
    }
    if (err1 != null) IJ.error(err1);
    if (err2 != null) {
      IJ.error(err2);
      IJ.runPlugIn("ij.plugin.ClassChecker", "");
    }
    if (IJ.isMacintosh() && applet == null) {
      Object qh = null;
      qh = IJ.runPlugIn("MacAdapter", "");
      if (qh == null) IJ.runPlugIn("QuitHandler", "");
    }
    if (applet == null) IJ.runPlugIn("ij.plugin.DragAndDrop", "");
    String str = m.getMacroCount() == 1 ? " macro" : " macros";
    IJ.showStatus(version() + m.getPluginCount() + " commands; " + m.getMacroCount() + str);
    configureProxy();
    if (applet == null) loadCursors();
  }
  public NslDimValue(
      NslFrame nsl_display_frame,
      String var_sel_full_name,
      NslVariableInfo var_sel_info,
      String plot_type_name,
      boolean replace_canvas) {
    super(nsl_display_frame, "Enter Values", true);

    /* these variables are needed in the action method */
    this.nsl_display_frame = nsl_display_frame;
    this.var_sel_full_name = var_sel_full_name;
    this.var_sel_info = var_sel_info;
    this.plot_type_name = plot_type_name;
    this.replace_canvas = replace_canvas;

    num_dims = (var_sel_info.getCountDimensions());

    if ((num_dims == 0) || (num_dims == 1) || (num_dims == 2) || (num_dims >= 4)) {
      System.err.println("Error: NslDimValue: should not have gotten here in the code.");
      return;
    }

    Panel p = new Panel();
    if (num_dims == 3) {
      if (NslDimInput.dim_choice.equals("HI")) {
        addEnterOneValue(p, "J");
      } else if (NslDimInput.dim_choice.equals("HJ")) {
        addEnterOneValue(p, "I");
      } else if (NslDimInput.dim_choice.equals("IJ")) {
        addEnterOneValue(p, "H");
      } else {
        System.err.println("Error: NslDimVal: bad input choice.");
        dispose();
        return;
      }
    } // end if (num_dims==3)
    else if (num_dims == 4) {
      if (NslDimInput.dim_choice.equals("GH")) {
        addEnterTwoValues(p, "I", "J");
      } else if (NslDimInput.dim_choice.equals("GI")) {
        addEnterTwoValues(p, "H", "J");
      } else if (NslDimInput.dim_choice.equals("GJ")) {
        addEnterTwoValues(p, "H", "I");
      } else if (NslDimInput.dim_choice.equals("HI")) {
        addEnterTwoValues(p, "G", "J");
      } else if (NslDimInput.dim_choice.equals("HJ")) {
        addEnterTwoValues(p, "G", "I");
      } else if (NslDimInput.dim_choice.equals("IJ")) {
        addEnterTwoValues(p, "G", "H");
      } else {
        System.err.println("Error: NslDimVal:bad input choice");
        dispose();
        return;
      }
    } // end if (num_dims==4)

    add("Center", p);

    Button b;
    Panel p4 = new Panel();
    p4.setLayout(new GridLayout(1, 5));
    p4.add(b = new Button("<Back"));
    b.addActionListener(this);
    p4.add(new Label(""));
    p4.add(b = new Button("Cancel"));
    b.addActionListener(this);
    p4.add(new Label(""));
    p4.add(b = new Button("Next>"));
    b.addActionListener(this);
    add("South", p4);
    setSize(450, 180);
  } // end constructor