Пример #1
0
    public void stateChanged(ChangeEvent e) {
      JSpinner source = (JSpinner) e.getSource();
      if (source.getName().equals("Hour")) {
        calendar.set(Calendar.HOUR_OF_DAY, getSelectedHour());
        return;
      }
      if (source.getName().equals("Year")) {

        calendar.set(Calendar.YEAR, getSelectedYear());
        dayPanel.removeAll();
        this.flushWeekAndDayPanal(calendar);
        dayPanel.revalidate();
        dayPanel.updateUI();
        return;
      }
      if (source.getName().equals("Month")) {
        calendar.set(Calendar.MONTH, getSelectedMonth() - 1);

        dayPanel.removeAll();
        this.flushWeekAndDayPanal(calendar);
        dayPanel.revalidate();
        dayPanel.updateUI();
        return;
      }
    }
  // 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);
    }
  }
  // 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();
    }
  }
 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();
 }
 private void setToComponent(final JComponent cmp, final boolean requestFocus) {
   myMatchingCountPanel.removeAll();
   myMatchingCountPanel.add(cmp, BorderLayout.CENTER);
   myMatchingCountPanel.revalidate();
   myMatchingCountPanel.repaint();
   if (requestFocus) {
     SwingUtilities.invokeLater(
         new Runnable() {
           public void run() {
             myPatternField.getTextField().requestFocusInWindow();
           }
         });
   }
 }
  private void buildKitData(Kits selectedKit) {
    final int ST_SPACE = 25;
    kitDataPanel.removeAll();
    Box container = Box.createVerticalBox();
    setComponentSize(container, 400, PAGE_HEIGHT);
    JLabel kitID = new JLabel(Integer.toString(selectedKit.getKitID()));
    JLabel kitName = new JLabel(selectedKit.getName());
    JLabel kitDesc = new JLabel(selectedKit.getDescription());
    JLabel lp = new JLabel("----- Listed Parts -----");

    // align elements to the left collum
    // all the arguments can be left as KitID.LEFT because we only need any instance of a JComponent
    // to use the LEFT keyword
    kitID.setHorizontalAlignment(kitID.LEFT);
    kitName.setHorizontalAlignment(kitID.LEFT);
    kitDesc.setHorizontalAlignment(kitID.LEFT);
    lp.setHorizontalAlignment(kitID.LEFT);

    // add elements to container
    container.add(kitID);
    container.add(kitName);
    container.add(kitDesc);
    container.add(Box.createVerticalStrut(ST_SPACE));
    container.add(lp);

    // add part data
    TreeMap<Integer, Parts> kitParts = selectedKit.getListOfParts();
    for (Integer i : kitParts.keySet()) {
      Parts selectedPart = kitParts.get(i);
      Box holder = Box.createHorizontalBox();
      Box section1 = Box.createVerticalBox();
      Box section2 = Box.createVerticalBox();
      int imageIndex = selectedPart.getImageIndex();
      String PID = Integer.toString(selectedPart.getPartNumber());
      String PName = selectedPart.getName();
      String PDesc = selectedPart.getDesc();

      setComponentSize(holder, 400, 60);

      // add elements to section1
      section1.add(new JLabel("Part " + i));
      section1.add(new JLabel(images.getIcon(imageIndex - 1)));

      // add elements to section2
      section2.add(new JLabel("Part #: " + PID));
      section2.add(new JLabel("Part name: " + PName));
      section2.add(new JLabel("Part desc: " + PDesc));

      // add sections to holder
      holder.add(section1);
      holder.add(Box.createHorizontalStrut(ST_SPACE));
      holder.add(section2);

      // add holder to container
      container.add(holder);
    }

    // add the build items to the container
    buildQuantity = new JTextField("Enter number of kits to build");
    build = new JButton("Add to build queue");
    setComponentSize(buildQuantity, 400, 20);
    setComponentSize(buildQuantity, 400, 20);
    build.addActionListener(this);
    container.add(buildQuantity);
    container.add(build);

    // add container to kitDataPanel
    kitDataPanel.add(container);
    kitDataPanel.revalidate();
  }