private void updateTemplateFromEditor(PrintfTemplate template) {
    ArrayList params = new ArrayList();
    String format = null;
    int text_length = editorPane.getDocument().getLength();
    try {
      format = editorPane.getDocument().getText(0, text_length);
    } catch (BadLocationException ex1) {
    }
    Element section_el = editorPane.getDocument().getDefaultRootElement();
    // Get number of paragraphs.
    int num_para = section_el.getElementCount();
    for (int p_count = 0; p_count < num_para; p_count++) {
      Element para_el = section_el.getElement(p_count);
      // Enumerate the content elements
      int num_cont = para_el.getElementCount();
      for (int c_count = 0; c_count < num_cont; c_count++) {
        Element content_el = para_el.getElement(c_count);
        AttributeSet attr = content_el.getAttributes();
        // Get the name of the style applied to this content element; may be null
        String sn = (String) attr.getAttribute(StyleConstants.NameAttribute);
        // Check if style name match
        if (sn != null && sn.startsWith("Parameter")) {
          // we extract the label.
          JLabel l = (JLabel) StyleConstants.getComponent(attr);
          if (l != null) {
            params.add(l.getName());
          }
        }
      }
    }

    template.setFormat(format);
    template.setTokens(params);
  }
  /**
   * Sets the mute status icon to the status panel.
   *
   * @param isMute indicates if the call with this peer is muted
   */
  public void setMute(final boolean isMute) {
    if (!SwingUtilities.isEventDispatchThread()) {
      SwingUtilities.invokeLater(
          new Runnable() {
            public void run() {
              setMute(isMute);
            }
          });
      return;
    }

    if (isMute) {
      muteStatusLabel.setIcon(new ImageIcon(ImageLoader.getImage(ImageLoader.MUTE_STATUS_ICON)));
      muteStatusLabel.setBorder(BorderFactory.createEmptyBorder(2, 3, 2, 3));
    } else {
      muteStatusLabel.setIcon(null);
      muteStatusLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    }

    // Update input volume control button state to reflect the current
    // mute status.
    if (localLevel.isSelected() != isMute) localLevel.setSelected(isMute);

    this.revalidate();
    this.repaint();
  }
  private void initComponents() {
    // Message - JLabel
    lblMessage =
        new JLabel(
            String.format(
                "An unexpected error has occurred: %s",
                e == null ? "Unexpected exception" : e.getMessage()));
    lblMessage.setIcon(icon);
    lblMessage.setPreferredSize(new Dimension(360, 40));
    lblMessage.setBorder(BorderFactory.createLineBorder(Color.red));

    // txtTrace - ExceptionTracePane
    txtTrace = new ExceptionTracePane();
    txtTrace.setBackground(new Color(92, 0, 0));
    txtTrace.setException(e);

    // srlTrace - JScrollPane
    JPanel traceWrapper = new JPanel(new BorderLayout());
    traceWrapper.add(txtTrace, BorderLayout.CENTER);
    srlTrace = new JScrollPane(traceWrapper);
    srlTrace.setPreferredSize(new Dimension(360, 200));
    srlTrace.setVisible(false);

    // btnDetails - JButton
    btnDetails = new JButton(new DetailsButtonAction());
    btnDetails.setPreferredSize(new Dimension(100, 40));

    // btnClose - JButton
    btnClose = new JButton(new CloseButtonAction());
    btnClose.setDefaultCapable(true);
    btnClose.setPreferredSize(new Dimension(100, 40));
  }
Beispiel #4
0
 public void evaluate() {
   try {
     // clear problems and console messages
     problemsView.setText("");
     consoleView.setText("");
     // update status view
     statusView.setText(" Parsing ...");
     tabbedPane.setSelectedIndex(0);
     LispExpr root = Parser.parse(textView.getText());
     statusView.setText(" Running ...");
     tabbedPane.setSelectedIndex(1);
     // update run button
     runButton.setIcon(stopImage);
     runButton.setActionCommand("Stop");
     // start run thread
     runThread = new RunThread(root);
     runThread.start();
   } catch (SyntaxError e) {
     tabbedPane.setSelectedIndex(0);
     System.err.println(
         "Syntax Error at " + e.getLine() + ", " + e.getColumn() + " : " + e.getMessage());
   } catch (Error e) {
     // parsing error
     System.err.println(e.getMessage());
     statusView.setText(" Errors.");
   }
 }
  void setData(boolean equal, Trace newTrace, Trace oldTrace) {
    boolean equalComments = newTrace.getComment().equals(oldTrace.getComment());
    if (equal) {
      if (equalComments) {
        messageLabel.setText("Passed");
        saveButton.setEnabled(false);
        replaceButton.setEnabled(false);
      } else {
        messageLabel.setText("Passed, but comments differ");
      }
    } else {
      messageLabel.setText("Discrepency found");
    }

    if (equalComments) {
      addText(newTrace.getComment(), "regular", commentPane);
    } else {
      System.out.println("Old Comment: " + oldTrace.getComment());
      System.out.println("New Comment: " + newTrace.getComment());
      Object[] v = stringToArray(oldTrace.getComment());
      Object[] h = stringToArray(newTrace.getComment());
      displayDifferencesToPane(v, h, commentPane);
    }

    if (equal) {
      copyTraceToPane(newTrace);
    } else {
      Object[] v = traceToArray(oldTrace);
      Object[] h = traceToArray(newTrace);
      displayDifferencesToPane(v, h, jTextPane);
    }
  }
    public DisplayUserDirectory() {
      GridBagLayout gbl = new GridBagLayout();
      GridBagConstraints gbc = new GridBagConstraints();
      setLayout(gbl);

      gbc.anchor = GridBagConstraints.NORTHWEST;
      gbc.fill = GridBagConstraints.HORIZONTAL;

      hmlabel.setForeground(Color.black);
      add(hmlabel, gbc);
      add(Box.createHorizontalStrut(10), gbc);
      gbc.gridwidth = GridBagConstraints.REMAINDER;
      add(hmdir, gbc);
      add(Box.createVerticalStrut(15), gbc);

      gbc.gridwidth = 1;
      vjlabel.setForeground(Color.black);
      add(vjlabel, gbc);
      add(Box.createHorizontalStrut(10), gbc);
      gbc.gridwidth = GridBagConstraints.REMAINDER;
      add(vjdir, gbc);
      add(Box.createVerticalStrut(0), gbc);

      gbc.gridwidth = 1;
      vjlabel2.setForeground(Color.black);
      add(vjlabel2, gbc);
      setBorder(
          new CompoundBorder(
              // i18n
              // BorderFactory.createTitledBorder(" User_Directories "),
              BorderFactory.createTitledBorder(Util.getAdmLabel("_admin_User_Directories")),
              BorderFactory.createEmptyBorder(10, 10, 10, 10)));
    }
  /**
   * Creates the <tt>Component</tt> hierarchy of the area of status-related information such as
   * <tt>CallPeer</tt> display name, call duration, security status.
   *
   * @return the root of the <tt>Component</tt> hierarchy of the area of status-related information
   *     such as <tt>CallPeer</tt> display name, call duration, security status
   */
  private Component createStatusBar() {
    // stateLabel
    callStatusLabel.setForeground(Color.WHITE);
    dtmfLabel.setForeground(Color.WHITE);
    callStatusLabel.setText(callPeer.getState().getLocalizedStateString());

    PeerStatusPanel statusPanel = new PeerStatusPanel(new GridBagLayout());

    GridBagConstraints constraints = new GridBagConstraints();

    constraints.gridx = 0;
    constraints.gridy = 0;
    statusPanel.add(securityStatusLabel, constraints);
    initSecurityStatusLabel();

    constraints.gridx++;
    statusPanel.add(holdStatusLabel, constraints);

    constraints.gridx++;
    statusPanel.add(muteStatusLabel, constraints);

    constraints.gridx++;
    callStatusLabel.setBorder(BorderFactory.createEmptyBorder(2, 3, 2, 12));
    statusPanel.add(callStatusLabel, constraints);

    constraints.gridx++;
    constraints.weightx = 1f;
    statusPanel.add(dtmfLabel, constraints);

    return statusPanel;
  }
 void addTextField(JPanel panel, String key, String label) {
   JLabel lab = new JLabel(label);
   lab.setAlignmentX(LEFT_ALIGNMENT);
   panel.add(lab);
   JTextField field = new JTextField();
   field.setText(sketch.configFile.get(key));
   field.setMaximumSize(new Dimension(Integer.MAX_VALUE, field.getPreferredSize().height));
   fields.put(key, field);
   panel.add(field);
 }
 void addTextArea(JPanel panel, String key, String label) {
   JLabel lab = new JLabel(label);
   lab.setAlignmentX(LEFT_ALIGNMENT);
   panel.add(lab);
   JTextArea field = new JTextArea();
   field.setText(sketch.configFile.get(key));
   field.setLineWrap(true);
   field.setWrapStyleWord(true);
   fields.put(key, field);
   JScrollPane scroll = new JScrollPane(field);
   scroll.setAlignmentX(0.0f);
   panel.add(scroll);
 }
Beispiel #10
0
 public void runFinished() {
   // program execution finished so update
   // status and run button accordingly
   if (runThread == null) {
     // _runThread = null only if
     // execution stopped by user via
     // run button
     statusView.setText(" Stopped.");
   } else {
     statusView.setText(" Done.");
   }
   runButton.setActionCommand("Run");
   runButton.setIcon(runImage);
 }
    protected void layoutUIComponents(String strPath, boolean bDefaultFile) {
      JLabel label = null;

      // i18n
      // label = new JLabel( "File names can be constructed from a template. The LABEL field is " );
      label =
          new JLabel(
              Util.getAdmLabel(
                  "_admin_File_names_can_be_constructed_from_a_template._The_LABEL_field_is_"));
      label.setForeground(Color.black);
      // m_gbc.weightx = 0.5;
      showInstruction(m_gbl, m_gbc, 0, 0, 7, label);

      // i18n
      // label = new JLabel( "presented as the choice to the user in the \"Data save\" pop-up." );
      label =
          new JLabel(
              Util.getAdmLabel(
                  "_admin_presented_as_the_choice_to_the_user_in_the_Data_save_pop-up."));
      showInstruction(m_gbl, m_gbc, 0, 1, 7, label);
      showInstruction(m_gbl, m_gbc, 0, 2, 1, new JLabel(""));

      label = new JLabel(Util.getAdmLabel("_adm_LABEL"));
      label.setForeground(Color.black);
      m_gbc.gridx = 1;
      m_gbc.gridy = 2;
      m_gbc.ipadx = 10;
      m_gbl.setConstraints(label, m_gbc);
      m_pnlDisplay.add(label);

      label = new JLabel("     ");
      m_gbc.gridx = 2;
      m_gbc.gridy = 2;
      m_gbc.ipadx = 0; // reset to default
      m_gbc.gridwidth = 5;
      m_gbl.setConstraints(label, m_gbc);
      // add( label );

      showInstruction(m_gbl, m_gbc, 2, 2, 1, new JLabel(Util.getAdmLabel("_admin_TEMPLATE")));

      m_nRow = 3;
      m_bDefaultFile = bDefaultFile;
      m_objTxfValue.clearArrays();
      displayNewTxf(strPath);

      m_pnlDisplay.setBorder(
          new CompoundBorder(
              BorderFactory.createTitledBorder(Util.getAdmLabel("_admin_User_Directories")),
              BorderFactory.createEmptyBorder(10, 10, 10, 10)));
    }
    public DisplayResults() {
      GridBagLayout gbl = new GridBagLayout();
      GridBagConstraints gbc = new GridBagConstraints();
      setLayout(gbl);

      gbc.anchor = GridBagConstraints.NORTHWEST;
      gbc.fill = GridBagConstraints.HORIZONTAL;

      text.setForeground(Color.black);
      add(text, gbc);
      gbc.gridy = 0;
      gbc.gridwidth = GridBagConstraints.REMAINDER;
      add(emptyLabel, gbc);
      add(Box.createVerticalStrut(0), gbc);
      add(emptyLabel, gbc);

      /*	 gbc.gridy = 1;
      VTextMsg result = new VTextMsg(sshare, vnmrif, null);
      result.setPreferredSize(new Dimension(300, 30));
      result.setForeground(Color.black);
      add( result, gbc );
      */
      setBorder(
          new CompoundBorder(
              BorderFactory.createTitledBorder("  Results  "),
              BorderFactory.createEmptyBorder(10, 10, 10, 10)));
    }
Beispiel #13
0
 public void prettyPrint() {
   try {
     // clear old problem messages
     problemsView.setText("");
     // update status view
     statusView.setText(" Parsing ...");
     LispExpr root = Parser.parse(textView.getText());
     statusView.setText(" Pretty Printing ...");
     String newText = PrettyPrinter.prettyPrint(root);
     textView.setText(newText);
     statusView.setText(" Done.");
   } catch (Error e) {
     System.err.println(e.getMessage());
     statusView.setText(" Errors.");
   }
 }
  /** Reloads all icons. */
  public void loadSkin() {
    if (localLevel != null)
      localLevel.setIcon(new ImageIcon(ImageLoader.getImage(ImageLoader.MICROPHONE)));

    if (remoteLevel != null && remoteLevel instanceof Skinnable)
      ((Skinnable) remoteLevel).loadSkin();

    if (muteStatusLabel.getIcon() != null)
      muteStatusLabel.setIcon(new ImageIcon(ImageLoader.getImage(ImageLoader.MUTE_STATUS_ICON)));

    if (holdStatusLabel.getIcon() != null)
      holdStatusLabel.setIcon(new ImageIcon(ImageLoader.getImage(ImageLoader.HOLD_STATUS_ICON)));

    securityStatusLabel.setIcon(new ImageIcon(ImageLoader.getImage(securityImageID)));

    if (peerImage == null) {
      photoLabel.setIcon(new ImageIcon(ImageLoader.getImage(ImageLoader.DEFAULT_USER_PHOTO)));
    }
  }
Beispiel #15
0
  public void showFrame(final Editor editor, boolean activateErrorPanel, final boolean loading) {
    this.editor = editor;

    setLayout(editor, activateErrorPanel, loading);
    contributionListPanel.setVisible(!loading);
    loaderLabel.setVisible(loading);
    errorPanel.setVisible(activateErrorPanel);

    validate();
    repaint();
  }
Beispiel #16
0
 public void newFile() {
   if (!dirty || checkForSave()) {
     textView.setText("");
     consoleView.setText("");
     problemsView.setText("");
     statusView.setText(" Created new file.");
     file = null;
     // reset dirty bit
     dirty = false;
   }
 }
Beispiel #17
0
  /**
   * Build the UI of the given process according to the given data.
   *
   * @param processExecutionData Process data.
   * @return The UI for the configuration of the process.
   */
  public JComponent buildUIConf(ProcessExecutionData processExecutionData) {
    JPanel panel = new JPanel(new MigLayout("fill"));
    // For each input, display its title, its abstract and gets its UI from the dataUIManager
    for (Input i : processExecutionData.getProcess().getInput()) {
      JPanel inputPanel = new JPanel(new MigLayout("fill"));
      inputPanel.setBorder(BorderFactory.createTitledBorder(i.getTitle()));
      JLabel inputAbstrac = new JLabel(i.getResume());
      inputAbstrac.setFont(inputAbstrac.getFont().deriveFont(Font.ITALIC));
      inputPanel.add(inputAbstrac, "wrap");
      DataUI dataUI = dataUIManager.getDataUI(i.getDataDescription().getClass());
      if (dataUI != null) {
        inputPanel.add(dataUI.createUI(i, processExecutionData.getInputDataMap()), "wrap");
      }
      panel.add(inputPanel, "growx, wrap");
    }

    // For each output, display its title, its abstract and gets its UI from the dataUIManager
    for (Output o : processExecutionData.getProcess().getOutput()) {
      DataUI dataUI = dataUIManager.getDataUI(o.getDataDescription().getClass());
      if (dataUI != null) {
        JComponent component = dataUI.createUI(o, processExecutionData.getOutputDataMap());
        if (component != null) {
          JPanel outputPanel = new JPanel(new MigLayout("fill"));
          outputPanel.setBorder(BorderFactory.createTitledBorder(o.getTitle()));
          JLabel outputAbstrac = new JLabel(o.getResume());
          outputAbstrac.setFont(outputAbstrac.getFont().deriveFont(Font.ITALIC));
          outputPanel.add(outputAbstrac, "wrap");
          outputPanel.add(component, "wrap");
          panel.add(outputPanel, "growx, wrap");
        }
      }
    }
    return panel;
  }
Beispiel #18
0
 public void saveFile() {
   if (file == null) {
     // first save file, so prompt for name.
     saveFileAs();
   } else {
     // file already named so just write it.
     physWriteTextFile(file, textView.getText());
     // update status
     statusView.setText(" Saved file \"" + file.getName() + "\".");
     // reset dirty bit
     dirty = false;
   }
 }
  /**
   * Sets the "on hold" property value.
   *
   * @param isOnHold indicates if the call with this peer is put on hold
   */
  public void setOnHold(final boolean isOnHold) {
    if (!SwingUtilities.isEventDispatchThread()) {
      SwingUtilities.invokeLater(
          new Runnable() {
            public void run() {
              setOnHold(isOnHold);
            }
          });
      return;
    }

    if (isOnHold) {
      holdStatusLabel.setIcon(new ImageIcon(ImageLoader.getImage(ImageLoader.HOLD_STATUS_ICON)));
      holdStatusLabel.setBorder(BorderFactory.createEmptyBorder(2, 3, 2, 3));
    } else {
      holdStatusLabel.setIcon(null);
      holdStatusLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    }

    this.revalidate();
    this.repaint();
  }
  /**
   * Computes the maximum width of a label in the configuration form.
   *
   * @param configForm the configuration form containing all labels.
   * @return the maximum width of a label in the configuration form
   */
  private int computeLabelWidth(ChatRoomConfigurationForm configForm) {
    int labelWidth = 0;

    Iterator<ChatRoomConfigurationFormField> configurationSet = configForm.getConfigurationSet();

    while (configurationSet.hasNext()) {
      ChatRoomConfigurationFormField formField = configurationSet.next();

      if (formField.getLabel() == null) continue;

      JLabel label = new JLabel(formField.getLabel());

      int newLabelWidth =
          SwingUtilities.computeStringWidth(
              label.getFontMetrics(label.getFont()), formField.getLabel());

      if (newLabelWidth > labelWidth) labelWidth = newLabelWidth;
    }

    // We add 10 pixels to be sure that even after adding the ':' char
    // the label will rest visible.
    return labelWidth + 10;
  }
 private void showInstruction(
     GridBagLayout gbl,
     GridBagConstraints gbc,
     int gridx,
     int gridy,
     int gridwidth,
     JLabel instruction) {
   gbc.gridwidth = gridwidth;
   gbc.gridx = gridx;
   gbc.gridy = gridy;
   gbl.setConstraints(instruction, gbc);
   instruction.setForeground(Color.black);
   m_pnlDisplay.add(instruction);
 }
Beispiel #22
0
 /**
  * Run the process.
  *
  * @return True if the process has already been launch, false otherwise.
  */
 public boolean runProcess() {
   if (processExecutionData.getState().equals(ProcessExecutionData.ProcessState.IDLE)
       || processExecutionData.getState().equals(ProcessExecutionData.ProcessState.ERROR)
       || processExecutionData.getState().equals(ProcessExecutionData.ProcessState.COMPLETED)) {
     clearLogPanel();
     processExecutionData.runProcess();
     // Select the execution tab
     stateLabel.setText(processExecutionData.getState().getValue());
     tabbedPane.setSelectedIndex(tabbedPane.getTabCount() - 1);
     return false;
   } else {
     return true;
   }
 }
  /**
   * Set the image of the peer
   *
   * @param image new image
   */
  public void setPeerImage(byte[] image) {
    // If the image is still null we try to obtain it from one of the
    // available contact sources.
    if (image == null || image.length <= 0) {
      GuiActivator.getContactList().setSourceContactImage(peerName, photoLabel, 100, 100);
    } else {
      peerImage = ImageUtils.getScaledRoundedIcon(image, 100, 100);
      if (peerImage == null) peerImage = getPhotoLabelIcon();

      if (!SwingUtilities.isEventDispatchThread()) {
        SwingUtilities.invokeLater(
            new Runnable() {
              public void run() {
                photoLabel.setIcon(peerImage);
                photoLabel.repaint();
              }
            });
      } else {
        photoLabel.setIcon(peerImage);
        photoLabel.repaint();
      }
    }
  }
Beispiel #24
0
  /**
   * Build the UI of the given process according to the given data.
   *
   * @param processExecutionData Process data.
   * @return The UI for the configuration of the process.
   */
  public JComponent buildUIExec(ProcessExecutionData processExecutionData) {
    JPanel panel = new JPanel(new MigLayout("fill"));

    JPanel executorPanel = new JPanel(new MigLayout());
    executorPanel.setBorder(BorderFactory.createTitledBorder("Executor :"));
    executorPanel.add(new JLabel("localhost"));

    JPanel statusPanel = new JPanel(new MigLayout());
    statusPanel.setBorder(BorderFactory.createTitledBorder("Status :"));
    stateLabel = new JLabel(processExecutionData.getState().getValue());
    statusPanel.add(stateLabel);

    JPanel resultPanel = new JPanel(new MigLayout());
    resultPanel.setBorder(BorderFactory.createTitledBorder("Result :"));
    for (Output o : processExecutionData.getProcess().getOutput()) {
      JLabel title = new JLabel(o.getTitle() + " : ");
      JLabel result = new JLabel();
      result.putClientProperty("URI", o.getIdentifier());
      outputJLabelList.add(result);
      resultPanel.add(title);
      resultPanel.add(result, "wrap");
    }

    JPanel logPanel = new JPanel(new BorderLayout());
    logPanel.setBorder(BorderFactory.createTitledBorder("Log :"));
    logPane = new JTextPane();
    logPane.setCaretPosition(0);
    JScrollPane scrollPane = new JScrollPane(logPane);
    logPanel.add(scrollPane, BorderLayout.CENTER);

    panel.add(executorPanel, "growx, wrap");
    panel.add(statusPanel, "growx, wrap");
    panel.add(resultPanel, "growx, wrap");
    panel.add(logPanel, "growx, growy, wrap");

    return panel;
  }
Beispiel #25
0
 public void caretUpdate(CaretEvent e) {
   // when the cursor moves on _textView
   // this method will be called. Then, we
   // must determine what the line number is
   // and update the line number view
   Element root = textView.getDocument().getDefaultRootElement();
   int line = root.getElementIndex(e.getDot());
   root = root.getElement(line);
   int col = root.getElementIndex(e.getDot());
   lineNumberView.setText(line + ":" + col);
   // if text is selected then enable copy and cut
   boolean isSelection = e.getDot() != e.getMark();
   copyAction.setEnabled(isSelection);
   cutAction.setEnabled(isSelection);
 }
Beispiel #26
0
 public void saveFileAs() {
   // Force user to enter new file name
   if (fileChooser.showSaveDialog(this) == JFileChooser.APPROVE_OPTION) {
     file = fileChooser.getSelectedFile();
   } else {
     // user cancelled save after all
     return;
   }
   // file selected, so write it.
   physWriteTextFile(file, textView.getText());
   // update status
   statusView.setText(" Saved file \"" + file.getName() + "\".");
   // reset dirty bit
   dirty = false;
 }
 void updateTheLabel(DocumentEvent e) {
   Document doc = (Document) e.getDocument();
   String text = null;
   try {
     text = doc.getText(0, doc.getLength());
     doc = null;
   } catch (BadLocationException ex) {
     text = null;
   }
   if (text != null) {
     try {
       double number = Double.parseDouble(text);
       if (number > 1) {
         label.setText(labelPair.getPlural());
       } else {
         label.setText(labelPair.getSingular());
       }
     } catch (NumberFormatException ex) {
       // Do nothing
     } finally {
       text = null;
     }
   }
 }
Beispiel #28
0
 /**
  * used to manage the connection icons to signify connection and secure status
  *
  * @param b true if connected
  */
 public void setConnected(boolean b) {
   if (b) {
     conIcon.setIcon(conYes);
     conIcon.setToolTipText("Connected");
     secIcon.setIcon(secYes);
     secIcon.setToolTipText("Secure Connection");
     butChannel.setEnabled(true);
   } else {
     conIcon.setIcon(conNo);
     conIcon.setToolTipText("Not Connected");
     secIcon.setIcon(secNo);
     secIcon.setToolTipText("Connection not Secured");
     butChannel.setEnabled(false);
     butCreate.setEnabled(false);
     butInvite.setEnabled(false);
   }
 }
    // Method to build the dialog box for help.
    private void buildDialogBox() {
      // Set the JDialog window properties.
      setTitle("Learning about Java");
      setResizable(false);
      setSize(dialogWidth, dialogHeight);

      // Define behaviors of container.
      c.setLayout(null);
      c.setBackground(Color.cyan);
      c.add(image);
      c.add(okButton);

      // Set the bounds for the image.
      image.setBounds(
          (dialogWidth / 2) - (imageWidth / 2),
          (top + (offsetMargin / 2)),
          imageWidth,
          imageHeight);

      // Set the behaviors, bounds and action listener for the button.
      okButton.setBounds(
          (dialogWidth / 2) - (buttonWidth / 2),
          (imageHeight + (int) 1.5 * offsetMargin),
          buttonWidth,
          buttonHeight);

      // Set the font to the platform default Font for the object with the
      // properties of bold and font size of 11.
      okButton.setFont(new Font(okButton.getFont().getName(), Font.BOLD, 11));

      // Set foreground and background of JButton(s).
      okButton.setForeground(Color.white);
      okButton.setBackground(Color.blue);

      // The class implements the ActionListener interface and therefore
      // provides an implementation of the actionPerformed() method.  When a
      // class implements ActionListener, the instance handler returns an
      // ActionListener.  The ActionListener then performs actionPerformed()
      // method on an ActionEvent.
      okButton.addActionListener(this);

      // Set the screen and display dialog window in relation to screen size.
      dim = tk.getScreenSize();
      setLocation((dim.width / 2) - (dialogWidth / 2), (dim.height / 2) - (dialogHeight / 2));

      // Display the dialog.
      show();
    } // End of buildDialogBox method.
Beispiel #30
0
 public void openFile() {
   if (!dirty || checkForSave()) {
     if (fileChooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
       file = fileChooser.getSelectedFile();
     } else {
       // user cancelled open after all
       return;
     }
     // load file into text view
     textView.setText(physReadTextFile(file));
     // update status
     statusView.setText(" Loaded file \"" + file.getName() + "\".");
     // reset dirty bit
     dirty = false;
   }
 }