Пример #1
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.");
   }
 }
  // Implementation of valueChanged
  public void valueChanged(ListSelectionEvent e) {
    if (e.getSource() == table.getSelectionModel()) {
      ListSelectionModel ls = table.getSelectionModel();

      int index = ls.getMinSelectionIndex();
      long id = (long) table.getValueAt(index, 0);

      updateFeesData(id);
    } else {
      ListSelectionModel ls = feestable.getSelectionModel();

      int index = ls.getMinSelectionIndex();

      float feespayed = (float) feestable.getValueAt(index, 1);
      float totalfees = (float) feestable.getValueAt(index, 2);

      feespayedlabel.setText("Fees Payed: " + feespayed);
      totalfeeslabel.setText("Total Fees: " + totalfees);

      if (totalfees - feespayed > 0) {
        feesduelabel.setText("Fees Due: " + (totalfees - feespayed));
      }

      panel_6.revalidate();
    }
  }
  // Fees update method
  private void updateFeesData(long id) {
    String columns[] = {"Course", "Fees Payed", "Total fees", "Installments"};
    try {
      Database db = new Database();

      panel_7.removeAll();

      feestablemodel = new MyTableModel(db.getFeeData(id), columns);

      feestable = new JTable(feestablemodel);
      feestable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
      feestable.getSelectionModel().addListSelectionListener(this);

      feesscrollpane = new JScrollPane(feestable);
      panel_7.add(feesscrollpane);

      // change fees payed label
      feespayedlabel.setText("Fees Payed");
      feesduelabel.setText("Fees Due");
      totalfeeslabel.setText("Total Fees");

      panel_7.revalidate();
    } catch (Exception e) {
      JOptionPane.showMessageDialog(this, e.getMessage(), null, JOptionPane.ERROR_MESSAGE);
    }
  }
Пример #4
0
 /**
  * Ovedrride the method so we can set the highlight label
  *
  * @param g Highlighted glyph
  */
 public void setHighlight(Glyph g) {
   super.setHighlight(g);
   if ((g == null) || !(g instanceof MetSymbol)) {
     highlightLabel.setText("   ");
     return;
   }
   highlightLabel.setText(" " + ((MetSymbol) g).getLabel());
 }
 /** Update the information. */
 private void updateInfo() {
   if (_info == null) return;
   if (_matchList.getModel().getSize() > 0) {
     T item = _matchList.getSelectedValue();
     _infoLabel.setText("Path:   " + _info.value(item));
     _infoLabel.setToolTipText(_info.value(item));
   } else _infoLabel.setText("No file selected");
 }
Пример #6
0
 // Renders the selected image
 protected void updateLabel(String name) {
   ImageIcon icon = createImageIcon("images/" + name + ".gif");
   picture.setIcon(icon);
   if (icon != null) {
     picture.setText(null);
   } else {
     picture.setText("Image not found");
   }
 }
Пример #7
0
  private void loadPreferences() {
    // grab the preferences so that they can be used to fill out the layout
    ThumbMakerPreferences myPreferences = ThumbMakerPreferences.getInstance();

    // x resolution text box
    xres.setText(myPreferences.getStringPref(ThumbMakerPreferences.RES_WIDTH_PREF_NAME));

    // y resolution text box
    yres.setText(myPreferences.getStringPref(ThumbMakerPreferences.RES_HEIGHT_PREF_NAME));

    // aspect ratio checkbox
    aspect.setSelected(
        myPreferences
            .getStringPref(ThumbMakerPreferences.DO_MAINTAIN_ASPECT_PREF_NAME)
            .equalsIgnoreCase(ThumbMakerPreferences.BOOLEAN_TRUE_STRING));

    // load the color values from the preferences
    int redValueNumber = myPreferences.getIntegerPref(ThumbMakerPreferences.RED_VALUE_PREF_NAME);
    int greenValueNumber =
        myPreferences.getIntegerPref(ThumbMakerPreferences.GREEN_VALUE_PREF_NAME);
    int blueValueNumber = myPreferences.getIntegerPref(ThumbMakerPreferences.BLUE_VALUE_PREF_NAME);

    // set the background color image
    colorBox.setBackground(new Color(redValueNumber, greenValueNumber, blueValueNumber));

    // red slider
    red.setValue(redValueNumber);
    redValue.setText("" + redValueNumber);

    // green slider
    green.setValue(greenValueNumber);
    greenValue.setText("" + greenValueNumber);

    // blue slider
    blue.setValue(blueValueNumber);
    blueValue.setText("" + blueValueNumber);

    // algorithm combo box
    algorithm.setSelectedIndex(
        myPreferences.getIntegerPref(ThumbMakerPreferences.RESIZE_ALG_PREF_NAME));

    // format combo box
    format.setSelectedIndex(
        myPreferences.getIntegerPref(ThumbMakerPreferences.THUMB_FORMAT_PREF_NAME));

    // prepend field
    prepend.setText(myPreferences.getStringPref(ThumbMakerPreferences.STRING_TO_PREPEND_PREF_NAME));

    // append field
    append.setText(myPreferences.getStringPref(ThumbMakerPreferences.STRING_TO_APPEND_PREF_NAME));

    // output folder field
    output.setText(
        (new File(myPreferences.getStringPref(ThumbMakerPreferences.FILE_PATH_STRING_PREF_NAME)))
            .getAbsolutePath());
  }
 private void updateCaretPositionText() {
   if (myErrorMessage != null) {
     myCaretPositionLabel.setText(
         IdeBundle.message("label.scope.editor.caret.position", myCaretPosition + 1));
   } else {
     myCaretPositionLabel.setText("");
   }
   myPositionPanel.setVisible(myErrorMessage != null);
   myCaretPositionLabel.setVisible(myErrorMessage != null);
   myPanel.revalidate();
 }
Пример #9
0
 /** Called when color slider values change. */
 public void stateChanged(ChangeEvent e) {
   JSlider slider = (JSlider) e.getSource();
   int val = slider.getValue();
   String s = "" + val;
   if (val < 100) s = "0" + s;
   if (val < 10) s = "0" + s;
   if (slider == red) redValue.setText(s);
   else if (slider == green) greenValue.setText(s);
   else if (slider == blue) blueValue.setText(s);
   Color c = new Color(red.getValue(), green.getValue(), blue.getValue());
   colorBox.setBackground(c);
 }
Пример #10
0
  public void save() {
    boolean isNoticed = false;
    if (!notice.isVisible()) {
      isNoticed = true;
      notice.setVisible(true);
      notice.setText("Saving...");
    }
    if (getOptions() != null) {
      DB database = null;
      try {
        database = factory.open(this.leveldbStore.getSelectedFile(), getOptions());
        DBIterator iterator = database.iterator();
        HashSet<byte[]> keys = new HashSet<>();

        for (iterator.seekToFirst(); iterator.hasNext(); iterator.next()) {
          keys.add(iterator.peekNext().getKey());
        }
        iterator.close();

        for (byte[] key : keys) {
          database.delete(key);
        }

        for (int i = 0; i < dataList.getModel().getSize(); ++i) {
          DBItem item = dataList.getModel().getElementAt(i);
          database.put(item.key, item.value);
        }
      } catch (Exception e) {
        JOptionPane.showMessageDialog(pane, "Unable to open database:\n" + e);
        e.printStackTrace();
      } finally {
        if (database != null) {
          try {
            database.close();
          } catch (IOException e) {
            JOptionPane.showMessageDialog(pane, "Unable to close database:\n" + e);
            e.printStackTrace();
          }
        }
        saveButton.setEnabled(false);
      }
    }
    if (isNoticed) {
      try {
        Thread.sleep(100);
      } catch (InterruptedException e) {
        e.printStackTrace();
      }
      notice.setVisible(false);
      notice.setText("");
    }
  }
Пример #11
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);
 }
  /*
   * Gets the user choice for font, style and size and redraws the text
   *     accordingly.
   */
  public void setSampleFont() {
    // Get the font name from the JComboBox
    fontName = (String) facenameCombo.getSelectedItem();

    sampleField.setText(textField.getText());

    // Get the font style from the JCheckBoxes
    fontStyle = 0;
    if (italicCheckBox.isSelected()) fontStyle += Font.ITALIC;
    if (boldCheckBox.isSelected()) fontStyle += Font.BOLD;

    // Get the font size
    fontSize = 0;

    fontSize = Integer.parseInt((String) sizeCombo.getSelectedItem());

    // THE FOLLOWING IS NO LONGER NEEDED
    //            if(smallButton.isSelected())
    //                  fontSize=SMALL;
    //            else if(mediumButton.isSelected())
    //                  fontSize=MEDIUM;
    //            else if(largeButton.isSelected())
    //                  fontSize=LARGE;

    // Set the font of the text field
    sampleField.setFont(new Font(fontName, fontStyle, fontSize));
    sampleField.setForeground(fontColor);
    sampleField.repaint();

    pack();
  } // end setSampleFont method
Пример #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.");
   }
 }
Пример #14
0
 /**
  * Set the label
  *
  * @param n The name of the station model
  */
 public void setName(String n) {
   // Make sure we got the label
   getLabelComponent();
   if (nameLabel != null) {
     nameLabel.setText(n);
   }
 }
Пример #15
0
 // Display question and answer choices
 public void readQuestionAnswer(int questionID) {
   lblmess.setText("  " + quizPossibleAnswers[questionID][0]);
   choice1.setText(quizPossibleAnswers[questionID][1]);
   choice2.setText(quizPossibleAnswers[questionID][2]);
   choice3.setText(quizPossibleAnswers[questionID][3]);
   choice4.setText(quizPossibleAnswers[questionID][4]);
   choice1.setSelected(true);
 }
Пример #16
0
  private void refreshLanguage() {
    uploadPrioLabel.setText(language.getString("Options.news.1.messageUploadPriority") + " (2)");
    downloadPrioLabel.setText(
        language.getString("Options.news.1.messageDownloadPriority") + " (2)");
    useOneConnectionForMessagesCheckBox.setText(
        language.getString("Options.news.1.useOneConnectionForMessages"));
    displayDaysLabel.setText(language.getString("Options.news.1.numberOfDaysToDisplay") + " (15)");
    downloadDaysLabel.setText(
        language.getString("Options.news.1.numberOfDaysToDownloadBackwards") + " (5)");
    messageBaseLabel.setText(language.getString("Options.news.1.messageBase") + " (news)");
    alwaysDownloadBackloadCheckBox.setText(
        language.getString("Options.news.1.alwaysDownloadBackload"));
    alwaysDownloadBackloadCheckBox.setToolTipText(
        language.getString("Options.news.1.alwaysDownloadBackload.tooltip"));

    final String minutes = language.getString("Options.common.minutes");

    minimumIntervalLabel.setText(
        language.getString("Options.news.3.minimumUpdateInterval") + " (" + minutes + ") (45)");
    concurrentUpdatesLabel.setText(
        language.getString("Options.news.3.numberOfConcurrentlyUpdatingBoards") + " (6)");

    automaticBoardUpdateCheckBox.setText(language.getString("Options.news.3.automaticBoardUpdate"));

    storeSentMessagesCheckBox.setText(language.getString("Options.news.1.storeSentMessages"));
    silentlyRetryCheckBox.setText(language.getString("Options.news.3.silentlyRetryFailedMessages"));

    final String off = language.getString("Options.common.off");
    altEditCheckBox.setText(
        language.getString("Options.miscellaneous.useEditorForWritingMessages") + " (" + off + ")");
  }
Пример #17
0
 public void blankScreen() {
   int numc = calCorrectAnswer();
   lblmess.setText("Your score is: " + numc + "/10");
   panel.remove(choice1);
   panel.remove(choice2);
   panel.remove(choice3);
   panel.remove(choice4);
   btnext.setText("Try again");
 }
Пример #18
0
 public void update(JTextArea area) {
   DBItem item = dataList.getSelectedValue();
   if (item != null && !isSet) {
     isSet = true;
     try {
       if (area == hexKey) {
         if (area.getText().isEmpty()) {
           return;
         }
         item.key =
             new BigInteger(area.getText().replaceAll("\n", "").replaceAll("%\\{EOL}", "\n"), 16)
                 .toByteArray();
         stringKey.setText(cutToLine(new String(item.key), 64));
         dataList.updateUI();
       } else if (area == stringKey) {
         if (area.getText().isEmpty()) {
           return;
         }
         item.key = area.getText().replaceAll("\n", "").replaceAll("%\\{EOL}", "\n").getBytes();
         hexKey.setText(cutToLine(LevelDBViewer.toHexString(item.key), 64));
         dataList.updateUI();
       } else if (area == hexValue) {
         item.value =
             new BigInteger(area.getText().replaceAll("\n", "").replaceAll("%\\{EOL}", "\n"), 16)
                 .toByteArray();
         stringValue.setText(cutToLine(new String(item.value), 64));
       } else if (area == stringValue) {
         item.value = area.getText().replaceAll("\n", "").replaceAll("%\\{EOL}", "\n").getBytes();
         hexValue.setText(cutToLine(LevelDBViewer.toHexString(item.value), 64));
       }
       notice.setVisible(false);
       notice.setText("");
       saveButton.setEnabled(true);
     } catch (Exception e) {
       notice.setVisible(true);
       notice.setText("Invalid number!");
     } finally {
       lengthLabel.setText(String.valueOf(item.value.length + item.key.length));
       keyLength.setText(String.valueOf(item.key.length));
       valueLength.setText(String.valueOf(item.value.length));
       isSet = false;
     }
   }
 }
Пример #19
0
 public void showDialog() {
   statusBar.setText(" ");
   setVisible(true);
   try {
     // Bring to front of other dialogs
     setSelected(true);
   } catch (PropertyVetoException e) {
     // ignore
   }
 }
Пример #20
0
 public void valueChanged(ListSelectionEvent e) {
   int tmp = 0;
   String stmp = "您目前选取:";
   int[] index = list.getSelectedIndices();
   for (int i = 0; i < index.length; i++) {
     tmp = index[i];
     stmp = stmp + s[tmp] + "  ";
   }
   label.setText(stmp);
 }
Пример #21
0
 public void actionPerformed(ActionEvent e) {
   // Invoked when an action occurs.
   if (e.getSource().equals(singleSizeUp)) {
     singleSize = singleSize * 2;
     singleSizeLabel.setText("Image height=" + singleSize);
   }
   if (e.getSource().equals(singleSizeDown)) {
     singleSize = Math.max(64, singleSize / 2);
     singleSizeLabel.setText("Image height=" + singleSize);
   }
   if (e.getSource().equals(seqSizeUp)) {
     seqSize = seqSize * 2;
     seqSizeLabel.setText("Image height=" + seqSize);
   }
   if (e.getSource().equals(seqSizeDown)) {
     seqSize = Math.max(64, seqSize / 2);
     seqSizeLabel.setText("Image height=" + seqSize);
   }
 }
Пример #22
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;
   }
 }
Пример #23
0
 void browse(String urlStr) {
   try {
     Desktop.getDesktop().browse(new URI(urlStr));
   } catch (Exception ex) {
     showDialog();
     statusBar.setText(ex.getLocalizedMessage());
     if (JConsole.isDebug()) {
       ex.printStackTrace();
     }
   }
 }
Пример #24
0
  public static void refreshCalendar(int month, int year) {
    // instantiation
    String[] months = {
      "January",
      "February",
      "March",
      "April",
      "May",
      "June",
      "July",
      "August",
      "September",
      "October",
      "November",
      "December"
    };
    int numoday, startom; // Number Of Days, Start Of Month

    // Allow/disallow buttons
    prev.setEnabled(true);
    next.setEnabled(true);
    if (month == 0 && year <= ryear) {
      prev.setEnabled(false);
    } // Cannot set an appointment back in time
    if (month == 11 && year >= ryear + 50) {
      next.setEnabled(false);
    } // Too early to set an appointment
    lmonth.setText(months[month]); // Refresh the month label (at the top)
    lmonth.setBounds(
        160 - lmonth.getPreferredSize().width / 2, 25, 180, 25); // Re-align label with calendar
    cyear.setSelectedItem(String.valueOf(year)); // Select the correct year in the combo box

    // deletes current table
    for (int i = 0; i < 6; i++) {
      for (int j = 0; j < 7; j++) {
        mcal.setValueAt(null, i, j);
      }
    }

    // Get first day of month and number of days
    GregorianCalendar cal = new GregorianCalendar(year, month, 1);
    numoday = cal.getActualMaximum(GregorianCalendar.DAY_OF_MONTH);
    startom = cal.get(GregorianCalendar.DAY_OF_WEEK);

    // Create calendar
    for (int i = 1; i <= numoday; i++) {
      int row = new Integer((i + startom - 2) / 7);
      int column = (i + startom - 2) % 7;
      mcal.setValueAt(i, row, column);
    }

    // Apply renderers
    Cal.setDefaultRenderer(Cal.getColumnClass(0), new tblCalendarRenderer());
  }
Пример #25
0
  public Piece pickNextPiece() {
    if (adversary.getValue() == 0 && happy.getValue() == 0) {
      adStat.setText(adversaryOff);
      adHappy.setText(happyOff);
      return (super
          .pickNextPiece()); // not to mess with the sequence of random numbers for test mode
    }

    if (adversary.getValue() != 0 && happy.getValue() != 0) {
      adversary.setValue(0);
      adversary.repaint();
    }

    if (random.nextInt(100) <= adversary.getValue()) {
      adStat.setText(adversaryOn);
      return getWorstPiece(true);
    } else {
      adStat.setText(adversaryOff);
    }
    if (random.nextInt(100) <= happy.getValue()) {
      adHappy.setText(happyOn);
      return getWorstPiece(false);
    } else {
      adHappy.setText(happyOff);
    }
    return (super.pickNextPiece());
  }
Пример #26
0
 /**
  * This function re-computes the total number of hours for the selected period. It is ran every
  * time the user edits a text field specifying the number of hours for a particular top-level
  * project. Percentage labels are also updated.
  */
 private void recomputeTotal() {
   double total = 0;
   for (Row row : rows.values()) {
     try {
       row.hours = Double.parseDouble(row.hoursTF.getText());
       total += row.hours;
       row.hoursTF.setForeground(normalColour);
     } catch (NumberFormatException e) {
       row.hoursTF.setForeground(errorColour);
       totalLabel.setText("ERROR");
       totalLabel.setForeground(errorColour);
       return;
     }
   }
   totalLabel.setText(decimalFormat.format(total));
   totalLabel.setForeground(normalColour);
   for (Row row : rows.values()) {
     String percentS = decimalFormat.format(total == 0 ? 0 : 100 * row.hours / total);
     row.percentL.setText("(" + percentS + "%)");
   }
   pack();
 }
Пример #27
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;
   }
 }
Пример #28
0
  /**
   * This method checks if the current server is valid. If it is valid then it checks if there is
   * authentication required
   *
   * @return true if the server exists and can be accessed
   */
  protected boolean canAccessServer() {
    // Try reading the public.serv file to see if we need a username/proj
    JTextField projFld = null;
    JTextField userFld = null;
    JComponent contents = null;
    JLabel label = null;
    boolean firstTime = true;
    while (true) {
      int status = checkIfServerIsOk();
      if (status == STATUS_OK) {
        break;
      }
      if (status == STATUS_ERROR) {
        setState(STATE_UNCONNECTED);
        return false;
      }
      if (projFld == null) {
        projFld = new JTextField("", 10);
        userFld = new JTextField("", 10);
        GuiUtils.tmpInsets = GuiUtils.INSETS_5;
        contents =
            GuiUtils.doLayout(
                new Component[] {
                  GuiUtils.rLabel("User ID:"), userFld, GuiUtils.rLabel("Project #:"), projFld,
                },
                2,
                GuiUtils.WT_N,
                GuiUtils.WT_N);
        label = new JLabel(" ");
        contents = GuiUtils.topCenter(label, contents);
        contents = GuiUtils.inset(contents, 5);
      }
      String lbl =
          (firstTime
              ? "The server: " + getServer() + " requires a user ID & project number for access"
              : "Authentication for server: " + getServer() + " failed. Please try again");
      label.setText(lbl);

      if (!GuiUtils.showOkCancelDialog(null, "ADDE Project/User name", contents, null)) {
        setState(STATE_UNCONNECTED);
        return false;
      }
      firstTime = false;
      String userName = userFld.getText().trim();
      String project = projFld.getText().trim();
      if ((userName.length() > 0) && (project.length() > 0)) {
        passwords.put(getServer(), new String[] {userName, project});
      }
    }
    return true;
  }
  /** Update the status of the GUI based on any changes in the game object. */
  private void updateStatus() {
    if (game.donePlacingShips()) {
      // Kill the ship highlight and disable the vertical/horizontal buttons.
      humanGrid.setHoverShape(null);
      hButton.setEnabled(false);
      vButton.setEnabled(false);
    } else {
      int len = game.placingLength();
      boolean horiz = game.placingHorizontal();
      humanGrid.setHoverShape(new Dimension(horiz ? len : 1, horiz ? 1 : len));
    }

    message.setText(game.getStatus());
    repaint();
  }
Пример #30
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);
 }