/**
   * @param owner the owner of this component
   * @param maxVersion the maximum version number which is valid
   */
  public CheckOutVersionDialog(Frame owner, int maxVersion) {
    super(owner, true);

    this.maxVersion = maxVersion;
    parentFrame = owner;

    versionTF = new JTextField(5);

    okButton = new JButton("Ok");
    okButton.addActionListener(this);

    JPanel versionPanel = new JPanel();
    JPanel buttonPanel = new JPanel();

    versionPanel.add(new JLabel("Version number to check out: "));
    versionPanel.add(versionTF);

    buttonPanel.add(okButton);

    getContentPane().setLayout(new BorderLayout());
    getContentPane().add(versionPanel, BorderLayout.CENTER);
    getContentPane().add(buttonPanel, BorderLayout.SOUTH);

    setLocation((int) owner.getLocation().getX() + 100, (int) owner.getLocation().getY() + 100);
    pack();
  }
Beispiel #2
0
  public UserInfoDialog(Frame parent) {
    super(parent, "Input", true);
    setLayout(null);

    l.setFont(default_font);
    l.setSize(50, 30);
    l.setLocation(30, 50);

    name.setFont(default_font);
    name.setSize(150, 30);
    name.setLocation(90, 50);
    // name.selectAll();

    ok.setFont(default_font);
    ok.setSize(50, 30);
    ok.setLocation(30, 90);

    add(l);
    add(name);
    add(ok);
    ok.addActionListener(this);
    setSize(300, 150);

    Point my_loc = parent.getLocation();
    my_loc.x += 50;
    my_loc.y += 150;
    setLocation(my_loc);
    show();
  }
Beispiel #3
0
 private void saveWindowState(String key, Frame frame) {
   if ((frame.getExtendedState() & Frame.MAXIMIZED_BOTH) == 0) {
     preferences.putInt(key + "-x", frame.getLocation().x);
     preferences.putInt(key + "-y", frame.getLocation().y);
     preferences.putInt(key + "-width", frame.getSize().width);
     preferences.putInt(key + "-height", frame.getSize().height);
   }
 }
Beispiel #4
0
  public static void translateToScreen(Event event) {
    Assert.isTrue(event.target instanceof Component);

    Frame frame = getFrame((Component) event.target);
    event.translate(
        frame.getLocation().x + frame.getInsets().left,
        frame.getLocation().y + frame.getInsets().top);
  }
Beispiel #5
0
  public MailDialog(Frame owner, String title, boolean modal) {
    super(owner, title, modal);

    Point p = owner.getLocation();
    this.setLocation(p.x + 50, p.y + 50);

    strings = ResourceBundle.getBundle("org.pegadi.maildialog.MailDialogStrings");

    createUI();
  }
Beispiel #6
0
 void saveWindowLocations() {
   Frame frame = WindowManager.getFrame("B&C");
   if (frame != null) Prefs.saveLocation(ContrastAdjuster.LOC_KEY, frame.getLocation());
   frame = WindowManager.getFrame("Threshold");
   if (frame != null) Prefs.saveLocation(ThresholdAdjuster.LOC_KEY, frame.getLocation());
   frame = WindowManager.getFrame("Results");
   if (frame != null) {
     Prefs.saveLocation(TextWindow.LOC_KEY, frame.getLocation());
     Dimension d = frame.getSize();
     Prefs.set(TextWindow.WIDTH_KEY, d.width);
     Prefs.set(TextWindow.HEIGHT_KEY, d.height);
   }
   frame = WindowManager.getFrame("Log");
   if (frame != null) {
     Prefs.saveLocation(TextWindow.LOG_LOC_KEY, frame.getLocation());
     Dimension d = frame.getSize();
     Prefs.set(TextWindow.LOG_WIDTH_KEY, d.width);
     Prefs.set(TextWindow.LOG_HEIGHT_KEY, d.height);
   }
 }
Beispiel #7
0
 /**
  * Centre the dialog box in the frame. This must be called after the size has been established,
  * i.e. after the buttons etc. are arranged and pack() is called
  */
 public void centreInFrame() {
   Dimension frame_size = parent.getSize();
   Point frame_location = parent.getLocation();
   int centre_x = frame_location.x + frame_size.width / 2;
   int centre_y = frame_location.y + frame_size.height / 2;
   ;
   int xloc = centre_x - this.getSize().width / 2;
   int yloc = centre_y - this.getSize().height / 2;
   this.setLocation(new Point(xloc, yloc));
   this.requestFocus();
 }
Beispiel #8
0
  public static void openAbout(Frame frame, String product, String version) {

    AboutDialog aboutDialog = new AboutDialog(frame, true, product, version);
    Dimension frameSize = frame.getSize();
    Dimension aboutSize = aboutDialog.getSize();
    int x = frame.getLocation().x + (frameSize.width - aboutSize.width) / 2;
    int y = frame.getLocation().y + (frameSize.height - aboutSize.height) / 2;
    if (x < 0) x = 0;
    if (y < 0) y = 0;
    aboutDialog.setLocation(x, y);
    aboutDialog.setVisible(true);
  }
  public int showDialog(Frame parentWindow, Throwable error) {
    if (this._dialog != null) {
      throw new IllegalStateException("CustomOreGen Config Error Dialog is already open!");
    } else {
      this._dialog = new Dialog(parentWindow, "CustomOreGen Config Error", false);
      this._dialog.addWindowListener(this);
      TextArea text = new TextArea(this.getMessage(error), 30, 120, 1);
      text.setEditable(false);
      text.setBackground(Color.WHITE);
      text.setFont(new Font("Monospaced", 0, 12));
      this._dialog.add(text);
      Panel buttonPanel = new Panel();
      this._abort = new Button("Abort");
      this._abort.addActionListener(this);
      buttonPanel.add(this._abort);
      this._retry = new Button("Retry");
      this._retry.addActionListener(this);
      buttonPanel.add(this._retry);
      this._ignore = new Button("Ignore");
      this._ignore.addActionListener(this);
      buttonPanel.add(this._ignore);
      buttonPanel.setLayout(new BoxLayout(buttonPanel, 0));
      this._dialog.add(buttonPanel);
      this._dialog.setLayout(new BoxLayout(this._dialog, 1));
      this._dialog.pack();
      Point loc = parentWindow.getLocation();
      Dimension parentSize = parentWindow.getSize();
      Dimension size = this._dialog.getSize();
      loc.x += (parentSize.width - size.width) / 2;
      loc.y += (parentSize.height - size.height) / 2;
      this._dialog.setLocation(loc);
      this._waiting = true;
      this._returnVal = 0;
      this._dialog.setVisible(true);
      boolean usingLWJGL = false; // CustomOreGenBase.isClassLoaded("org.lwjgl.opengl.Display");

      while (this._waiting) {
        if (usingLWJGL && Display.isCreated()) {
          Display.processMessages();
        }
      }

      this._abort = null;
      this._retry = null;
      this._ignore = null;
      this._dialog.setVisible(false);
      this._dialog.dispose();
      this._dialog = null;
      return this._returnVal;
    }
  }
  private static Point getAppropriateLocation(Frame owner, Point position) {
    Point result = new Point(position);
    Point p = owner.getLocation();
    int offsetX = (position.x + width) - (p.x + owner.getWidth());
    int offsetY = (position.y + height) - (p.y + owner.getHeight());

    if (offsetX > 0) {
      result.x -= offsetX;
    }

    if (offsetY > 0) {
      result.y -= offsetY;
    }
    return result;
  }
  public RemovePackageDialog(Frame parent, String title, boolean modal, Properties properties) {
    super(parent, title, modal);

    i18n = I18nManager.getI18nManager("i18n/JacmanLabels", Locale.getDefault());
    jacmanProperties = properties;

    sortedPackages = new SortedList(packageEventList, new PackageComparitor());
    FilterList textFilteredIssues =
        new FilterList(
            sortedPackages, new TextComponentMatcherEditor(txtSearch, new PackageTextFilterator()));

    String[] propertyNames = {"name", "version", "description", "size"};
    String[] columnNames = {
      i18n.getString("PackageTableColumnName"),
      i18n.getString("PackageTableColumnInstalledVer"),
      i18n.getString("PackageTableColumnDescription"),
      i18n.getString("PackageTableColumnSize")
    };

    checkableTableFormat =
        new CheckableTableFormat(
            new BeanTableFormat(InstalledPacmanPkg.class, propertyNames, columnNames));
    packagesTableModel = new EventTableModel(textFilteredIssues, checkableTableFormat);

    if (parent != null) this.setLocation(parent.getLocation());
    setupGUI();

    final InfiniteProgressPanel pane =
        new InfiniteProgressPanel(i18n.getString("LoadingPackagesMessage"));
    setGlassPane(pane);
    validate();
    pane.start();
    SwingWorker worker =
        new SwingWorker() {
          public Object construct() {

            Jacman.findInstalledPackages(packageEventList);
            return "done";
          }

          public void finished() {
            JacmanUtils.setOptimalTableWidth(getPackageListTable());
            pane.stop();
          }
        };
    worker.start();
  }
  public CodeGenOptionsDialog(Frame parent, CodeGenConfig codeGenConfig, boolean modal)
      throws HeadlessException {
    super(parent, "Code Generation Options", modal);
    setDefaultCloseOperation(DISPOSE_ON_CLOSE);
    if (parent != null) {
      Dimension parentSize = parent.getSize();
      Point p = parent.getLocation();
      setLocation(p.x + parentSize.width / 4, p.y + parentSize.height / 4);
    }

    this.codeGenConfig = codeGenConfig;
    form = new CodeGenOptionsForm();
    getContentPane().add(form, BorderLayout.CENTER);
    setSize(550, 240);
    form.m_textRootOut.setText(codeGenConfig.getRootOut());
    form.m_textPackage.setText(codeGenConfig.getBasePackage());
    form.m_textCatalog.setText(codeGenConfig.getCatalogName());
    form.m_textSchema.setText(codeGenConfig.getSchemaName());
    form.m_btnCancel.addActionListener(closeListener);
    form.m_btnOk.addActionListener(saveListener);
    pack();
    setVisible(true);
  }
  public void actionPerformed(ActionEvent a) {

    String command = a.getActionCommand();

    if ("refresh".equals(command)) {

      countriesModel.fireTableDataChanged();
      continentsModel.fireTableDataChanged();
      cardsModel.fireTableDataChanged();
      cardsModel2.fireTableDataChanged();
      playersModel.fireTableDataChanged();
      gameInfo.fireTableDataChanged();
      commands.fireTableDataChanged();

      repaint();
    } else if ("flash".equals(command)) {
      MainMenu.newMainMenuFrame(myrisk, JFrame.DISPOSE_ON_CLOSE);
    } else if ("aiwait".equals(command)) {

      Object[] message = new Object[2];
      message[0] = new JLabel("AI wait time (in milliseconds):");
      message[1] = new JSpinner(new SpinnerNumberModel(AIManager.getWait(), 0, 10000, 100));

      String[] options = {"OK", "cancel"};

      int result =
          JOptionPane.showOptionDialog(
              this, // the parent that the dialog blocks
              message, // the dialog message array
              "AI Options", // the title of the dialog window
              JOptionPane.OK_CANCEL_OPTION, // option type
              JOptionPane.PLAIN_MESSAGE, // message type
              null, // optional icon, use null to use the default icon
              options, // options string array, will be made into buttons
              options[0] // option that should be made into a default button
              );

      if (result == JOptionPane.OK_OPTION) {
        AIManager.setWait(((Integer) ((JSpinner) message[1]).getValue()).intValue());
      }
    } else if ("allcards".equals(command)) {

      if (myrisk.getGame() != null
          && myrisk.getGame().getState() != RiskGame.STATE_NEW_GAME
          && myrisk.getGame().getCards() != null) {

        Frame frame = RiskUIUtil.findParentFrame(this);

        CardsDialog cardsDialog = new CardsDialog(frame, pp, false, myrisk, false);
        Dimension frameSize = frame.getSize();
        Dimension aboutSize = cardsDialog.getPreferredSize();
        int x = frame.getLocation().x + (frameSize.width - aboutSize.width) / 2;
        int y = frame.getLocation().y + (frameSize.height - aboutSize.height) / 2;
        if (x < 0) x = 0;
        if (y < 0) y = 0;
        cardsDialog.setLocation(x, y);

        cardsDialog.populate(myrisk.getGame().getCards());

        cardsDialog.setVisible(true);
      }
    } else if ("checkMapServer".equals(command)) {
      // get all maps
      List<Map> maps = MapUpdateService.getMaps(MapChooser.MAP_PAGE, Collections.EMPTY_LIST);
      Set<String> ids = new HashSet();
      Set<String> errors = new HashSet();
      for (Map map : maps) {
        String fileUID =
            RiskUtil.replaceAll(MapChooser.getFileUID(map.getMapUrl()), " ", "").toLowerCase();
        if (ids.contains(fileUID)) {
          errors.add(fileUID);
        } else {
          ids.add(fileUID);
        }
      }

      if (errors.isEmpty()) {
        JOptionPane.showMessageDialog(this, "No errors found.");
      } else {
        JOptionPane.showMessageDialog(this, "Error found with map: " + errors);
      }
    } else {
      throw new RuntimeException("TestTab: unknown command found: " + command);
    }
  }
  private void jbInit() throws Exception {
    panel1.setLayout(borderLayout1);
    jPanel1.setBackground(Color.white);
    jPanel1.setLayout(borderLayout3);
    jLabel1.setFont(new java.awt.Font("Dialog", 1, 16));
    jLabel1.setHorizontalAlignment(SwingConstants.LEFT);
    jLabel1.setHorizontalTextPosition(SwingConstants.RIGHT);
    jLabel1.setText("Problem occured");
    jLabel1.setIcon(
        new ImageIcon(
            net.sf.memoranda.ui.ExceptionDialog.class.getResource("resources/icons/error.png")));

    jLabel2.setFont(new java.awt.Font("Dialog", 0, 11));
    jLabel2.setText(
        "<html>An internal exception occured. It is may be a result of bug in the "
            + "program, corrupted data, incorrect configuration or hardware failure.<br><br>"
            + "Click on <b>Report bug..</b> button to submit a bug to the Memoranda bugs tracker on SourceForge.net </html>");
    jPanel2.setLayout(borderLayout2);
    jPanel2.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    borderLayout3.setVgap(5);
    String labelText = "<html><b>Description:</b><br>" + description;
    if ((tip != null) && (tip.length() > 0)) {
      labelText = labelText + "<br><br><b>Tip:</b><br>" + tip;
    }
    labelText = labelText + "<br><br><b>Stack trace:</b></html>";
    descLabel.setText(labelText);
    descLabel.setFont(new java.awt.Font("Dialog", 0, 12));
    jScrollPane1.setEnabled(false);
    reportB.setMaximumSize(new Dimension(120, 25));
    reportB.setMinimumSize(new Dimension(120, 25));
    reportB.setPreferredSize(new Dimension(120, 25));
    reportB.setText("Report bug...");
    reportB.addActionListener(
        new java.awt.event.ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            reportB_actionPerformed(e);
          }
        });
    closeB.setMaximumSize(new Dimension(120, 25));
    closeB.setMinimumSize(new Dimension(120, 25));
    closeB.setPreferredSize(new Dimension(120, 25));
    closeB.setText("Close");
    closeB.addActionListener(
        new java.awt.event.ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            closeB_actionPerformed(e);
          }
        });
    this.getRootPane().setDefaultButton(closeB);
    jPanel3.setLayout(flowLayout1);
    flowLayout1.setAlignment(FlowLayout.RIGHT);
    copyB.setText("Copy to clipboard");
    copyB.addActionListener(
        new java.awt.event.ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            copyB_actionPerformed(e);
          }
        });
    copyB.setHorizontalAlignment(SwingConstants.RIGHT);
    jPanel4.setLayout(borderLayout4);
    traceTextArea.setText(trace);
    traceTextArea.setEditable(false);
    borderLayout1.setVgap(5);
    getContentPane().add(panel1);
    panel1.add(jPanel1, BorderLayout.NORTH);
    jPanel1.add(jLabel1, BorderLayout.NORTH);
    jPanel1.add(jLabel2, BorderLayout.CENTER);
    panel1.add(jPanel2, BorderLayout.CENTER);
    jPanel2.add(descLabel, BorderLayout.NORTH);
    jPanel2.add(jScrollPane1, BorderLayout.CENTER);
    jPanel2.add(jPanel4, BorderLayout.SOUTH);
    jPanel4.add(copyB, BorderLayout.WEST);
    jScrollPane1.getViewport().add(traceTextArea, null);
    panel1.add(jPanel3, BorderLayout.SOUTH);
    jPanel3.add(closeB, null);
    jPanel3.add(reportB, null);
    Dimension dlgSize = new Dimension(400, 500);
    this.setSize(dlgSize);
    if (owner != null) {
      Dimension frmSize = owner.getSize();
      Point loc = owner.getLocation();
      this.setLocation(
          (frmSize.width - dlgSize.width) / 2 + loc.x,
          (frmSize.height - dlgSize.height) / 2 + loc.y);
    }
  }
  /**
   * Constructs a FileConversionDialog
   *
   * @param owner The owner of the dialog.
   * @param typeFrom source file type
   * @param typeTo destinatin file type
   * @param dir current file directory
   * @param openFiles The list of current open files
   */
  public FileConversionDialog(
      Frame owner, String typeFrom, String typeTo, String dir, List openFiles) {
    super(owner, "Convert File...", true);

    fileTypeFrom = typeFrom;
    fileTypeTo = typeTo;
    isConverted = false;
    isConvertedFromImage = false;
    fileList = openFiles;
    toFileExtension = "";
    currentDir = dir;
    toolkit = Toolkit.getDefaultToolkit();

    String fromName = "Source";
    if (fileTypeTo.equals(FileFormat.FILE_TYPE_HDF5)) {
      toFileExtension = ".h5";
      setTitle("Convert Image to HDF5 ...");
      fromName = "IMAGE";
      isConvertedFromImage = true;
    } else if (fileTypeTo.equals(FileFormat.FILE_TYPE_HDF4)) {
      toFileExtension = ".hdf";
      setTitle("Convert Image to HDF4 ...");
      fromName = "IMAGE";
      isConvertedFromImage = true;
    }

    // layout the components
    JPanel contentPane = (JPanel) getContentPane();
    contentPane.setLayout(new BorderLayout(5, 5));
    contentPane.setBorder(BorderFactory.createEmptyBorder(15, 5, 5, 5));
    int w = 450 + (ViewProperties.getFontSize() - 12) * 15;
    int h = 120 + (ViewProperties.getFontSize() - 12) * 10;
    contentPane.setPreferredSize(new Dimension(w, h));

    // add the top panel for enter file name
    JPanel p = new JPanel();
    p.setLayout(new BorderLayout(5, 5));

    JPanel p0 = new JPanel();
    p0.setLayout(new GridLayout(2, 1, 5, 5));
    p0.add(new JLabel(fromName + " File: "));
    p0.add(new JLabel("HDF File: "));
    p.add(p0, BorderLayout.WEST);

    p0 = new JPanel();
    p0.setLayout(new GridLayout(2, 1, 5, 5));
    p0.add(srcFileField = new JTextField());
    p0.add(dstFileField = new JTextField());
    p.add(p0, BorderLayout.CENTER);

    p0 = new JPanel();
    p0.setLayout(new GridLayout(2, 1, 5, 5));
    JButton jButton = new JButton("Browse...");
    jButton.setActionCommand("Browse source file");
    jButton.addActionListener(this);
    p0.add(jButton);
    jButton = new JButton("Browse...");
    jButton.setActionCommand("Browse target file");
    jButton.addActionListener(this);
    p0.add(jButton);
    p.add(p0, BorderLayout.EAST);

    contentPane.add(p, BorderLayout.CENTER);

    JButton okButton = new JButton("   Ok   ");
    okButton.setMnemonic(KeyEvent.VK_O);
    okButton.setActionCommand("Ok");
    okButton.addActionListener(this);

    JButton cancelButton = new JButton("Cancel");
    cancelButton.setMnemonic(KeyEvent.VK_C);
    cancelButton.setActionCommand("Cancel");
    cancelButton.addActionListener(this);

    p = new JPanel();
    p.add(okButton);
    p.add(cancelButton);

    contentPane.add(p, BorderLayout.SOUTH);

    Point l = owner.getLocation();
    l.x += 250;
    l.y += 80;
    setLocation(l);
    pack();
  }