コード例 #1
0
 /** Listener to handle button actions */
 public void actionPerformed(ActionEvent e) {
   // Check if the user pressed the remove button
   if (e.getSource() == remove_button) {
     int row = table.getSelectedRow();
     model.removeRow(row);
     table.clearSelection();
     table.repaint();
     valueChanged(null);
   }
   // Check if the user pressed the remove all button
   if (e.getSource() == remove_all_button) {
     model.clearAll();
     table.setRowSelectionInterval(0, 0);
     table.repaint();
     valueChanged(null);
   }
   // Check if the user pressed the filter button
   if (e.getSource() == filter_button) {
     filter.showDialog();
     if (filter.okPressed()) {
       // Update the display with new filter
       model.setFilter(filter);
       table.repaint();
     }
   }
   // Check if the user pressed the start button
   if (e.getSource() == start_button) {
     start();
   }
   // Check if the user pressed the stop button
   if (e.getSource() == stop_button) {
     stop();
   }
   // Check if the user wants to switch layout
   if (e.getSource() == layout_button) {
     details_panel.remove(details_soap);
     details_soap.removeAll();
     if (details_soap.getOrientation() == JSplitPane.HORIZONTAL_SPLIT) {
       details_soap = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
     } else {
       details_soap = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
     }
     details_soap.setTopComponent(request_panel);
     details_soap.setRightComponent(response_panel);
     details_soap.setResizeWeight(.5);
     details_panel.add(details_soap, BorderLayout.CENTER);
     details_panel.validate();
     details_panel.repaint();
   }
   // Check if the user is changing the reflow option
   if (e.getSource() == reflow_xml) {
     request_text.setReflowXML(reflow_xml.isSelected());
     response_text.setReflowXML(reflow_xml.isSelected());
   }
 }
コード例 #2
0
ファイル: AlertPanel.java プロジェクト: nologic/nabs
  public void actionPerformed(ActionEvent e) {
    Object o = e.getSource();

    if (o instanceof JMenuItem) {
      for (int i = 0; i < markItems.length; i++) {
        if (markItems[i] == o) {
          synchronized (alerts) {
            markAlerts(table.getSelectedRows(), i);
          }
          table.repaint();
          return;
        }
      }

      if (o == deleteAlerts) {
        deleteSelectedAlerts();
      } else if (o == deleteAlertsForHost) {
        deleteAlertsForHost();
      } else if (o == deleteAlertTypeForHost) {
        deleteAlertTypeForHost();
      } else if (o == moveToDetails) {
        moveToDetails();
      }
    }
  }
コード例 #3
0
 @Override
 public void mouseMoved(MouseEvent e) {
   Point pt = e.getPoint();
   int prevRow = row;
   int prevCol = col;
   row = table.rowAtPoint(pt);
   col = table.columnAtPoint(pt);
   if (row < 0 || col < 0) {
     row = -1;
     col = -1;
   }
   // >>>> HyperlinkCellRenderer.java
   // @see
   // http://java.net/projects/swingset3/sources/svn/content/trunk/SwingSet3/src/com/sun/swingset3/demos/table/HyperlinkCellRenderer.java
   if (row == prevRow && col == prevCol) {
     return;
   }
   Rectangle repaintRect;
   if (row >= 0 && col >= 0) {
     Rectangle r = table.getCellRect(row, col, false);
     if (prevRow >= 0 && prevCol >= 0) {
       repaintRect = r.union(table.getCellRect(prevRow, prevCol, false));
     } else {
       repaintRect = r;
     }
   } else {
     repaintRect = table.getCellRect(prevRow, prevCol, false);
   }
   table.repaint(repaintRect);
   // <<<<
   // table.repaint();
 }
コード例 #4
0
  /**
   * scrolls to selected line number
   *
   * @param lineNumber the line number to scroll to
   * @param toTop display on the top row
   * @return true if .. , false if
   */
  public boolean scrollToLine(final int lineNumber, final boolean toTop) {
    final int lineNumbers = m_sourceModel.getLineNumbers();

    if ((lineNumber >= 0) && (lineNumber < lineNumbers)) {
      int viewColumnIndex = 0;

      Rectangle rect = m_sourceCode.getCellRect(lineNumber, viewColumnIndex, true);

      JViewport viewport = (JViewport) m_sourceCode.getParent();

      if (toTop) {
        Rectangle lastRect = m_sourceCode.getCellRect(lineNumbers - 1, viewColumnIndex, true);
        viewport.scrollRectToVisible(lastRect);
      }

      Point pt = viewport.getViewPosition();
      rect.setLocation(rect.x - pt.x, rect.y - pt.y);

      // Scroll the area into view

      viewport.scrollRectToVisible(rect);

      m_sourceCode.repaint();

      return true;
    }
    return false;
  }
コード例 #5
0
ファイル: MainFrame.java プロジェクト: gaurav/taxref
  /**
   * 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();
  }
コード例 #6
0
 @SuppressWarnings("unchecked")
 @Override
 public int loop() {
   synchronized (lock) {
     try {
       if (!ui.isVisible()) handler.stopMod(getName());
       World world = minecraft.getWorld();
       JTable list = ui.getList();
       DefaultTableModel model = (DefaultTableModel) list.getModel();
       TableRowSorter<TableModel> sorter = (TableRowSorter<TableModel>) list.getRowSorter();
       if (world != null) {
         Player currentPlayer = minecraft.getPlayer();
         int playerX = (int) java.lang.Math.round(currentPlayer.getX());
         int playerY = (int) java.lang.Math.round(currentPlayer.getY());
         int playerZ = (int) java.lang.Math.round(currentPlayer.getZ());
         ArrayList<Block> blocks = new ArrayList<Block>();
         for (int x = playerX - radius; x < playerX + radius; x++)
           for (int y = playerY - radius; y < playerY + radius; y++)
             for (int z = playerZ - radius; z < playerZ + radius; z++)
               if (world.getBlockIDAt(x, y, z) == blockID) blocks.add(new Block(x, y, z));
         label:
         for (int row = 0; row < model.getRowCount(); row++) {
           int x = (Integer) model.getValueAt(row, 1);
           int y = (Integer) model.getValueAt(row, 2);
           int z = (Integer) model.getValueAt(row, 3);
           for (Block block : blocks) {
             if (x == block.getX() && y == block.getY() && z == block.getZ()) {
               model.setValueAt(getDistanceTo(x, y, z, currentPlayer), row, 0);
               continue label;
             }
           }
           model.removeRow(row);
         }
         label:
         for (Block block : blocks) {
           for (int row = 0; row < model.getRowCount(); row++) {
             int x = (Integer) model.getValueAt(row, 1);
             int y = (Integer) model.getValueAt(row, 2);
             int z = (Integer) model.getValueAt(row, 3);
             if (x == block.getX() && y == block.getY() && z == block.getZ()) continue label;
           }
           model.addRow(
               new Object[] {
                 getDistanceTo(block.getX(), block.getY(), block.getZ(), minecraft.getPlayer()),
                 block.getX(),
                 block.getY(),
                 block.getZ()
               });
         }
         sorter.sort();
         list.repaint();
       } else {
         for (int i = model.getRowCount() - 1; i >= 0; i--) model.removeRow(i);
       }
     } catch (Exception exception) {
     }
   }
   return 500;
 }
コード例 #7
0
ファイル: LibraryApp.java プロジェクト: smarr/AmbientTalk-lib
 public void setAvailable(ATBookWrapper book, boolean isAvailable) {
   int row = bookTableModel_.findRow(book);
   if (row >= 0) {
     bookTableCellRenderer_.setAvailable(row, isAvailable);
     statusCellRenderer_.setAvailable(row, isAvailable);
     bookTable_.repaint();
   }
 }
コード例 #8
0
 @Override
 public void mouseExited(MouseEvent e) {
   if (row >= 0 && col >= 0) {
     table.repaint(table.getCellRect(row, col, false));
   }
   row = -1;
   col = -1;
 }
コード例 #9
0
 @Override
 public void windowDeactivated(WindowEvent e) {
   dao.getAllCategories();
   category.setList(dao.getCategoryList().getList());
   ((CategoryTableModel) table.getModel()).setList(category.getList());
   table.repaint();
   this.repaint();
   this.revalidate();
 }
コード例 #10
0
 private void hideIndirectDependencies() {
   List<DependencyDTO> filteredList = new ArrayList<DependencyDTO>();
   List<DependencyDTO> allDependencies = dataControl.listDependencies(fromSelected, toSelected);
   for (DependencyDTO dependency : allDependencies) {
     if (!dependency.isIndirect) filteredList.add(dependency);
   }
   dependencyTable.setModel(new DependencyTableModel(filteredList, dataControl));
   dependencyTable.repaint();
 }
コード例 #11
0
ファイル: MainFrame.java プロジェクト: gaurav/taxref
  /**
   * Set the DarwinCSV to match this against.
   *
   * @param against The DarwinCSV object to match against.
   */
  private void matchAgainst(DarwinCSV against) {
    // System.err.println("matchAgainst: " + against);

    // Reset previous match information.
    currentMatch = null;
    table.repaint();

    // If all we're doing is a reset, we can get out now.
    if (against == null) return;

    // long t1 = System.currentTimeMillis();
    currentMatch = currentCSV.getRowIndex().matchAgainst(against.getRowIndex());
    table.repaint();
    matchInfoPanel.matchChanged(currentMatch);
    // long t2 = System.currentTimeMillis();

    // System.err.println("matchAgainst finished: " + (t2 - t1) + " ms");
  }
コード例 #12
0
  /** Update views. */
  protected void updateViews() {
    ptmodel.fireTableDataChanged();
    hmodel.fireTableDataChanged();
    //		if(ptmodel.getRowCount()>0)
    //			((ResizeableTableHeader)threads.getTableHeader()).resizeAllColumns();
    //		if(hmodel.getRowCount()>0)
    //			((ResizeableTableHeader)history.getTableHeader()).resizeAllColumns();
    threads.repaint();
    history.repaint();

    if (bpp != null) {
      List sel_bps = new ArrayList();
      for (int i = 0; i < threads_clone.length; i++) {
        if (threads_clone[i].getActivity() != null)
          sel_bps.add(threads_clone[i].getActivity().getBreakpointId());
      }
      bpp.setSelectedBreakpoints((String[]) sel_bps.toArray(new String[sel_bps.size()]));
    }
  }
コード例 #13
0
 @Override
 public void resetColorMouse() {
   listS = sotfwareBN.selectAll();
   Color color =
       new Color(
           listS.get(0).getColorMouseClick().getRed(),
           listS.get(0).getColorMouseClick().getGreen(),
           listS.get(0).getColorMouseClick().getBlue());
   tableSB32.setSelectionBackground(color);
   tableSB32.repaint();
 }
コード例 #14
0
ファイル: DataPanel.java プロジェクト: Serabe/geogebra
    public void enableAll() {

      for (int i = 0; i < selectionList.length; ++i) {
        if (selectionList[i] == false) {
          statController.updateSelectedDataList(i, true);
          selectionList[i] = true;
        }
      }
      rowHeader.repaint();
      table.repaint();
    }
コード例 #15
0
 @Override
 public void resetColorWord() {
   listS = sotfwareBN.selectAll();
   Color color =
       new Color(
           listS.get(0).getColorWord().getRed(),
           listS.get(0).getColorWord().getGreen(),
           listS.get(0).getColorWord().getBlue());
   tableSB32.setForeground(color);
   tableSB32.repaint();
 }
コード例 #16
0
  private void obtenerValorPorcentaje(java.math.BigDecimal valorDescuento) {

    try {
      //////////////////////////// ESTO ES PARA OBTENER EL PORCENTAJE
      java.math.BigDecimal parcial =
          new java.math.BigDecimal(
              tabla.getValueAt(fila, buscarColumna("Parcial", tabla)) == null
                      || tabla
                          .getValueAt(fila, buscarColumna("Parcial", tabla))
                          .toString()
                          .trim()
                          .isEmpty()
                  ? "0.00"
                  : tabla.getValueAt(fila, buscarColumna("Parcial", tabla)).toString().trim());

      java.math.BigDecimal descuento =
          new java.math.BigDecimal(
              valorDescuento == null ? "0.00" : valorDescuento.toString().trim());

      java.math.BigDecimal multiplicacion = descuento.multiply(new java.math.BigDecimal("100.00"));
      java.math.BigDecimal division = cero;

      if (parcial.compareTo(cero) > 0)
        division = multiplicacion.divide(parcial, 15, java.math.RoundingMode.HALF_UP);
      tabla.setValueAt(division.toPlainString(), fila, buscarColumna("%", tabla));

      /// PARA PONER EL SUBTOTAL
      //            table.setValueAt(parcial.subtract(division), fila, buscarColumna("Subtotal"));
      //            if (division.compareTo(mDIShrimp.getCero()) == 0){
      //                table.setValueAt(parcial.subtract(division), fila,
      // buscarColumna("Subtotal"));
      //            } else {
      //                table.setValueAt(division.subtract(parcial), fila,
      // buscarColumna("Subtotal"));
      //            }

      tabla.repaint();
    } catch (Exception e) {
      shrimp.helper.JDVentanaMensajes.showMessageDialog(
          new javax.swing.JFrame(),
          "Ha ocurrido un error inesperado en el formulario",
          javax.swing.JOptionPane.ERROR_MESSAGE,
          javax.swing.JOptionPane.DEFAULT_OPTION,
          e,
          null);
    }

    //        ///PARA PONER EL VALOR ENTERO EN EL CAMPO CANTIDAD
    //        tabla.setValueAt(cantidad.toString().substring(0, cantidad.toString().indexOf(".")),
    //                fila, buscarColumna("Cantidad", tabla));
    tabla.updateUI();
  }
コード例 #17
0
  private void setSizeAndDimensions(
      @NotNull JTable table,
      @NotNull JBPopup popup,
      @NotNull RelativePoint popupPosition,
      @NotNull List<UsageNode> data) {
    JComponent content = popup.getContent();
    Window window = SwingUtilities.windowForComponent(content);
    Dimension d = window.getSize();

    int width = calcMaxWidth(table);
    width = (int) Math.max(d.getWidth(), width);
    Dimension headerSize = ((AbstractPopup) popup).getHeaderPreferredSize();
    width = Math.max((int) headerSize.getWidth(), width);
    width = Math.max(myWidth, width);

    if (myWidth == -1) myWidth = width;
    int newWidth = Math.max(width, d.width + width - myWidth);

    myWidth = newWidth;

    int rowsToShow = Math.min(30, data.size());
    Dimension dimension = new Dimension(newWidth, table.getRowHeight() * rowsToShow);
    Rectangle rectangle = fitToScreen(dimension, popupPosition, table);
    dimension = rectangle.getSize();
    Point location = window.getLocation();
    if (!location.equals(rectangle.getLocation())) {
      window.setLocation(rectangle.getLocation());
    }

    if (!data.isEmpty()) {
      TableScrollingUtil.ensureSelectionExists(table);
    }
    table.setSize(dimension);
    // table.setPreferredSize(dimension);
    // table.setMaximumSize(dimension);
    // table.setPreferredScrollableViewportSize(dimension);

    Dimension footerSize = ((AbstractPopup) popup).getFooterPreferredSize();

    int newHeight =
        (int) (dimension.height + headerSize.getHeight() + footerSize.getHeight())
            + 4 /* invisible borders, margins etc*/;
    Dimension newDim = new Dimension(dimension.width, newHeight);
    window.setSize(newDim);
    window.setMinimumSize(newDim);
    window.setMaximumSize(newDim);

    window.validate();
    window.repaint();
    table.revalidate();
    table.repaint();
  }
コード例 #18
0
ファイル: MainGui.java プロジェクト: normannexo/Excel2SQL
 @Override
 public void bracketEvent(String content) {
   System.out.println(content);
   Column c = sheet.getColumnByName(content);
   if (c != null) {
     c.setIgnore(false);
     System.out.println("yes");
     if (sbColumnNames == null) {
       setColumnNamesPattern(sheet);
     }
     paneSyntax.highlightPattern(sbColumnNames.toString());
     table.repaint();
   }
 }
コード例 #19
0
  @Override
  public void scrollToConstructionStep() {
    int rowCount = table.getRowCount();
    if (rowCount == 0) return;

    int step = kernel.getConstructionStep();
    int row = 0;
    for (int i = Math.max(step, 0); i < rowCount; i++) {
      if (data.getConstructionIndex(i) <= step) row = i;
      else break;
    }

    table.setRowSelectionInterval(row, row);
    table.repaint();
  }
コード例 #20
0
 // call the ontology printer and update the textPane
 @Override
 public synchronized void mouseReleased(MouseEvent arg0) {
   // TODO Auto-generated method stub
   int selectionRow = table.getSelectedRow();
   int selectionCol = table.getSelectedColumn();
   if (selectionRow != -1 && selectionCol == 2) {
     OFDebugLogger tmp = OFDebugLogger.getAllInstances().get(table.getValueAt(selectionRow, 1));
     Boolean boo = (Boolean) table.getValueAt(selectionRow, selectionCol);
     table.setValueAt(!boo, selectionRow, selectionCol);
     tmp.setFlagToFollow(!boo); // .setFlagToFollow( !boo, this);
     update();
     model.fireTableDataChanged();
   }
   table.repaint();
 }
コード例 #21
0
ファイル: AlertPanel.java プロジェクト: nologic/nabs
 public void valueChanged(ListSelectionEvent e) {
   Object o = e.getSource();
   if (o == table.getSelectionModel()) {
     int row = table.getSelectedRow();
     if (row >= 0) {
       AlertItem item = model.getAlert(row);
       editor.showAlert(item);
     }
   } else if (o == list) {
     if (!e.getValueIsAdjusting()) {
       model.setSelectedIPs(list.getSelectedValues());
       table.repaint();
     }
   }
 }
コード例 #22
0
ファイル: BookView.java プロジェクト: loitv/MyProject
 @SuppressWarnings({"rawtypes", "unchecked"})
 public void refreshTable(Vector list) {
   TableModel model = bookDetails.getModel();
   Vector cols = new Vector();
   cols.addElement("ISBN");
   cols.addElement("Title");
   cols.addElement("Author");
   cols.addElement("Category");
   cols.addElement("Price");
   cols.addElement("Total");
   cols.addElement("Remain");
   model = new DefaultTableModel(list, cols);
   bookDetails.setModel(model);
   bookDetails.repaint();
 }
コード例 #23
0
 @Override
 public void resetColorRowTable() {
   listS = sotfwareBN.selectAll();
   Color colorL =
       new Color(
           listS.get(0).getColorLight().getRed(),
           listS.get(0).getColorLight().getGreen(),
           listS.get(0).getColorLight().getBlue());
   Color colorD =
       new Color(
           listS.get(0).getColorDark().getRed(),
           listS.get(0).getColorDark().getGreen(),
           listS.get(0).getColorDark().getBlue());
   StripedTableCellRenderer.installInColumn(tableSB32, colorL, null, colorD, null);
   tableSB32.repaint();
 }
コード例 #24
0
 private void addButtonActionPerfomed(ActionEvent evt) {
   try {
     WorkCard.getWork().addCard(Integer.parseInt(tficon.getText()), tfcolor.getText());
     if (searchFrame.getSearchRequest() != null) {
       Search search = new CardSearch();
       model.setArrayOfCards(
           (ArrayList<Card>) search.regularSearch(searchFrame.getSearchRequest()));
     }
   } catch (NotFoundException ex) {
     log.debug(ex.getMessage());
   }
   tficon.setText("");
   tfcolor.setText("");
   jTable1.revalidate();
   jTable1.repaint();
 }
コード例 #25
0
 private void loadTemplate(String filename) {
   if (filename.equals("")) {
     return;
   }
   File file = new File(filename);
   if (!file.exists()) {
     return;
   }
   TemplateHandle handle = new TemplateHandle(filename);
   List<TemplateInfo> temps = handle.getTemplateInfos();
   // 绑定到表格
   templateInfos = temps;
   tableModel.setColumns(temps);
   table.repaint();
   table.updateUI();
 }
コード例 #26
0
ファイル: DataPanel.java プロジェクト: Serabe/geogebra
    public void mousePressed(MouseEvent e) {
      // check if we clicked in checkbox icon area
      int index = this.locationToIndex(e.getPoint());
      Rectangle rect = getCellBounds(index, index);
      boolean iconClicked = rect != null && e.getX() - rect.x < 16; // distance from left border			
      if (iconClicked) {
        // icon clicked: toggle enable/disable data
        selectionList[this.getSelectedIndex()] = !selectionList[this.getSelectedIndex()];
        statController.updateSelectedDataList(
            this.getSelectedIndex(), selectionList[this.getSelectedIndex()]);
        btnEnableAll.setEnabled(!isAllEnabled());

        table.repaint();
        repaint();
        return;
      }
    }
コード例 #27
0
            public void actionPerformed(ActionEvent e) {
              /* Identify max radio on */
              double maxRadioOn = 0;
              int maxRadioOnIndex = -1;
              for (int i = 0; i < moteTrackers.size(); i++) {
                MoteTracker mt = moteTrackers.get(i);
                if (mt.getRadioOnRatio() > maxRadioOn) {
                  maxRadioOn = mt.getRadioOnRatio();
                  maxRadioOnIndex = i;
                }
              }
              if (maxRadioOnIndex >= 0) {
                tableMaxRadioOnIndex = maxRadioOnIndex;
              }

              table.repaint();
            }
コード例 #28
0
  public void update() {
    int tickerWidth = setupColumnWidths();

    setupTableHeaders();
    setupScrollPane(tickerWidth);
    table.invalidate();
    table.validate();
    table.repaint();

    invalidate();
    validate();
    repaint();

    mainFrame.getHeaderPanel().invalidate();
    mainFrame.getHeaderPanel().validate();
    mainFrame.getHeaderPanel().repaint();
  }
コード例 #29
0
  public void atualizaLista(JTable lista, String nome) throws DaoException {

    DefaultTableModel dtm = (DefaultTableModel) table.getModel();

    ImageIcon editar = new ImageIcon(CadFuncionario.class.getResource("/br/com/images/editar.png"));
    ImageIcon excluir =
        new ImageIcon(CadFuncionario.class.getResource("/br/com/images/icon_excluir.png"));

    ImageIcon relatorio =
        new ImageIcon(CadFuncionario.class.getResource("/br/com/images/repo.png")); // mudar icon

    TableColumnModel columnModel = table.getColumnModel();

    JTableRenderer renderer = new JTableRenderer();
    JTableRenderer renderer1 = new JTableRenderer();
    JTableRenderer renderer2 = new JTableRenderer();

    renderer.setValue(editar);
    renderer.setHorizontalAlignment(JLabel.CENTER);
    columnModel.getColumn(5).setCellRenderer(renderer);

    renderer1.setValue(excluir);
    renderer1.setHorizontalAlignment(JLabel.CENTER);
    columnModel.getColumn(7).setCellRenderer(renderer1);

    renderer2.setValue(relatorio);
    renderer2.setHorizontalAlignment(JLabel.CENTER);
    columnModel.getColumn(6).setCellRenderer(renderer2);

    dtm.setRowCount(0);
    List<FolhaPagamento> listaFolha = new ArrayList<FolhaPagamento>();
    listaFolha = folhaDao.consultarPagamento(nome);
    String dados[] = new String[5];
    for (FolhaPagamento obj : listaFolha) {
      dados[0] = String.valueOf(obj.getCodDep());
      dados[1] = obj.getNomeFunc();
      dados[2] = obj.getProfissaoFunc();
      dados[3] = String.valueOf(obj.getTotalFunc());
      dados[4] = String.valueOf(obj.getDataInicio()) + " / " + String.valueOf(obj.getDataFim());
      ((DefaultTableModel) table.getModel()).addRow(dados);
    }
    table.setDefaultRenderer(Object.class, new TableCellRenderer());
    table.repaint();
  }
コード例 #30
0
    public void mouseClicked(MouseEvent e) {
      TableColumnModel colModel = table.getColumnModel();
      int columnModelIndex = colModel.getColumnIndexAtX(e.getX());
      int modelIndex = colModel.getColumn(columnModelIndex).getModelIndex();

      if (modelIndex < 0) return;
      if (sortCol == modelIndex) isSortAsc = !isSortAsc;
      else sortCol = modelIndex;

      for (int i = 0; i < colNames.length; i++) {
        TableColumn column = colModel.getColumn(i);
        column.setHeaderValue(getColumnName(column.getModelIndex()));
      }
      table.getTableHeader().repaint();

      Collections.sort(rowData, new MyComparator(isSortAsc));
      table.tableChanged(new TableModelEvent(MyTableModel.this));
      table.repaint();
    }