public void show() {

    dlg =
        new DialogDescriptor(
            this,
            NbBundle.getMessage(this.getClass(), "CLIENT_EXCEPTION"),
            false,
            NotifyDescriptor.OK_CANCEL_OPTION,
            DialogDescriptor.OK_OPTION,
            DialogDescriptor.DEFAULT_ALIGN,
            this.getHelpCtx(),
            null);
    dlg.setOptions(new Object[] {okButton});
    dialog = DialogDisplayer.getDefault().createDialog(dlg);
    dialog.setPreferredSize(new java.awt.Dimension(500, 300));
    dialog.show();
  }
示例#2
0
  public void makeTheWarning(
      int X,
      int Y,
      int width,
      int height,
      Color fg,
      Color bg,
      String title,
      String text,
      boolean oneLine,
      Frame frame) {

    Font warnFont = new java.awt.Font("SanSerif", Font.BOLD, 12);
    FontMetrics warnFontMetrics = getFontMetrics(warnFont);

    // Create Dialog window with modal blocking set to true.
    // Make final so inner class below can access it.

    final Dialog mww = new Dialog(frame, title, true);
    mww.setLayout(new BorderLayout());
    mww.setSize(width, height);
    mww.setLocation(X, Y);

    // Use Label for 1-line warning

    if (oneLine) {
      Label hT = new Label(text, Label.CENTER);
      hT.setForeground(fg);
      hT.setBackground(bg);
      hT.setFont(warnFont);
      mww.add("Center", hT);

      // Use TextArea for multiline warning

    } else {
      TextArea hT = new TextArea("", height, width, TextArea.SCROLLBARS_NONE);
      hT.setEditable(false);
      hT.setForeground(fg);
      hT.setBackground(bg); // no effect once setEditable (false)?
      hT.setFont(warnFont);
      mww.add("Center", hT);
      hT.appendText(text);
    }

    mww.setTitle(title);

    // Add dismiss button

    Panel botPanel = new Panel();
    botPanel.setBackground(Color.lightGray);
    Label label1 = new Label();
    Label label2 = new Label();

    Button dismissButton = new Button("Dismiss");
    botPanel.add(label1);
    botPanel.add(dismissButton);
    botPanel.add(label2);

    // Add inner class event handler for Dismiss button.  This must be
    // added to the dismissButton before botPanel is added to mww.

    dismissButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            mww.hide();
            mww.dispose();
          }
        });

    mww.add("South", botPanel);

    // Add window closing button (inner class)

    mww.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            mww.hide();
            mww.dispose();
          }
        });

    mww.show(); // Note that this show must come after all the above
    // additions; otherwise they are not added before the
    // window is displayed.
  }
示例#3
0
 public void actionPerformed(ActionEvent e) {
   Dialog d = new ToeDialog(Integer.parseInt(rows.getText()), Integer.parseInt(cols.getText()));
   d.show();
 }
示例#4
0
  public static int crossOver(int version, JoConnection conn, Config config) throws Exception {
    Dialog dlg = null;
    try {
      if (version < 1002) {
        // ----------------------------------------------------
        //  New Columns GamePlayer.Color and GamePlayer.Result
        // ----------------------------------------------------

        dlg =
            JoDialog.createMessageDialog(
                "Database Update",
                "jose will now update the database structure.\n"
                    + "This may take up to some minutes.",
                false);
        dlg.show();
        dlg.paint(dlg.getGraphics());

        Setup setup = new Setup(config, "MAIN", conn);
        /*
        				setup.addColumn("GamePlayer","Color",3);
        				setup.addColumn("GamePlayer","Result",4);
        /*
        					alter table gameplayer
        					modify column PId integer not null,
        					add column Color tinyint not null,
        					add index GamePlayer_3 (Color),
        					add column Result tinyint not null,
        					add index GamePlayer_4 (Result)
        * /
        				//  fill in values
        				String upd1 =
        				        "UPDATE GamePlayer, Game" +
        				        " SET GamePlayer.Color = 1, GamePlayer.Result = Game.Result" +
        				        " WHERE GamePlayer.GId = Game.Id" +
        				        "   AND GamePlayer.PId = Game.WhiteId";
        				/** Color = 1 = White
        				 *  Result = Game.Result (from white's perspective)
        				 * /
        				conn.executeUpdate(upd1);

        				String upd2 =
        				        "UPDATE GamePlayer, Game" +
        				        " SET GamePlayer.Result = CASE WHEN Game.Result < 0 THEN Game.Result ELSE 2-Game.Result END" +
        				        " WHERE GamePlayer.GId = Game.Id" +
        				        "   AND GamePlayer.PId = Game.BlackId";
        				/** Color = 0 = Black
        				 *  Result = 2-Game.Result (from black's perspective)
        				 * /
        				conn.executeUpdate(upd2);
        */
        System.err.print("[create GamePlayer");
        try {
          setup.dropTable("GamePlayer");
        } catch (Exception e) {
          Application.error(e);
        }

        setup.createTable(null, setup.getTable("GamePlayer"), null, true);
        JoConnection.getAdapter().disableConstraints("GamePlayer", conn);

        String ins =
            "INSERT INTO GamePlayer"
                + " SELECT Id, WhiteId, 1, Result FROM Game "
                + " UNION"
                + " SELECT Id, BlackId, 0, CASE WHEN Result<0 THEN Result ELSE 2-Result END FROM Game";

        conn.executeUpdate(ins);
        JoConnection.getAdapter().enableConstraints("GamePlayer", conn);
        System.err.println("]");

        Setup.setTableVersion(conn, "MAIN", "GamePlayer", 102);
        Setup.setSchemaVersion(conn, "MAIN", version = 1002);
      }

      return version;

    } finally {
      if (dlg != null) dlg.dispose();
    }
  }