Exemplo n.º 1
2
  public MainPanel() {
    super(new BorderLayout());

    InputMap im = table.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    KeyStroke tab = KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0);
    KeyStroke enter = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0);
    KeyStroke stab = KeyStroke.getKeyStroke(KeyEvent.VK_TAB, InputEvent.SHIFT_DOWN_MASK);
    KeyStroke senter = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.SHIFT_DOWN_MASK);
    im.put(tab, im.get(enter));
    im.put(stab, im.get(senter));

    final Color orgColor = table.getSelectionBackground();
    final Color tflColor = this.getBackground();
    table.addFocusListener(
        new FocusListener() {
          @Override
          public void focusGained(FocusEvent e) {
            table.setSelectionForeground(Color.WHITE);
            table.setSelectionBackground(orgColor);
          }

          @Override
          public void focusLost(FocusEvent e) {
            table.setSelectionForeground(Color.BLACK);
            table.setSelectionBackground(tflColor);
          }
        });

    table.setComponentPopupMenu(new TablePopupMenu());
    add(new JScrollPane(table));
    setPreferredSize(new Dimension(320, 240));
  }
Exemplo n.º 2
0
  public CombatViewer() {
    super("Combat Tracker");
    setLookAndFeel();
    setSize(500, 400);
    FlowLayout layout = new FlowLayout(FlowLayout.CENTER, 10, 10);
    setLayout(layout);

    String[] columnNames = {"First Name", "Last Name", "Sport", "# of Years", "Vegetarian"};

    Object[][] data = {
      {"Kathy", "Smith", "Snowboarding", new Integer(5), new Boolean(false)},
      {"John", "Doe", "Rowing", new Integer(3), new Boolean(true)},
      {"Sue", "Black", "Knitting", new Integer(2), new Boolean(false)},
      {"Jane", "White", "Speed reading", new Integer(20), new Boolean(true)},
      {"Joe", "Brown", "Pool", new Integer(10), new Boolean(false)}
    };

    JTable table = new JTable(data, columnNames);

    JScrollPane scrollPane = new JScrollPane(table);
    table.setFillsViewportHeight(true);

    panel1.setLayout(new BorderLayout());
    panel1.add(table.getTableHeader(), BorderLayout.PAGE_START);
    panel1.add(table, BorderLayout.CENTER);
    add(panel1);

    panel2.setLayout(new FlowLayout(FlowLayout.CENTER, 10, 10));
    panel2.add(testBox);
    add(panel2);

    setVisible(true);
  }
Exemplo n.º 3
0
  /**
   * Initialisiere den unteren Bereichs des Benchmark-Panels mit einer Tabelle von Schätzungen und
   * Vorhersagen.
   */
  private void initTablePane() {
    JPanel tablePane = new JPanel(new GridLayout(1, 1));
    tablePane.add(new JScrollPane(benchmarkTable));
    benchmarkTable.setDefaultRenderer(Object.class, new BenchmarkTableCellRenderer());
    benchmarkTable.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent e) {
            super.mouseClicked(e);

            int selRowIndex = benchmarkTable.getSelectedRow();
            int selColIndex = benchmarkTable.getSelectedColumn();

            String user = (String) benchmarkTableModel.getValueAt(selRowIndex, 0);

            if (selColIndex == 0) {
              new UserStatsWindow(user).setVisible(true);
              return;
            }

            Object cellVal = benchmarkTableModel.getValueAt(selRowIndex, selColIndex);
            if (!(cellVal instanceof String)) {
              return;
            }
            String repoName = (String) cellVal;

            Project p = new Project(user, repoName);
            if (metricsData.containsKey(p)) {
              new ProjectMetricsWindow(metricsData.get(p)).setVisible(true);
            }
          }
        });
    add(tablePane, BorderLayout.CENTER);
  }
Exemplo n.º 4
0
  private Component table() {
    String[] titles = {
      "Year",
      "Starting Balance",
      "Starting Principal",
      "Withdrawals",
      "Appreciation",
      "Deposits",
      "Ending Balance"
    };
    tableModel = new DefaultTableModel(titles, 0);
    for (int i = 0; i < 12800; i++) {
      tableModel.addRow(
          new Integer[] {1900 + i, 10000 + i, 8000 + i, 50 + i, 905 + i, 2000 + i, 12000 + i});
    }

    JTable table = new CustomTable(tableModel);

    int preferredWidth = 0;
    for (int i = 0; i < table.getColumnCount(); i++) {
      int width = packColumn(table, i, 2);
      preferredWidth += width;
    }
    Dimension preferredSize = new Dimension(preferredWidth, 400);
    table.setPreferredScrollableViewportSize(preferredSize);
    this.setMinimumSize(preferredSize);

    JScrollPane scrollPane = new JScrollPane(table);
    return scrollPane;
  }
Exemplo n.º 5
0
  // This method from http://www.exampledepot.com/egs/javax.swing.table/PackCol.html
  public int packColumn(JTable table, int vColIndex, int margin) {
    DefaultTableColumnModel colModel = (DefaultTableColumnModel) table.getColumnModel();
    TableColumn col = colModel.getColumn(vColIndex);
    int width = 0;

    // Get width of column header
    TableCellRenderer renderer = col.getHeaderRenderer();
    if (renderer == null) {
      renderer = table.getTableHeader().getDefaultRenderer();
    }
    Component comp =
        renderer.getTableCellRendererComponent(table, col.getHeaderValue(), false, false, 0, 0);
    width = comp.getPreferredSize().width;

    // Get maximum width of column data
    for (int r = 0; r < table.getRowCount(); r++) {
      renderer = table.getCellRenderer(r, vColIndex);
      comp =
          renderer.getTableCellRendererComponent(
              table, table.getValueAt(r, vColIndex), false, false, r, vColIndex);
      width = Math.max(width, comp.getPreferredSize().width);
    }

    // Add margin
    width += 2 * margin;

    // Set the width
    col.setPreferredWidth(width);

    return width;
  }
  /** Observer method to update the insuranceCompanyTable */
  public void updateTable() {

    tableData.update(
        model.getInsuranceCompanies(), model.getSortingStrategy()); // Populate the table

    // Check if InsuranceCompany map is empty
    if (model.getInsuranceCompanies().size() > 0) {
      selectRow();
      int selectedCompanyId =
          Integer.valueOf(
              (String)
                  insuranceCompaniesTable.getValueAt(insuranceCompaniesTable.getSelectedRow(), 0));
      controller.selectInsuranceCompany(selectedCompanyId);
      recordEdited = -1; // Reset the recordEdited field
    } else {
      // If all records are deleted, clear the edit panel
      companyIdTextField.setText("");
      companyNameTextField.setText("");
      urlTextField.setText("");
      generalDescriptionTextField.setText("");
      insuranceTypesTextField.setText("");
      telephoneTextField.setText("");
      percentageTextField.setText("");
    }
  }
 /**
  * This method updates the input and action maps with new ToggleAction.
  *
  * @param isToggleDynamic
  * @param isToggleLarger
  * @param key
  * @param keyStroke
  */
 private void installToggleAction(
     boolean isToggleDynamic, boolean isToggleLarger, String key, String keyStroke) {
   Action action = new ToggleAction(isToggleDynamic, isToggleLarger);
   KeyStroke ks = KeyStroke.getKeyStroke(keyStroke);
   table.getInputMap().put(ks, key);
   table.getActionMap().put(key, action);
 }
 /**
  * This method updates the input and action maps with a new ColumnAction.
  *
  * @param isSelectedColumn
  * @param isAdjust
  * @param key
  * @param keyStroke
  */
 private void installColumnAction(
     boolean isSelectedColumn, boolean isAdjust, String key, String keyStroke) {
   Action action = new ColumnAction(isSelectedColumn, isAdjust);
   KeyStroke ks = KeyStroke.getKeyStroke(keyStroke);
   table.getInputMap().put(ks, key);
   table.getActionMap().put(key, action);
 }
  /**
   * This method implements the TableModelListener
   *
   * @param e The event to listen for.
   */
  @Override
  public void tableChanged(TableModelEvent e) {
    if (!isColumnDataIncluded) {
      return;
    }

    //  A cell has been updated

    if (e.getType() == TableModelEvent.UPDATE) {
      int column = table.convertColumnIndexToView(e.getColumn());

      //  Only need to worry about an increase in width for this cell

      if (isOnlyAdjustLarger) {
        int row = e.getFirstRow();
        TableColumn tableColumn = table.getColumnModel().getColumn(column);

        if (tableColumn.getResizable()) {
          int width = getCellDataWidth(row, column);
          updateTableColumn(column, width);
        }
      } //	Could be an increase of decrease so check all rows
      else {
        adjustColumn(column);
      }
    } //  The update affected more than one column so adjust all columns
    else {
      adjustColumns();
    }
  }
  // Initializes this component.
  private void jbInit() {
    segmentTable.addFocusListener(
        new FocusListener() {
          public void focusGained(FocusEvent e) {
            segmentTable_focusGained(e);
          }

          public void focusLost(FocusEvent e) {
            segmentTable_focusLost(e);
          }
        });
    segmentTable.setTableHeader(null);
    scrollPane = new JScrollPane(segmentTable);
    scrollPane.setMinimumSize(new Dimension(getTableWidth(), 0));

    setLayout(new BorderLayout(0, 0));

    determineColumnWidth();
    nameLbl.setPreferredSize(new Dimension(getTableWidth(), 25));
    nameLbl.setMinimumSize(new Dimension(getTableWidth(), 0));
    nameLbl.setFont(Utilities.labelsFont);

    segmentTable.setFont(Utilities.valueFont);
    setBorder(BorderFactory.createEtchedBorder());

    setMinimumSize(new Dimension(getTableWidth(), 0));

    this.add(nameLbl, BorderLayout.NORTH);
    this.add(scrollPane, BorderLayout.CENTER);
  }
Exemplo n.º 11
0
 private void setSelection(int rowAnchor, int rowLead, int colAnchor, int colLead) {
   setAnchor(rowAnchor, colAnchor);
   setLead(rowLead, colLead);
   table.setRowSelectionInterval(
       clamp(rowAnchor, 0, numUsableRows), clamp(rowLead, 0, numUsableRows));
   table.setColumnSelectionInterval(colAnchor, colLead);
 }
Exemplo n.º 12
0
 /** 删除 */
 private void processDeleteEvent() {
   int index = timeTable.getSelectedRow();
   if (index == -1) return;
   JTimeTableModel model = (JTimeTableModel) timeTable.getModel();
   if (index < model.timeList.size()) model.timeList.removeElementAt(index);
   timeTable.updateUI();
 }
Exemplo n.º 13
0
  /**
   * Set the current open DarwinCSV. You should really, really, really setCurrentCSV(null) before
   * you load a new DarwinCSV.
   *
   * @param csv The new DarwinCSV object.
   */
  private void setCurrentCSV(DarwinCSV csv) {
    // Clear the old currentCSV object and matchAgainst object.
    currentCSV = null;
    matchAgainst(null);

    // Load the new currentCSV object.
    currentCSV = csv;
    table.removeAll();
    table.setDefaultRenderer(Name.class, this);

    // Set the currentCSV
    // TODO: This causes an exception occasionally, because we shouldn't
    // be calling setModel outside of the Event Queue thread; however, we're
    // currently in a worker thread, so dipping back into the Event thread
    // would just cause more problems. Sorry!
    if (csv != null) {
      table.setModel(currentCSV.getRowIndex());
    } else {
      table.setModel(blankDataModel);
    }

    columnInfoPanel.loadedFileChanged(csv);
    columnInfoPanel.columnChanged(-1);
    table.repaint();
  }
  // 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();
    }
  }
 public void mousePressed(MouseEvent e) {
   if (e.getButton() != MouseEvent.BUTTON1) {
     return;
   }
   if (e.getClickCount() != 2) {
     return;
   }
   JTable table = (JTable) e.getSource();
   Point p = e.getPoint();
   int row = table.rowAtPoint(p);
   if (row < 0) {
     return;
   }
   PickerTableModel model = getDataModel();
   ICFInternetISOCountryObj o =
       (ICFInternetISOCountryObj) model.getValueAt(row, COLID_ROW_HEADER);
   invokeWhenChosen.choseISOCountry(o);
   try {
     Container cont = getParent();
     while ((cont != null) && (!(cont instanceof JInternalFrame))) {
       cont = cont.getParent();
     }
     if (cont != null) {
       ((JInternalFrame) cont).setClosed(true);
     }
   } catch (Exception x) {
   }
 }
 public void mousePressed(MouseEvent e) {
   if (e.getButton() != MouseEvent.BUTTON1) {
     return;
   }
   if (e.getClickCount() != 2) {
     return;
   }
   JTable table = (JTable) e.getSource();
   Point p = e.getPoint();
   int row = table.rowAtPoint(p);
   if (row < 0) {
     return;
   }
   FinderTableModel model = getDataModel();
   ICFSecurityISOTimezoneObj o =
       (ICFSecurityISOTimezoneObj) model.getValueAt(row, COLID_ROW_HEADER);
   if (o == null) {
     return;
   }
   JInternalFrame frame = swingSchema.getISOTimezoneFactory().newViewEditJInternalFrame(o);
   ((ICFSecuritySwingISOTimezoneJPanelCommon) frame).setPanelMode(CFJPanel.PanelMode.View);
   if (frame == null) {
     return;
   }
   Container cont = getParent();
   while ((cont != null) && (!(cont instanceof JInternalFrame))) {
     cont = cont.getParent();
   }
   if (cont != null) {
     JInternalFrame myInternalFrame = (JInternalFrame) cont;
     myInternalFrame.getDesktopPane().add(frame);
     frame.setVisible(true);
     frame.show();
   }
 }
Exemplo n.º 17
0
 public void secureDelete() {
   int rw = tblItems.getSelectedRow();
   if (rw == -1) {
     JOptionPane.showMessageDialog(frm, "No item selected", "Error", JOptionPane.ERROR_MESSAGE);
     return;
   }
   int idx = tblItems.convertRowIndexToModel(rw);
   if (JOptionPane.showConfirmDialog(
           frm,
           "Delete " + store.plainName(idx) + "?",
           "Confirm Delete",
           JOptionPane.YES_NO_OPTION)
       != JOptionPane.YES_OPTION) return;
   File del = store.delete(idx);
   store.fireTableDataChanged();
   if (del != null) {
     if (del.delete()) {
       // successful
       needsSave = true;
     } else {
       System.err.println("Delete " + del.getAbsolutePath() + " failed");
     }
   }
   updateStatus();
 }
Exemplo n.º 18
0
 public MyRenderComponent(
     JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int col) {
   super();
   this.table = table;
   this.col = col;
   if (value != null) {
     setText(value.toString());
   } else {
     setText("");
   }
   setOpaque(false);
   setFont(UIManager.getFont("TableHeader.font"));
   setForeground(UIManager.getColor("TableHeader.foreground"));
   setHorizontalAlignment(JLabel.CENTER);
   setHorizontalTextPosition(SwingConstants.LEADING);
   setBorder(UIManager.getBorder("TableHeader.cellBorder"));
   if ((JTattooUtilities.getJavaVersion() >= 1.6)
       && (UIManager.getLookAndFeel() instanceof AbstractLookAndFeel)) {
     RowSorter rowSorter = table == null ? null : table.getRowSorter();
     List keyList = rowSorter == null ? null : rowSorter.getSortKeys();
     if ((keyList != null) && (keyList.size() > 0)) {
       RowSorter.SortKey sortKey = (RowSorter.SortKey) keyList.get(0);
       if (sortKey.getColumn() == table.convertColumnIndexToModel(col)) {
         AbstractIconFactory iconFactory =
             ((AbstractLookAndFeel) UIManager.getLookAndFeel()).getIconFactory();
         if (sortKey.getSortOrder().equals(SortOrder.ASCENDING)) {
           setIcon(iconFactory.getUpArrowIcon());
         } else if (sortKey.getSortOrder().equals(SortOrder.DESCENDING)) {
           setIcon(iconFactory.getDownArrowIcon());
         }
       }
     }
   }
   gv = ColorHelper.getGrayValue(AbstractLookAndFeel.getTheme().getRolloverColor());
 }
Exemplo n.º 19
0
 @Override
 public void actionPerformed(ActionEvent e) {
   // Object o = table.getModel().getValueAt(table.getSelectedRow(), 0);
   int row = table.convertRowIndexToModel(table.getEditingRow());
   Object o = table.getModel().getValueAt(row, 0);
   JOptionPane.showMessageDialog(table, "Editing: " + o);
 }
Exemplo n.º 20
0
  private Vector<String> getColumnNames() {
    Vector<String> columnNames = new Vector<String>();

    for (int i = 0; i < jTable1.getColumnCount(); i++) columnNames.add(jTable1.getColumnName(i));

    return columnNames;
  }
Exemplo n.º 21
0
    /**
     * Create a Transferable to use as the source for a data transfer.
     *
     * @param c The component holding the data to be transfered. This argument is provided to enable
     *     sharing of TransferHandlers by multiple components.
     * @return The representation of the data to be transfered.
     */
    protected Transferable createTransferable(JComponent c) {
      Object[] values = null;
      if (c instanceof JList) {
        values = ((JList) c).getSelectedValues();
      } else if (c instanceof JTable) {
        JTable table = (JTable) c;
        int[] rows = table.getSelectedRows();
        if (rows != null) {
          values = new Object[rows.length];
          for (int i = 0; i < rows.length; i++) {
            values[i] = table.getValueAt(rows[i], 0);
          }
        }
      }
      if (values == null || values.length == 0) {
        return null;
      }

      StringBuffer plainBuf = new StringBuffer();
      StringBuffer htmlBuf = new StringBuffer();

      htmlBuf.append("<html>\n<body>\n<ul>\n");

      for (Object obj : values) {
        String val = ((obj == null) ? "" : obj.toString());
        plainBuf.append(val + "\n");
        htmlBuf.append("  <li>" + val + "\n");
      }

      // remove the last newline
      plainBuf.deleteCharAt(plainBuf.length() - 1);
      htmlBuf.append("</ul>\n</body>\n</html>");

      return new FileTransferable(plainBuf.toString(), htmlBuf.toString(), values);
    }
Exemplo n.º 22
0
  public static Component CreateRouteTable(Object[][] data, Dimension totalSize) {
    String[] columnNames = {
      "Route #",
      "Carrier",
      "Dep. Airport",
      "Dep. Time",
      "Arr. Airport",
      "Arr. Time",
      "Price",
      "status"
    };

    // disable cell editing
    JTable routeTable =
        new JTable(data, columnNames) {
          public boolean isCellEditable(int rowIndex, int vColIndex) {
            return false;
          };
        };
    routeTable.getTableHeader().setReorderingAllowed(false);
    routeTable.getTableHeader().setResizingAllowed(false);
    JScrollPane routeTableScroll =
        new JScrollPane(routeTable); // create the routes table in a scrollPane

    routeTableScroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    routePanelWidth = (totalSize.width * 3 / 4) * 48 / 100;
    routePanelHeight = totalSize.height * 45 / 100;
    routeTableScroll.setPreferredSize(new Dimension(routePanelWidth, routePanelHeight));
    return routeTableScroll;
  }
  // 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);
    }
  }
Exemplo n.º 24
0
  private void prepareComponent() {
    CloseEventHandler closeEventHandler = new CloseEventHandler();
    addWindowListener(closeEventHandler);

    Container contentPane = getContentPane();
    contentPane.setLayout(new BorderLayout());

    JPanel contentPanel = new JPanel();
    // JPanel contentPanel = new FormDebugPanel();
    contentPane.add(contentPanel, BorderLayout.CENTER);

    CellConstraints cc = new CellConstraints();
    FormLayout layout =
        new FormLayout(
            "4dlu, d:grow, 4dlu", // columns
            "4dlu, p, 2dlu, fill:100dlu:grow, 4dlu, "
                + // rows
                "p, 2dlu, p, 4dlu"); // btn rows
    PanelBuilder contentPB = new PanelBuilder(layout, contentPanel);
    int columnCount = layout.getColumnCount();
    int rowCount = layout.getRowCount();

    JLabel label = new JLabel(Localizer.getString("MediaTypeCondEditor_ConditionToAdd"));
    contentPB.add(label, cc.xywh(2, 2, 1, 1));

    mediaTypeModel = new MediaTypeModel();
    mediaTypeTable = new JTable(mediaTypeModel);
    JTableHeader tableHeader = mediaTypeTable.getTableHeader();
    tableHeader.setResizingAllowed(false);
    tableHeader.setReorderingAllowed(false);
    // adjust column witdh of checkbox
    JCheckBox box = (JCheckBox) mediaTypeTable.getDefaultRenderer(Boolean.class);
    TableColumn column = mediaTypeTable.getColumnModel().getColumn(0);
    column.setMaxWidth(box.getPreferredSize().width + 2);
    column.setMinWidth(box.getPreferredSize().width + 2);
    mediaTypeTable.getColumnModel().getColumn(1).setCellRenderer(new MediaTypeCellRenderer());
    // ToolTipManager.sharedInstance().registerComponent( mediaTypeTable );
    contentPB.add(new JScrollPane(mediaTypeTable), cc.xywh(2, 4, 1, 1));

    // button bar
    contentPB.add(new JSeparator(), cc.xywh(1, rowCount - 3, columnCount, 1));

    JButton okBtn = new JButton(Localizer.getString("OK"));
    okBtn.addActionListener(new OkBtnListener());
    okBtn.setDefaultCapable(true);
    okBtn.setRequestFocusEnabled(true);

    JButton cancelBtn = new JButton(Localizer.getString("Cancel"));
    cancelBtn.addActionListener(closeEventHandler);

    JPanel btnPanel = ButtonBarFactory.buildOKCancelBar(okBtn, cancelBtn);
    contentPB.add(btnPanel, cc.xywh(2, rowCount - 1, columnCount - 2, 1));

    setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    getRootPane().setDefaultButton(okBtn);

    pack();
    setLocationRelativeTo(getParent());
  }
Exemplo n.º 25
0
  /** Sets the call stack with the given vector of method names. */
  public void setContents(Vector newMethodNames) {
    methodNames = (Vector) newMethodNames.clone();
    callStackTable.revalidate();

    Rectangle r = callStackTable.getCellRect(newMethodNames.size() - 1, 0, true);
    callStackTable.scrollRectToVisible(r);
    repaint();
  }
 /** Returns the coordinates of the top left corner of the value at the given index. */
 public Point getCoordinates(int index) {
   JScrollBar bar = scrollPane.getVerticalScrollBar();
   Rectangle r = segmentTable.getCellRect(index, 1, true);
   segmentTable.scrollRectToVisible(r);
   setTopLevelLocation();
   return new Point(
       (int) (r.getX() + topLevelLocation.getX()), (int) (r.getY() + topLevelLocation.getY()));
 }
Exemplo n.º 27
0
 @Override
 public void mouseExited(MouseEvent e) {
   if (row >= 0 && col >= 0) {
     table.repaint(table.getCellRect(row, col, false));
   }
   row = -1;
   col = -1;
 }
Exemplo n.º 28
0
 // region Private Methods
 private static void stopCellEditing(JTable table) {
   if (table.getRowCount() > 0) {
     TableCellEditor editor = table.getCellEditor();
     if (editor != null) {
       editor.stopCellEditing();
     }
   }
 }
Exemplo n.º 29
0
  public hostelStatus() {
    setTitle("Hostel");
    connect();
    updateRecord();

    JFrame fr = new JFrame();
    Toolkit tkt = fr.getToolkit();
    Dimension frsize = tkt.getScreenSize();
    setBounds(frsize.width / 4, frsize.height / 12, frsize.width / 2, frsize.height / 8);
    setLayout(null);

    cn = getContentPane();
    cn.setBackground(new Color(190, 180, 170));

    setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

    tl = new JLabel("Current Hostels Status");
    tl.setFont(new Font("Engravers MT", 1, 25));
    tl.setForeground(new Color(247, 251, 249));

    p1 = new JPanel();
    p1.setBounds(0, 0, 600, 50);
    p1.add(tl);
    p1.setBackground(new Color(31, 88, 166));
    cn.add(p1);

    b1 = new JButton("LOAD");
    b1.setMnemonic('L');
    b1.addActionListener(new dispListener());
    b1.setBounds(230, 320, 120, 30);

    b2 = new JButton("EXIT");
    b2.setMnemonic('X');
    b2.addActionListener(new exitListener());
    b2.setBounds(350, 320, 100, 30);

    cn.add(b1);
    cn.add(b2);

    table = new JTable(data, col);
    table.setFont(new Font("Serif", Font.BOLD, 16));
    table.setBackground(new Color(250, 250, 250));
    table.setEnabled(false);

    JScrollPane jsp = new JScrollPane(table);
    jsp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    jsp.setBounds(5, 100, 590, 200);
    cn.add(jsp);

    screensize = Toolkit.getDefaultToolkit().getScreenSize();

    setSize(600, 400);
    setVisible(true);
    setVisible(true);
    setResizable(true);
    connect();
  }
Exemplo n.º 30
0
 private void setTableColumnWidths() {
   table.sizeColumnsToFit(JTable.AUTO_RESIZE_NEXT_COLUMN);
   TableColumn column = null;
   column = table.getColumnModel().getColumn(0);
   column.setMinWidth(KEY_COL_WIDTH);
   column.setPreferredWidth(KEY_COL_WIDTH);
   column = table.getColumnModel().getColumn(1);
   column.setPreferredWidth(VAL_COL_WIDTH);
 }