List of usage examples for javax.swing.table TableRowSorter TableRowSorter
public TableRowSorter(M model)
TableRowSorter
using model
as the underlying TableModel
. From source file:com.microsoft.alm.plugin.idea.git.ui.vcsimport.ImportForm.java
public void setTeamProjectTable(final ServerContextTableModel tableModel, final ListSelectionModel selectionModel) { teamProjectTable.setModel(tableModel); teamProjectTable.setSelectionModel(selectionModel); // Setup table sorter final RowSorter<TableModel> sorter = new TableRowSorter<TableModel>(tableModel); teamProjectTable.setRowSorter(sorter); // Attach an index converter to fix the indexes if the user sorts the list tableModel.setSelectionConverter(new TableModelSelectionConverter() { @Override// w w w . ja va2s .co m public int convertRowIndexToModel(int viewRowIndex) { if (viewRowIndex >= 0) { return teamProjectTable.convertRowIndexToModel(viewRowIndex); } return viewRowIndex; } }); }
From source file:com.db2eshop.gui.component.table.api.GenericTable.java
/** {@inheritDoc} */ @Override/* w ww . ja v a2s.c om*/ @SuppressWarnings("unchecked") public void afterPropertiesSet() throws Exception { if (!getClass().equals(GenericTable.class)) { entityClazz = (Class<T>) UIForUtil.retrieveUIFor(this); if (entityClazz != null) { tableName = entityClazz.getSimpleName(); Set<String> metaColumnNamesSet = EntityUtil.getRowMeta(entityClazz).keySet(); List<String> metaColumnNames = new LinkedList<String>(metaColumnNamesSet); Collections.sort(metaColumnNames, new Comparator<String>() { @Override public int compare(String o1, String o2) { if (o1 != null && o1.equalsIgnoreCase("id")) { return -1; } return 0; } }); columnNames = metaColumnNames.toArray(new String[metaColumnNames.size()]); this.setModel(EntityUtil.asTableModel(entityClazz)); TableRowSorter<DefaultTableModel> sorter = new TableRowSorter<DefaultTableModel>( (DefaultTableModel) this.getModel()); Class<?>[] columnTypes = ClassUtil.getTypesOfProperties(columnNames, this.entityClazz); for (int i = 0; i < columnTypes.length; i++) { if (java.lang.Number.class.isAssignableFrom(columnTypes[i])) { sorter.setComparator(i, new Comparator<Long>() { @Override public int compare(Long arg0, Long arg1) { if (arg0 == arg1) { return 0; } if (arg1 > arg0) { return -1; } return 1; } }); } } this.setRowSorter(sorter); } } tableEntityModelListener = new TableEntityModelListener<T>(this); this.getModel().addTableModelListener(tableEntityModelListener); }
From source file:com.microsoft.alm.plugin.idea.common.ui.checkout.CheckoutForm.java
public void setRepositoryTable(final ServerContextTableModel tableModel, final ListSelectionModel selectionModel) { repositoryTable.setModel(tableModel); repositoryTable.setSelectionModel(selectionModel); // Setup table sorter RowSorter<TableModel> sorter = new TableRowSorter<TableModel>(tableModel); repositoryTable.setRowSorter(sorter); // Attach an index converter to fix the indexes if the user sorts the list tableModel.setSelectionConverter(new TableModelSelectionConverter() { @Override/*from www.j av a2 s .c o m*/ public int convertRowIndexToModel(int viewRowIndex) { if (viewRowIndex >= 0) { return repositoryTable.convertRowIndexToModel(viewRowIndex); } return viewRowIndex; } }); }
From source file:DefaultsDisplay.java
protected void initFilters(JTable table) { TableRowSorter sorter = new TableRowSorter(table.getModel()); table.setRowSorter(sorter);/*from w w w .j a va 2 s . co m*/ if (visualsFilter == null) { visualsFilter = new RowFilter<UIDefaultsTableModel, Integer>() { public boolean include(Entry<? extends UIDefaultsTableModel, ? extends Integer> entry) { UIDefaultsTableModel model = entry.getModel(); Object defaultsValue = model.getValueAt(entry.getIdentifier().intValue(), UIDefaultsTableModel.VALUE_COLUMN); return defaultsValue instanceof Color || defaultsValue instanceof Font || defaultsValue instanceof Icon; } }; } if (onlyVisualsCheckBox.isSelected()) { sorter.setRowFilter(visualsFilter); } }
From source file:com.frostwire.gui.bittorrent.PartialFilesDialog.java
private void setupTextFilter() { GridBagConstraints c;/*from w ww. j a v a 2 s . co m*/ _filter = new LabeledTextField("Filter files", 30); _filter.setMinimumSize(_filter.getPreferredSize()); // fix odd behavior textBasedFilter = new RowFilterExtension(_filter, 2); _filter.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { if (_filter.getText() == null || _filter.getText().equals("")) { _table.setRowSorter(null); return; } _checkBoxToggleAll.setSelected(false); TableRowSorter<TorrentTableModel> sorter = new TableRowSorter<TorrentTableModel>(_model); sorter.setRowFilter(textBasedFilter); _table.setRowSorter(sorter); } }); c = new GridBagConstraints(); c.gridx = 0; c.gridy = 1; c.gridwidth = 2; c.gridheight = 1; c.anchor = GridBagConstraints.WEST; c.weightx = 1.0; c.insets = new Insets(5, 5, 5, 5); panel.add(_filter, c); }
From source file:MainFrame.MainFrame.java
public MainFrame() { //Create menu this.menuBar = new JMenuBar(); this.menuProxy = new JMenu("Proxy"); this.menuBar.add(menuProxy); this.cbMenuItem = new JCheckBoxMenuItem("? proxy"); this.cbMenuItem.setMnemonic(KeyEvent.VK_C); ActionListener aListener = new ActionListener() { public void actionPerformed(ActionEvent event) { AbstractButton aButton = (AbstractButton) event.getSource(); boolean selected = aButton.getModel().isSelected(); if (selected) { SingleDataHolder.getInstance().isProxyActivated = true; SingleDataHolder.getInstance().proxyIpAdress = MainFrame.this.proxyIpAdress.getText(); SingleDataHolder.getInstance().proxyPort = Integer.parseInt(MainFrame.this.proxyPort.getText()); SingleDataHolder.getInstance().proxyLogin = MainFrame.this.proxyLogin.getText(); SingleDataHolder.getInstance().proxyPassword = String .valueOf(MainFrame.this.proxyPassword.getPassword()); } else { SingleDataHolder.getInstance().isProxyActivated = false; }/*w w w . ja va2 s . c om*/ } }; this.cbMenuItem.addActionListener(aListener); this.proxyIpAdress = new JTextField(); this.proxyPort = new JTextField(); this.proxyLogin = new JTextField(); ; this.proxyPassword = new JPasswordField(); this.menuProxy.add(this.cbMenuItem); this.menuProxy.add(new JLabel("IP ?")); this.menuProxy.add(this.proxyIpAdress); this.menuProxy.add(new JLabel("? ")); this.menuProxy.add(this.proxyPort); this.menuProxy.add(new JLabel("")); this.menuProxy.add(this.proxyLogin); this.menuProxy.add(new JLabel("")); this.menuProxy.add(this.proxyPassword); this.setJMenuBar(this.menuBar); communicator = new HttpCommunicator(); myActionListener = new mainFrameActionListener(); mainPanel = new JPanel(new BorderLayout()); this.setContentPane(mainPanel); JPanel P = new JPanel(new FlowLayout(FlowLayout.LEFT, 15, 5)); mainPanel.add(P, BorderLayout.NORTH); //Create Group label labelGroup = new JLabel(""); P.add(labelGroup); //Create Group combo comboGroup = new JComboBox(); comboGroup.addItem("?"); comboGroup.addActionListener(myActionListener); P.add(comboGroup); //Create Date label labelDate = new JLabel(""); P.add(labelDate); //Create Date combo comboDate = new JComboBox(); comboDate.addItem("?"); comboDate.addActionListener(myActionListener); P.add(comboDate); //Create Delete button buttonDelete = new JButton(""); buttonDelete.setEnabled(false); buttonDelete.addActionListener(myActionListener); P.add(buttonDelete); //this.checkConnection = new CheckConnection(buttonDelete); buttonPasswordsManager = new JButton(" "); buttonPasswordsManager.addActionListener(myActionListener); P.add(buttonPasswordsManager); try { Image img = ImageIO.read(getClass().getResource("resources/table_refresh.png")); this.buttonRefresh = new JButton(new ImageIcon(img)); this.buttonRefresh.addActionListener(myActionListener); this.buttonRefresh.setToolTipText(" "); P.add(buttonRefresh); } catch (IOException ex) { Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex); } //CreateLessonTableModel lessonTableModel = new LessonTableModel(); try { communicator.setCombos(comboGroup, comboDate, lessonTableModel); } catch (IOException ex) { JOptionPane.showMessageDialog(null, " ? ? ."); Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex); } //CreateTable table = new JTable(lessonTableModel); table.setFillsViewportHeight(true); table.setAutoCreateRowSorter(true); JScrollPane scrollP = new JScrollPane(table); mainPanel.add(scrollP, BorderLayout.CENTER); //Create Table sorter sorter = new TableRowSorter<LessonTableModel>(lessonTableModel); table.setRowSorter(sorter); table.getModel().addTableModelListener(new TableModelListener() { @Override public void tableChanged(TableModelEvent e) { int row = e.getFirstRow(); int column = e.getColumn(); TableModel model = (TableModel) e.getSource(); for (int i = 0; i < model.getRowCount(); i++) { if ((boolean) model.getValueAt(i, 2) == true) { buttonDelete.setEnabled(true); return; } } buttonDelete.setEnabled(false); } }); //Standart block this.setSize(700, 400); this.setTitle(" "); this.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent we) { System.exit(0); } }); try { Image img = ImageIO.read(getClass().getResource("resources/appIcon.png")); this.setIconImage(img); } catch (IOException ex) { Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex); } this.setVisible(true); }
From source file:de.mendelson.comm.as2.client.AS2Gui.java
/** * Creates new form NewJFrame//w ww. j a v a 2 s .c o m */ public AS2Gui(Splash splash, String host) { this.host = host; //Set System default look and feel try { //support the command line option -Dswing.defaultlaf=... if (System.getProperty("swing.defaultlaf") == null) { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } } catch (Exception e) { this.logger.warning(this.getClass().getName() + ":" + e.getMessage()); } //load resource bundle try { this.rb = (MecResourceBundle) ResourceBundle.getBundle(ResourceBundleAS2Gui.class.getName()); } catch (MissingResourceException e) { throw new RuntimeException("Oops..resource bundle " + e.getClassName() + " not found."); } initComponents(); this.jButtonNewVersion.setVisible(false); this.jPanelRefreshWarning.setVisible(false); //set preference values to the GUI this.setBounds(this.clientPreferences.getInt(PreferencesAS2.FRAME_X), this.clientPreferences.getInt(PreferencesAS2.FRAME_Y), this.clientPreferences.getInt(PreferencesAS2.FRAME_WIDTH), this.clientPreferences.getInt(PreferencesAS2.FRAME_HEIGHT)); //ensure to display all messages this.getLogger().setLevel(Level.ALL); LogConsolePanel consolePanel = new LogConsolePanel(this.getLogger()); //define the colors for the log levels consolePanel.setColor(Level.SEVERE, LogConsolePanel.COLOR_BROWN); consolePanel.setColor(Level.WARNING, LogConsolePanel.COLOR_BLUE); consolePanel.setColor(Level.INFO, LogConsolePanel.COLOR_BLACK); consolePanel.setColor(Level.CONFIG, LogConsolePanel.COLOR_DARK_GREEN); consolePanel.setColor(Level.FINE, LogConsolePanel.COLOR_DARK_GREEN); consolePanel.setColor(Level.FINER, LogConsolePanel.COLOR_DARK_GREEN); consolePanel.setColor(Level.FINEST, LogConsolePanel.COLOR_DARK_GREEN); this.jPanelServerLog.add(consolePanel); this.setTitle(AS2ServerVersion.getProductName() + " " + AS2ServerVersion.getVersion()); //initialize the help system if available this.initializeJavaHelp(); this.jTableMessageOverview.getSelectionModel().addListSelectionListener(this); this.jTableMessageOverview.getTableHeader().setReorderingAllowed(false); //icon columns TableColumn column = this.jTableMessageOverview.getColumnModel().getColumn(0); column.setMaxWidth(20); column.setResizable(false); column = this.jTableMessageOverview.getColumnModel().getColumn(1); column.setMaxWidth(20); column.setResizable(false); this.jTableMessageOverview.setDefaultRenderer(Date.class, new TableCellRendererDate(DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT))); //add row sorter RowSorter<TableModel> sorter = new TableRowSorter<TableModel>(this.jTableMessageOverview.getModel()); jTableMessageOverview.setRowSorter(sorter); sorter.addRowSorterListener(this); this.jPanelFilterOverview.setVisible(this.showFilterPanel); this.jMenuItemHelpForum.setEnabled(Desktop.isDesktopSupported()); //destroy splash, possible login screen for the client should come up if (splash != null) { splash.destroy(); } this.setButtonState(); this.jTableMessageOverview.addMouseListener(this); //popup menu issues this.jPopupMenu.setInvoker(this.jScrollPaneMessageOverview); this.jPopupMenu.addPopupMenuListener(this); super.addMessageProcessor(this); //perform the connection to the server //warning! this works for localhost only so far int clientServerCommPort = this.clientPreferences.getInt(PreferencesAS2.CLIENTSERVER_COMM_PORT); if (splash != null) { splash.destroy(); } this.browserLinkedPanel.cyleText(new String[] { "For additional EDI software to convert and process your data please contact <a href='http://www.mendelson-e-c.com'>mendelson-e-commerce GmbH</a>", "To buy a commercial license please visit the <a href='http://shop.mendelson-e-c.com/'>mendelson online shop</a>", "Most trading partners demand a trusted certificate - Order yours at the <a href='http://ca.mendelson-e-c.com'>mendelson CA</a> now!", "Looking for additional secure data transmission software? Try the <a href='http://oftp2.mendelson-e-c.com'>mendelson OFTP2</a> solution!", "You want to send EDIFACT data from your SAP system? Ask <a href='mailto:info@mendelson.de?subject=Please%20inform%20me%20about%20your%20SAP%20integration%20solutions'>mendelson-e-commerce GmbH</a> for a solution.", "You need a secure FTP solution? <a href='mailto:info@mendelson.de?subject=Please%20inform%20me%20about%20your%20SFTP%20solution'>Ask us</a> for the mendelson SFTP software.", "Convert flat files, EDIFACT, SAP IDos, VDA, inhouse formats? <a href='mailto:info@mendelson.de?subject=Please%20inform%20me%20about%20your%20converter%20solution'>Ask us</a> for the mendelson EDI converter.", "For commercial support of this software please buy a license at <a href='http://as2.mendelson-e-c.com'>the mendelson AS2</a> website.", "Have a look at the <a href='http://www.mendelson-e-c.com/products_mbi.php'>mendelson business integration</a> for a powerful EDI solution.", "The <a href='mailto:info@mendelson.de?subject=Please%20inform%20me%20about%20your%20RosettaNet%20solution'>mendelson RosettaNet solution</a> supports RNIF 1.1 and RNIF 2.0.", "The <a href='http://www.mendelson-e-c.com/products_ide.php'>mendelson converter IDE</a> is the graphical mapper for the mendelson converter.", "To process any XML data and convert it to EDIFACT, VDA, flat files, IDocs and inhouse formats use <a href='http://www.mendelson-e-c.com/products_converter.php'>the mendelson converter</a>.", "To transmit your EDI data via HTTP/S please <a href='mailto:info@mendelson.de?subject=Please%20inform%20me%20about%20your%20HTTPS%20solution'>ask us</a> for the mendelson HTTPS solution.", "If you have questions regarding this product please refer to the <a href='http://community.mendelson-e-c.com/'>mendelson community</a>.", }); this.connect(new InetSocketAddress(host, clientServerCommPort), 5000); Runnable dailyNewsThread = new Runnable() { @Override public void run() { while (true) { long lastUpdateCheck = Long.valueOf(clientPreferences.get(PreferencesAS2.LAST_UPDATE_CHECK)); //check only once a day even if the system is started n times a day if (lastUpdateCheck < (System.currentTimeMillis() - TimeUnit.HOURS.toMillis(23))) { clientPreferences.put(PreferencesAS2.LAST_UPDATE_CHECK, String.valueOf(System.currentTimeMillis())); jButtonNewVersion.setVisible(false); String version = (AS2ServerVersion.getVersion() + " " + AS2ServerVersion.getBuild()) .replace(' ', '+'); Header[] header = htmlPanel.setURL( "http://www.mendelson.de/en/mecas2/client_welcome.php?version=" + version, AS2ServerVersion.getProductName() + " " + AS2ServerVersion.getVersion(), new File("start/client_welcome.html")); if (header != null) { String downloadURL = null; String actualBuild = null; for (Header singleHeader : header) { if (singleHeader.getName().equals("x-actual-build")) { actualBuild = singleHeader.getValue().trim(); } if (singleHeader.getName().equals("x-download-url")) { downloadURL = singleHeader.getValue().trim(); } } if (downloadURL != null && actualBuild != null) { try { int thisBuild = AS2ServerVersion.getBuildNo(); int availableBuild = Integer.valueOf(actualBuild); if (thisBuild < availableBuild) { jButtonNewVersion.setVisible(true); } downloadURLNewVersion = downloadURL; } catch (Exception e) { //nop } } } } else { htmlPanel.setPage(new File("start/client_welcome.html")); } try { //check once a day for new update Thread.sleep(TimeUnit.DAYS.toMillis(1)); } catch (InterruptedException e) { //nop } } } }; Executors.newSingleThreadExecutor().submit(dailyNewsThread); this.as2StatusBar.setConnectedHost(this.host); }
From source file:com.sec.ose.osi.ui.frm.main.manage.dialog.JDlgProjectAdd.java
/** * This method initializes jTablePjtList * //from w w w. j a v a 2 s . c o m * @return javax.swing.JTable */ private JTable getJTablePjtList() { if (jTablePjtList == null) { jTablePjtList = new JTable(); jTablePjtList.addMouseListener(new ProjectTableClickAction()); } projectListTableModel = new AddProjectTableModel(); jTablePjtList.setModel(projectListTableModel); projectListTableModel.setColumnWidth(jTablePjtList); projectListTableModel.setColumnView(jTablePjtList); sorter = new TableRowSorter<AddProjectTableModel>(projectListTableModel); sorter.toggleSortOrder(projectListTableModel.COL_PROJECT_NAME); jTablePjtList.setRowSorter(sorter); return jTablePjtList; }
From source file:de.main.sessioncreator.DesktopApplication1View.java
private void showReportPanel() { sessionWizardMenuItem.setEnabled(true); reviewVieMenuItem.setEnabled(true);//from ww w. j av a 2 s. c om sessionReportMenuItem.setEnabled(false); viewReviewsPanel.setVisible(false); mainPanel.validate(); wizardPanel.setVisible(false); mainPanel.validate(); reportOverviewTable.setVisible(false); reportPanel.setVisible(true); mainPanel.validate(); this.getFrame().setTitle("SessionCreator - Report"); //Backgroundprozess to fill data to the reportPanel class ReportData extends SwingWorker<DefaultTableModel, Void> { @Override protected DefaultTableModel doInBackground() throws Exception { rh.addReport(reportChartPanel); reportScrollPOverviewTabel.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); reportScrollPOverviewTabel.setToolTipText("Please wait..."); reportlblSum.setText("Sums of Charters done: <counting>"); progressBar.setIndeterminate(true); progressBar.setVisible(true); model = new DefaultTableModel(); reportOverviewTable.removeAll(); model = rh.getTableModel(); reportOverviewTable.setModel(model); reportOverviewTable.setVisible(true); String count = rh.getAllSessionCount(model); reportlblSum.setText("Sums of Charters done: " + count); String[] text = rh.getAllBugsAndIssues(); reportlblBug.setText(text[0]); reportlblIssue.setText(text[1]); return model; } @Override protected void done() { try { reportScrollPOverviewTabel.setCursor(Cursor.getDefaultCursor()); reportScrollPOverviewTabel.setToolTipText(""); progressBar.setIndeterminate(false); progressBar.setVisible(false); reportScrollPOverviewTabel.setEnabled(true); reportOverviewTable.setFillsViewportHeight(true); reportOverviewTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); TableRowSorter<DefaultTableModel> rowSorter = new TableRowSorter<DefaultTableModel>(model); reportOverviewTable.setRowSorter(rowSorter); rowSorter.setComparator(1, new Comparator<Integer>() { @Override public int compare(Integer int1, Integer int2) { return int1.intValue() - int2.intValue(); } }); TableColumn column = null; for (int i = 0; i < 2; i++) { column = reportOverviewTable.getColumnModel().getColumn(i); if (i == 1) { column.setPreferredWidth(10); //third column is bigger DefaultTableCellRenderer myRenderer = new DefaultTableCellRenderer(); //Textalignment in second column right myRenderer.setHorizontalAlignment(SwingConstants.RIGHT); column.setCellRenderer(myRenderer); } else { column.setPreferredWidth(490); } } } catch ( /* InterruptedException, ExecutionException */Exception e) { } } } new ReportData().execute(); }
From source file:cn.labthink.ReadAccess060.java
private void jButton_OpenfileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_OpenfileActionPerformed //filter/* www .j a v a 2s . c o m*/ ExtensionFileFilter filter = new ExtensionFileFilter("mdb", false, true); filter.setDescription("Open DataBase File"); //? JFileChooser jfc = new JFileChooser(); FileSystemView fsv = FileSystemView.getFileSystemView(); //? jfc.setCurrentDirectory(fsv.getHomeDirectory()); jfc.setDialogTitle("Choose the mdb file"); jfc.setMultiSelectionEnabled(false); jfc.setDialogType(JFileChooser.OPEN_DIALOG); jfc.setFileSelectionMode(JFileChooser.FILES_ONLY); jfc.setFileFilter(filter); int result = jfc.showOpenDialog(this); // ""? if (result == JFileChooser.APPROVE_OPTION) { String filesrc = jfc.getSelectedFile().getAbsolutePath(); inputfile = jfc.getSelectedFile(); jLabel_dbpath.setText("DB File Path:" + filesrc); maxid = Integer.MIN_VALUE; minid = Integer.MAX_VALUE; } else { return; } // Infodata = new Vector(); Infocolumns = new Vector(); try { // String url = "jdbc:odbc:driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=D://b.MDB"; if (inputfile == null) { return; } initDB(); sql = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY); rs = sql.executeQuery("SELECT * FROM test order by testid desc"); Infocolumns.add("TestID"); Infocolumns.add("TestType"); Infocolumns.add("DeviceID"); Infocolumns.add("CellID"); Infocolumns.add("Operator"); Infocolumns.add("StartTime"); Infocolumns.add("EndTime"); Infocolumns.add("Comments"); Infocolumns.add("SetTemp."); int columnCount = Infocolumns.size(); Vector row; while (rs.next()) { row = new Vector(columnCount); int temp = 0; int ivalue = rs.getInt("TESTID"); maxid = maxid < ivalue ? ivalue : maxid; minid = minid > ivalue ? ivalue : minid; row.add(ivalue); temp = rs.getInt("TESTTYPE"); if (temp == 1) { row.add("OTR"); } else if (temp == 2) { row.add("WVTR"); } else { row.add(temp); } row.add(rs.getInt("DEVICEID")); row.add(rs.getString("CELLID")); row.add(rs.getString("OPERATOR")); row.add(rs.getDate("STARTTIME")); row.add(rs.getDate("ENDTIME")); row.add(rs.getString("COMMENTS")); row.add(rs.getDouble("SETTEMP")); // row.add(rs.getString(11)); // row.add(rs.getInt(10)); Infodata.add(row); } DefaultTableModel tableModel = new DefaultTableModel(Infodata, Infocolumns); jTable1.setModel(tableModel); //? // jTable1.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); jTable1.setSelectionBackground(Color.orange); //? TableRowSorter<TableModel> tableRowSorter = new TableRowSorter<TableModel>(tableModel); jTable1.setRowSorter(tableRowSorter); // jTable1.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); //table DefaultTableCellRenderer tcr = new DefaultTableCellRenderer();// table tcr.setHorizontalAlignment(SwingConstants.CENTER);// ?? jTable1.setDefaultRenderer(Object.class, tcr); // ((DefaultTableCellRenderer) jTable1.getTableHeader().getDefaultRenderer()) .setHorizontalAlignment(SwingConstants.CENTER); // DefaultTableCellRenderer rh = new DefaultTableCellRenderer(); // rh.setHorizontalAlignment(SwingConstants.CENTER); // jTable1.getTableHeader().setDefaultRenderer(rh); jTable1.getColumnModel().getColumn(0).setPreferredWidth(20); jTable1.getColumnModel().getColumn(1).setPreferredWidth(28); jTable1.getColumnModel().getColumn(2).setPreferredWidth(20); jTable1.getColumnModel().getColumn(3).setPreferredWidth(40); jTable1.getColumnModel().getColumn(4).setPreferredWidth(40); jTable1.getColumnModel().getColumn(5).setPreferredWidth(100); jTable1.getColumnModel().getColumn(6).setPreferredWidth(100); jTable1.getColumnModel().getColumn(7).setPreferredWidth(100); } catch (SQLException ee) { System.out.println(ee); } catch (ClassNotFoundException ex) { Logger.getLogger(ReadAccess060.class.getName()).log(Level.SEVERE, null, ex); } finally { try { sql.close(); } catch (Exception e) { } try { rs.close(); } catch (Exception e) { } } // validate(); }