Example #1
0
  private void _displayRespStrInFrame() {

    final JFrame frame = new JFrame("Google Static Map - Error");
    GUIUtils.setAppIcon(frame, "69.png");
    // frame.setDefaultCloseOperation(DISPOSE_ON_CLOSE);

    JTextArea response = new JTextArea(_respStr, 25, 80);
    response.addMouseListener(
        new MouseListener() {
          public void mouseClicked(MouseEvent e) {}

          public void mousePressed(MouseEvent e) {
            /*frame.dispose();*/
          }

          public void mouseReleased(MouseEvent e) {}

          public void mouseEntered(MouseEvent e) {}

          public void mouseExited(MouseEvent e) {}
        });

    frame.setContentPane(new JScrollPane(response));
    frame.pack();

    GUIUtils.centerOnScreen(frame);
    frame.setVisible(true);
  }
Example #2
0
  public synchronized void run() {

    byte[] buffer = new byte[BUFFER_SIZE];

    for (; ; ) {
      try {
        this.wait(100);
      } catch (InterruptedException ie) {
      }

      int len = 0;
      try {
        int noBytes = pin.available();

        if (noBytes > 0) {
          len = pin.read(buffer, 0, Math.min(noBytes, BUFFER_SIZE));
          if (len > 0) {
            jTextArea.append(new String(buffer, 0, len));
            jTextArea.setCaretPosition(jTextArea.getText().length());
          }
        }
      } catch (IOException ioe) {
        throw new UIError("Unable to read from input stream! " + ioe.getMessage());
      }
    }
  }
 /** Override setText to do formatting */
 public void setText(String text) {
   original = text;
   formatted = null;
   if (format) {
     doFormat();
     super.setText(formatted);
   } else {
     super.setText(original);
   }
 }
 /**
  * Updates all of the components in the panel to match that of the associated Artifact.
  *
  * @see #ArtifactView(Artifact, DataProvider)
  */
 public void rebuild() {
   title.setText(SHTML + TITLE + elem.title + EHTML);
   donor.setText(SHTML + DONOR + elem.donor + EHTML);
   subDate.setText(SHTML + SUB_DATE + elem.subDate.toString() + EHTML);
   objDate.setText(SHTML + OBJ_DATE + elem.objDate.toString() + EHTML);
   medium.setText(SHTML + MEDIUM + elem.medium + EHTML);
   accNum.setText(SHTML + ACC_NUM + elem.accNum + EHTML);
   descView.setText(elem.desc);
   descView.setCaretPosition(0);
   validate();
 }
 /** Turn reflow on or off */
 public void setReflowXML(boolean reflow) {
   format = reflow;
   if (format) {
     if (formatted == null) {
       doFormat();
     }
     super.setText(formatted);
   } else {
     super.setText(original);
   }
 }
Example #6
0
  // calculate and display amounts
  private void calculateJButtonActionPerformed(ActionEvent event) {
    resultJTextArea.setText("Rate (%)\tAmount after 10 years");
    DecimalFormat dollars = new DecimalFormat("$0.00");

    int principal = Integer.parseInt(principalJTextField.getText());

    // for loop to calculate interest
    for (int rate = 5; rate <= 10; rate++) {
      double amount = (double) principal * Math.pow(1 + ((double) rate / 100), 10);
      resultJTextArea.append("\n" + rate + "\t" + dollars.format(amount));
    } // end for
  } // end method calculateJButtonActionPerformed
Example #7
0
  // create and position GUI components; register event handlers
  private void createUserInterface() {
    // get content pane for attaching GUI components
    Container contentPane = getContentPane();

    // enable explicit positioning of GUI components
    contentPane.setLayout(null);

    // set up principalJLabel
    principalJLabel = new JLabel();
    principalJLabel.setBounds(20, 20, 80, 20);
    principalJLabel.setText("Principal:");
    contentPane.add(principalJLabel);

    // set up principalJTextField
    principalJTextField = new JTextField();
    principalJTextField.setBounds(80, 20, 90, 20);
    principalJTextField.setText("0");
    principalJTextField.setHorizontalAlignment(JTextField.RIGHT);
    contentPane.add(principalJTextField);

    // set up resultJLabel
    resultJLabel = new JLabel();
    resultJLabel.setBounds(20, 60, 100, 20);
    resultJLabel.setText("Result:");
    contentPane.add(resultJLabel);

    // set up resultJTextArea
    resultJTextArea = new JTextArea();
    resultJTextArea.setBounds(20, 85, 260, 120);
    resultJTextArea.setEditable(false);
    contentPane.add(resultJTextArea);

    // set up calculateJButton
    calculateJButton = new JButton();
    calculateJButton.setBounds(190, 20, 90, 20);
    calculateJButton.setText("Calculate");
    contentPane.add(calculateJButton);
    calculateJButton.addActionListener(
        new ActionListener() // anonymous inner class
        {
          // event handler called when calculateJButton is pressed
          public void actionPerformed(ActionEvent event) {
            calculateJButtonActionPerformed(event);
          }
        } // end anonymous inner class
        ); // end call to addActionListener

    // set properties of application's window
    setTitle("Comparing Rates"); // set title bar text
    setSize(310, 255); // set window size
    setVisible(true); // display window
  } // end method createUserInterface
 public CFSecuritySwingISOCurrencyAskDeleteJPanel(
     ICFSecuritySwingSchema argSchema, ICFSecurityISOCurrencyObj argFocus) {
   super();
   final String S_ProcName = "construct-schema-focus";
   if (argSchema == null) {
     throw CFLib.getDefaultExceptionFactory()
         .newNullArgumentException(getClass(), S_ProcName, 1, "argSchema");
   }
   // argFocus is optional; focus may be set later during execution as
   // conditions of the runtime change.
   swingSchema = argSchema;
   swingFocus = argFocus;
   // Construct the various objects
   textAreaMessage = new JTextArea("Are you sure you want to delete this ISO Currency?");
   actionOk = new ActionOk();
   actionCancel = new ActionCancel();
   buttonOk = new JButton(actionOk);
   buttonCancel = new JButton(actionCancel);
   attrJPanel = argSchema.getISOCurrencyFactory().newAttrJPanel(argFocus);
   scrollPane = new CFHSlaveJScrollPane(attrJPanel);
   // Lay out the widgets
   setSize(1024, 480);
   Dimension min = new Dimension(480, 300);
   setMinimumSize(min);
   add(textAreaMessage);
   textAreaMessage.setBounds(0, 0, 1024, 50);
   int xparts = (768 - (2 * 125)) / 3;
   add(buttonOk);
   buttonOk.setBounds(xparts, 55, 125, 40);
   add(buttonCancel);
   buttonCancel.setBounds(xparts + 125 + xparts, 55, 125, 40);
   add(scrollPane);
   scrollPane.setBounds(0, 100, 1024, 480 - 100);
 }
  // calculate and display amounts
  private void calculateJButtonActionPerformed(ActionEvent event) {
    // declare variables to store user input
    double principal = Double.parseDouble(principalJTextField.getText());
    double rate = Double.parseDouble(interestRateJTextField.getText());

    Integer integerObject = (Integer) yearsJSpinner.getValue();
    Integer year = integerObject.intValue();

    yearlyBalanceJTextArea.setText("Year\tAmount on Deposit");
    DecimalFormat dollars = new DecimalFormat("$0.00");

    // calculate the total value for each year
    for (int count = 1; count <= year; count++) {
      double amount = principal * Math.pow((1 + rate / 100), count);
      yearlyBalanceJTextArea.append("\n" + count + "\t" + dollars.format(amount));
    } // end for
  } // end method calculateJButtonActionPerformed
 public void doLayout() {
   Dimension sz = getSize();
   textAreaMessage.setBounds(0, 0, sz.width, 50);
   int xparts = (sz.width - (2 * 125)) / 3;
   buttonOk.setBounds(xparts, 55, 125, 40);
   buttonCancel.setBounds(xparts + 125 + xparts, 55, 125, 40);
   scrollPane.setBounds(0, 100, sz.width, sz.height - 100);
   scrollPane.doLayout();
 }
  private void populateList() {
    try {
      String path = ".";
      fileList.setText(" ");

      String files;
      File folder = new File(path);
      File[] listOfFiles = folder.listFiles();

      for (int i = 0; i < listOfFiles.length; i++) {

        if (listOfFiles[i].isFile()) {
          files = listOfFiles[i].getName();
          // if(files.endsWith(".dat"))
          fileList.append(files + "\n");
        }
      }
    } catch (java.security.AccessControlException k) {
    }
  }
  private String getFileWords(String s) {
    String output = "";
    try {
      // THIS CODE SEGMENT WILL NOT RUN IN AN APPLET THAT IS NOT "SIGNED"
      // By default applets cannot alter files on the hard drive of the user.
      // If the panel is opened in a regular application the save button should work.
      // This can be tested in HomeworkApplication.java through HomeworkRun.java only

      File inputFile = new File(s);
      Scanner inputScanner = new Scanner(inputFile);

      while (inputScanner.hasNext()) {
        output = output + inputScanner.nextLine() + "\n";
      }

      inputScanner.close();
      String numWords = getWords(output);
      return numWords;
    } catch (IOException e) {
      outputLabel.append(e + "");
    }

    return output;
  }
  // create and position GUI components; register event handlers
  private void createUserInterface() {
    // get content pane for attaching GUI components
    Container contentPane = getContentPane();

    // enable explicit positioning of GUI components
    contentPane.setLayout(null);

    // set up principalJLabel
    principalJLabel = new JLabel();
    principalJLabel.setBounds(16, 16, 56, 24);
    principalJLabel.setText("Principal:");
    contentPane.add(principalJLabel);

    // set up principalJTextField
    principalJTextField = new JTextField();
    principalJTextField.setBounds(100, 16, 100, 24);
    principalJTextField.setHorizontalAlignment(JTextField.RIGHT);
    contentPane.add(principalJTextField);

    // set up interestRateJLabel
    interestRateJLabel = new JLabel();
    interestRateJLabel.setBounds(16, 56, 80, 24);
    interestRateJLabel.setText("Interest rate:");
    contentPane.add(interestRateJLabel);

    // set up interestRateJTextField
    interestRateJTextField = new JTextField();
    interestRateJTextField.setBounds(100, 56, 100, 24);
    interestRateJTextField.setHorizontalAlignment(JTextField.RIGHT);
    contentPane.add(interestRateJTextField);

    // set up yearsJLabel
    yearsJLabel = new JLabel();
    yearsJLabel.setBounds(16, 96, 48, 24);
    yearsJLabel.setText("Years:");
    contentPane.add(yearsJLabel);

    // set up yearsJSpinner
    yearsJSpinner = new JSpinner(new SpinnerNumberModel(1, 1, 10, 1));
    yearsJSpinner.setBounds(100, 96, 100, 24);
    contentPane.add(yearsJSpinner);

    // set up yearlyBalanceJLabel
    yearlyBalanceJLabel = new JLabel();
    yearlyBalanceJLabel.setBounds(16, 136, 150, 24);
    yearlyBalanceJLabel.setText("Yearly account balance:");
    contentPane.add(yearlyBalanceJLabel);

    // set up yearlyBalanceJTextArea
    yearlyBalanceJTextArea = new JTextArea();
    yearlyBalanceJTextArea.setEditable(false);

    // set up yearlyBalanceJScrollPane
    yearlyBalanceJScrollPane = new JScrollPane(yearlyBalanceJTextArea);
    yearlyBalanceJScrollPane.setBounds(16, 160, 300, 92);
    contentPane.add(yearlyBalanceJScrollPane);

    // set up calculateJButton
    calculateJButton = new JButton();
    calculateJButton.setBounds(216, 16, 100, 24);
    calculateJButton.setText("Calculate");
    contentPane.add(calculateJButton);
    calculateJButton.addActionListener(
        new ActionListener() // anonymous inner class
        {
          // event handler called when calculateJButton is clicked
          public void actionPerformed(ActionEvent event) {
            calculateJButtonActionPerformed(event);
          }
        } // end anonymous inner class
        ); // end call to addActionListener

    // set properties of application's window
    setTitle("Interest Calculator"); // set title bar text
    setSize(340, 296); // set window size
    setVisible(true); // display window
  } // end method createUserInterface
  public void setup() {
    setLayout(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    title = new JLabel(SHTML + TITLE + elem.title + EHTML);
    gbc.fill = GridBagConstraints.NONE;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.gridy = 4;
    gbc.gridx = 0;
    gbc.gridwidth = 2;
    gbc.gridheight = 1;
    gbc.weighty = 1.0;
    add(title, gbc);
    donor = new JLabel(SHTML + DONOR + elem.donor + EHTML);
    gbc.gridy = 5;
    add(donor, gbc);
    subDate = new JLabel(SHTML + SUB_DATE + elem.subDate.toString() + EHTML);
    gbc.gridy = 6;
    add(subDate, gbc);
    objDate = new JLabel(SHTML + OBJ_DATE + elem.objDate.toString() + EHTML);
    gbc.gridy = 7;
    add(objDate, gbc);
    medium = new JLabel(SHTML + MEDIUM + elem.medium + EHTML);
    gbc.gridy = 8;
    add(medium, gbc);
    accNum = new JLabel(SHTML + ACC_NUM + elem.accNum + EHTML);
    gbc.gridy = 9;
    add(accNum, gbc);
    desc = new JLabel(SHTML + DESC + EHTML);
    // gbc.anchor = GridBagConstraints.PAGE_START;
    gbc.insets = new Insets(0, 50, 0, 0);
    gbc.gridy = 4;
    gbc.gridx = 2;
    add(desc, gbc);
    descView = new JTextArea();
    descView.setLineWrap(true);
    descView.setWrapStyleWord(true);
    descView.setEditable(false);
    descView.setText(elem.desc);
    descView.setFont(new Font("Times New Roman", Font.PLAIN, 13));
    JScrollPane scrollPane = new JScrollPane(descView);
    scrollPane.setPreferredSize(new Dimension(225, 100));
    // scrollPane.setBorder(null);
    scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    descView.setCaretPosition(0);
    gbc.gridy = 5;
    gbc.gridheight = 4;
    gbc.gridx = 2;
    add(scrollPane, gbc);

    gbc.insets = null;
    gbc.gridy = 0;
    gbc.gridx = 0;
    gbc.gridwidth = 4;
    gbc.gridheight = 4;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.insets = new Insets(0, 0, 10, 0);
    vpan = new V3DPanel(elem, provider);
    vpan.setPreferredSize(new Dimension(500, 300));
    setBackground(BACKGROUND);
    add(vpan, gbc);
    validate();
  }
Example #15
0
  ///////////////////////////////////
  // member functions
  //////////////////////////////////
  protected final void initForm() {
    thisPanel = new JPanel();
    thisPanel.setName("Import Range Data");
    thisPanel.setLayout(new java.awt.BorderLayout());

    _thePanel.add(thisPanel);

    _theWarning = new JTextArea();
    _theWarning.setEditable(false);
    String theMessage = "Warning, data imported through this panel has";
    theMessage += " speed and course calculated as over the ground.";
    theMessage += System.getProperties().getProperty("line.separator");
    theMessage += "Debrief recognises PC Argos (RAO) and PMRF (PRN) files.";
    theMessage += System.getProperties().getProperty("line.separator");
    theMessage += "See Debrief Help File for file format and details.";

    _theWarning.setText(theMessage);
    _theWarning.setLineWrap(true);
    _theWarning.setBorder(BorderFactory.createLoweredBevelBorder());
    _theWarning.setWrapStyleWord(true);
    thisPanel.add("North", _theWarning);
    ////////////////////////////////////////////
    // auto generated stuff
    ////////////////////////////////////////////

    ButtonPanel = new javax.swing.JPanel();
    importBtn = new javax.swing.JButton();
    closeBtn = new javax.swing.JButton();
    PropertiesList = new javax.swing.JPanel();
    FilenamePanel = new javax.swing.JPanel();
    jLabel3 = new javax.swing.JLabel();
    FilenameLabel = new javax.swing.JLabel();
    selectFileBtn = new javax.swing.JButton();
    FrequencyPanel = new javax.swing.JPanel();
    FrequencyLabel = new javax.swing.JLabel();
    FrequencyCombo = new TimeFrequencyCombo();
    OriginPanel = new javax.swing.JPanel();
    jLabel7 = new javax.swing.JLabel();
    OriginLabel = new javax.swing.JLabel();
    selectOriginBtn = new javax.swing.JButton();
    DTGPanel = new javax.swing.JPanel();
    jLabel9 = new javax.swing.JLabel();
    _theDate = new javax.swing.JTextField("2001/01/30");

    /////////////////////////////////////////////////
    // button panel first
    //////////////////////////////////////////////////

    importBtn.setText("Import");
    ButtonPanel.add(importBtn);
    closeBtn.setText("Close");
    ButtonPanel.add(closeBtn);
    thisPanel.add(ButtonPanel, java.awt.BorderLayout.SOUTH);
    closeBtn.addActionListener(
        new ActionListener() {
          public void actionPerformed(final ActionEvent e) {
            doClose();
          }
        });
    importBtn.addActionListener(
        new ActionListener() {
          public void actionPerformed(final ActionEvent e) {
            doImport();
          }
        });

    ///////////////////////////////////////////////////
    // now the properties panel
    ///////////////////////////////////////////////////

    PropertiesList.setLayout(new java.awt.GridLayout(0, 1));

    jLabel3.setText("Filename:");
    FilenamePanel.add(jLabel3);
    FilenameLabel.setText("    blank    ");
    FilenamePanel.add(FilenameLabel);
    selectFileBtn.setPreferredSize(new java.awt.Dimension(33, 27));
    selectFileBtn.setToolTipText("Select file");
    selectFileBtn.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    selectFileBtn.setText("...");
    selectFileBtn.addActionListener(
        new ActionListener() {
          public void actionPerformed(final ActionEvent e) {
            doEditFilename();
          }
        });
    FilenamePanel.add(selectFileBtn);
    PropertiesList.add(FilenamePanel);

    FrequencyLabel.setText("Frequency:");
    FrequencyPanel.add(FrequencyLabel);
    FrequencyCombo.setPreferredSize(new java.awt.Dimension(100, 25));
    FrequencyPanel.add(FrequencyCombo);
    PropertiesList.add(FrequencyPanel);

    jLabel7.setText("Origin:");
    OriginPanel.add(jLabel7);
    OriginLabel.setText("    blank    ");
    OriginPanel.add(OriginLabel);
    selectOriginBtn.setPreferredSize(new java.awt.Dimension(33, 27));
    selectOriginBtn.setToolTipText("Select file");
    selectOriginBtn.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    selectOriginBtn.setText("...");
    selectOriginBtn.addActionListener(
        new ActionListener() {
          public void actionPerformed(final ActionEvent e) {
            editOrigin();
          }
        });
    OriginPanel.add(selectOriginBtn);
    PropertiesList.add(OriginPanel);

    //////////////////////////////////////////////////////
    // DTG
    /////////////////////////////////////////////////////

    jLabel9.setText("DTG (yyyy/mm/dd):");
    _theDate.setText("2001/01/30");
    _theDate.addFocusListener(
        new FocusAdapter() {
          public void focusLost(final FocusEvent e) {
            checkDTG();
          }
        });
    DTGPanel.add(jLabel9);
    DTGPanel.add(_theDate);
    PropertiesList.add(DTGPanel);

    final JPanel jp = new JPanel();
    jp.setLayout(new FlowLayout());
    jp.add(PropertiesList);

    thisPanel.add(jp, java.awt.BorderLayout.CENTER);
  }