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);
  }
  public Panel getAccordionNav() {
    Panel accordion = new Panel();
    accordion.setTitle("Accordion");
    accordion.setLayout(new AccordionLayout(true));

    Store store = getStore();

    Record[] records = store.getRecords();
    for (int i = 0; i < records.length; i++) {
      Record record = records[i];

      String id = record.getAsString("id");
      final String category = record.getAsString("category");
      String title = record.getAsString("title");
      final String iconCls = record.getAsString("iconCls");

      String thumbnail = record.getAsString("thumbnail");
      String qtip = record.getAsString("qtip");

      final ShowcasePanel panel = (ShowcasePanel) record.getAsObject("screen");

      if (category == null) {
        Panel categoryPanel = new Panel();
        categoryPanel.setAutoScroll(true);
        categoryPanel.setLayout(new FitLayout());
        categoryPanel.setId(id + "-acc");
        categoryPanel.setTitle(title);
        categoryPanel.setIconCls(iconCls);
        accordion.add(categoryPanel);
      } else {
        Panel categoryPanel = (Panel) accordion.findByID(category + "-acc");
        TreePanel treePanel = (TreePanel) categoryPanel.findByID(category + "-acc-tree");
        TreeNode root = null;
        if (treePanel == null) {
          treePanel = new TreePanel();
          treePanel.setAutoScroll(true);
          treePanel.setId(category + "-acc-tree");
          treePanel.setRootVisible(false);
          root = new TreeNode();
          treePanel.setRootNode(root);
          categoryPanel.add(treePanel);
        } else {
          root = treePanel.getRootNode();
        }

        TreeNode node = new TreeNode();
        node.setText(title);
        node.setId(id);
        if (iconCls != null) node.setIconCls(iconCls);
        if (qtip != null) node.setTooltip(qtip);
        root.appendChild(node);

        addNodeClickListener(node, panel, iconCls);
      }
    }

    return accordion;
  }
Exemple #5
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++;
 }
  // 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);
          }
        });
  }
  /** 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();
  }
Exemple #8
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();
 }
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++;
 }
  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 #12
0
  public CollageList() {
    super();

    actionComponent = new Button();

    Panel toolBar;

    setLayout(new BorderLayout());
    //		ggHScroll	= new Scrollbar( Scrollbar.HORIZONTAL, 0, 0x8000, 0, 0x8000 );
    ggVScroll = new Scrollbar(Scrollbar.VERTICAL, 0, 0x8000, 0, 0x8000);
    //		ggHScroll.addAdjustmentListener( ggCurve );
    ggVScroll.addAdjustmentListener(this);

    toolBar = new Panel();
    toolBar.setLayout(new FlowLayout(FlowLayout.LEFT, 2, 2));
    ggAdd = new JButton("    Add    ");
    ggDel = new JButton("  Delete  ");
    ggDup = new JButton(" Duplicate ");
    ggAdd.addActionListener(this);
    ggDel.addActionListener(this);
    ggDup.addActionListener(this);
    toolBar.add(ggAdd);
    toolBar.add(ggDel);
    toolBar.add(ggDup);

    add(toolBar, BorderLayout.NORTH);
    //		add( ggHScroll, BorderLayout.SOUTH );
    add(ggVScroll, BorderLayout.EAST);
    add(new CollageCanvas(this), BorderLayout.CENTER);
    //		add( ggCurve,   BorderLayout.CENTER );
  }
 public ButtonPanel() {
   int buttonPanelOrient = FlowLayout.CENTER;
   setLayout(new BorderLayout(0, 5));
   buttonPanelOrient = FlowLayout.CENTER;
   buttonPanel.setLayout(new FlowLayout(buttonPanelOrient));
   add(separator, "North");
   add(buttonPanel, "Center");
 }
  AssignReferencesCheckboxPanel() {

    setBackground(Color.lightGray);

    setLayout(new GridLayout(1, 3));
    Panel p = new Panel();
    p.setLayout(new FlowLayout());
    p.add(new Checkbox(HeapOfFishStrings.moveFish, cbg, false));
    add(p);
    p = new Panel();
    p.setLayout(new FlowLayout());
    p.add(new Checkbox(HeapOfFishStrings.linkFish, cbg, true));
    add(p);
    p = new Panel();
    p.setLayout(new FlowLayout());
    p.add(new Checkbox(HeapOfFishStrings.unlinkFish, cbg, false));
    add(p);
  }
Exemple #15
0
  /**
   * Create a new wizard page.
   *
   * @param prPage which is the previous page. Useful only with interactive multi-paged wizards.
   *     Usually set just to previous page.
   */
  public wizPage(int prPage) {
    pOptions = new Panel();

    setLayout(new BorderLayout());
    pOptions.setLayout(new WizardLayout()); // the LayoutManager of the wizard page

    add("Center", pOptions);
    canFinish = false;
  }
 /** 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 void buildChooser() {
   Panel panel = new Panel();
   panel.setLayout(new GridLayout());
   for (int i = 1; i <= 3; i++) {
     for (int x = 1; x <= 2; x++) {
       panel.add(addButton(i * x + "", Color.yellow));
     }
   }
   add(panel);
 }
  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 #20
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();
 }
  /**
   * I Layout sono 3 intanto Layout esterno: è di tipo Border e ordina banner a nord e tastiera a
   * sud Layout del banner: è di tipo Border e ordina messaggio e casella di testo Layout tastiera:
   * è ovviamente una grid.
   */
  public void init() { // DICHIARO GLI OGGETTI DELLA APPLET, DEI PANNELLI. LI AGGIUNGO A QUESTA

    setLayout(new BorderLayout());

    Panel banner = new Panel();
    banner.setLayout(new BorderLayout());
    banner.setBackground(Color.RED);

    Label titolo = new Label("benvenuto in pCalc");
    banner.add(titolo, BorderLayout.NORTH);

    TextField risultato = new TextField(30);
    banner.add(risultato, BorderLayout.SOUTH);

    Panel tastiera = new Panel();
    tastiera.setLayout(new GridLayout(3, 3));

    Button tasto0 = new Button("0");
    tastiera.add(tasto0);
    Button tasto1 = new Button("1");
    tastiera.add(tasto1);
    Button tasto2 = new Button("2");
    tastiera.add(tasto2);
    Button tasto3 = new Button("3");
    tastiera.add(tasto3);
    Button tasto4 = new Button("4");
    tastiera.add(tasto4);
    Button tasto5 = new Button("5");
    tastiera.add(tasto5);
    Button tasto6 = new Button("6");
    tastiera.add(tasto6);
    Button tasto7 = new Button("7");
    tastiera.add(tasto7);
    Button tasto8 = new Button("8");
    tastiera.add(tasto8);
    Button tasto9 = new Button("9");
    tastiera.add(tasto9);

    add(banner, BorderLayout.NORTH);
    add(tastiera, BorderLayout.SOUTH);
  }
Exemple #22
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 #23
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++;
 }
Exemple #24
0
  /**
   * This method is called from within the constructor to initialize the form. WARNING: Do NOT
   * modify this code. The content of this method is always regenerated by the Form Editor.
   */
  @SuppressWarnings("unchecked")
  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  private void initComponents() {

    Panel = new javax.swing.JPanel();
    graphPanel = new javax.swing.JPanel();

    setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
    setResizable(false);

    graphPanel.setMinimumSize(new java.awt.Dimension(450, 216));
    graphPanel.setPreferredSize(new java.awt.Dimension(450, 216));
    graphPanel.setRequestFocusEnabled(false);
    graphPanel.setLayout(new java.awt.GridLayout(1, 0));

    javax.swing.GroupLayout PanelLayout = new javax.swing.GroupLayout(Panel);
    Panel.setLayout(PanelLayout);
    PanelLayout.setHorizontalGroup(
        PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(graphPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 480, Short.MAX_VALUE));
    PanelLayout.setVerticalGroup(
        PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(
                graphPanel,
                javax.swing.GroupLayout.Alignment.TRAILING,
                javax.swing.GroupLayout.DEFAULT_SIZE,
                263,
                Short.MAX_VALUE));

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
        layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(
                Panel,
                javax.swing.GroupLayout.DEFAULT_SIZE,
                javax.swing.GroupLayout.DEFAULT_SIZE,
                Short.MAX_VALUE));
    layout.setVerticalGroup(
        layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(
                Panel,
                javax.swing.GroupLayout.DEFAULT_SIZE,
                javax.swing.GroupLayout.DEFAULT_SIZE,
                Short.MAX_VALUE));

    pack();
  } // </editor-fold>//GEN-END:initComponents
  public static void main(String[] args) {
    Frame MiMarco = new Frame();
    Panel MiPanel = new Panel();
    GridLayout Matriz = new GridLayout(2, 3);

    Button[] Botones = new Button[6];
    for (int i = 0; i < 6; i++) Botones[i] = new Button("Botón " + i);

    MiPanel.setLayout(Matriz);
    for (int i = 0; i < 6; i++) MiPanel.add(Botones[i]);

    MiMarco.add(MiPanel);
    MiMarco.setSize(300, 100);
    MiMarco.setTitle("Ventana con GridLayout");
    MiMarco.setVisible(true);
  }
 /* 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 #27
0
 public ListFrame(String title, int row, int col, Applet ma, boolean multiple, Font ft) {
   super();
   myApplet = ma;
   this.setTitle(title);
   setLayout(new BorderLayout());
   panel = new Panel();
   panel.setLayout(new FlowLayout(FlowLayout.LEFT));
   nLists = 1;
   list = new List[1];
   list[0] = new List(row, multiple);
   list[0].setFont(ft);
   panel.add(list[0]);
   add("Center", panel);
   this.setResizable(true);
   this.resize(minimumSize);
   selectedIndices = new int[1][];
 }
Exemple #28
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;
 }