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());
  }
示例#2
0
  // Initializing this component.
  private void jbInit() {
    callStackTable.addFocusListener(
        new FocusListener() {
          public void focusGained(FocusEvent e) {
            callStackTable_focusGained(e);
          }

          public void focusLost(FocusEvent e) {
            callStackTable_focusLost(e);
          }
        });
    callStackTable.setTableHeader(null);
    callStackTable.setDefaultRenderer(callStackTable.getColumnClass(0), getCellRenderer());
    scrollPane = new JScrollPane(callStackTable);
    setVisibleRows(DEFAULT_VISIBLE_ROWS);
    scrollPane.setLocation(0, 27);
    setBorder(BorderFactory.createEtchedBorder());
    // this.setLayout(null);
    this.setLayout(new GridBagLayout());
    nameLbl.setText("Call Stack");
    nameLbl.setBounds(new Rectangle(3, 4, 70, 23));
    nameLbl.setFont(Utilities.labelsFont);

    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.BOTH;
    c.ipadx = 0;
    c.ipady = 0;
    c.weightx = 1;
    c.weighty = 1;
    c.gridwidth = 7;
    c.gridheight = 1;
    c.anchor = GridBagConstraints.PAGE_END;
    c.gridx = 0;
    c.gridy = 2;
    this.add(scrollPane, c);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.ipadx = 0;
    c.ipady = 0;
    c.weightx = 1;
    c.weighty = 0.0;
    c.gridwidth = 3;
    c.gridheight = 1;
    c.anchor = GridBagConstraints.FIRST_LINE_START;
    c.gridx = 0;
    c.gridy = 0;
    c.insets = new Insets(5, 0, 0, 0);
    this.add(nameLbl, c);
  }
  /** Constructs a new MemorySegmentComponent. */
  public MemorySegmentComponent() {
    dataFormat = Format.DEC_FORMAT;
    listeners = new Vector();
    errorEventListeners = new Vector();
    highlightIndex = new Vector();
    segmentTable = new JTable(getTableModel());
    segmentTable.setDefaultRenderer(segmentTable.getColumnClass(0), getCellRenderer());
    startEnabling = -1;
    endEnabling = -1;

    JTextField tf = new JTextField();
    tf.setFont(Utilities.bigBoldValueFont);
    tf.setBorder(null);
    DefaultCellEditor editor = new DefaultCellEditor(tf);
    segmentTable.getColumnModel().getColumn(getColumnValue()).setCellEditor(editor);

    jbInit();
  }