List of usage examples for javax.swing.table TableColumn setResizable
@BeanProperty(description = "Whether or not this column can be resized.") public void setResizable(boolean isResizable)
From source file:net.sf.keystore_explorer.gui.dialogs.extensions.DViewExtensions.java
private void initComponents() { ExtensionsTableModel extensionsTableModel = new ExtensionsTableModel(); jtExtensions = new JKseTable(extensionsTableModel); TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(extensionsTableModel); sorter.setComparator(2, new ObjectIdComparator()); jtExtensions.setRowSorter(sorter);/* w ww. j a v a 2 s . c om*/ jtExtensions.setShowGrid(false); jtExtensions.setRowMargin(0); jtExtensions.getColumnModel().setColumnMargin(0); jtExtensions.getTableHeader().setReorderingAllowed(false); jtExtensions.setAutoResizeMode(JKseTable.AUTO_RESIZE_ALL_COLUMNS); jtExtensions.setRowHeight(Math.max(18, jtExtensions.getRowHeight())); for (int i = 0; i < jtExtensions.getColumnCount(); i++) { TableColumn column = jtExtensions.getColumnModel().getColumn(i); column.setHeaderRenderer( new ExtensionsTableHeadRend(jtExtensions.getTableHeader().getDefaultRenderer())); column.setCellRenderer(new ExtensionsTableCellRend()); } TableColumn criticalCol = jtExtensions.getColumnModel().getColumn(0); criticalCol.setResizable(false); criticalCol.setMinWidth(28); criticalCol.setMaxWidth(28); criticalCol.setPreferredWidth(28); ListSelectionModel selectionModel = jtExtensions.getSelectionModel(); selectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); selectionModel.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent evt) { if (!evt.getValueIsAdjusting()) { try { CursorUtil.setCursorBusy(DViewExtensions.this); updateExtensionValue(); } finally { CursorUtil.setCursorFree(DViewExtensions.this); } } } }); jspExtensionsTable = PlatformUtil.createScrollPane(jtExtensions, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); jspExtensionsTable.getViewport().setBackground(jtExtensions.getBackground()); jpExtensionsTable = new JPanel(new BorderLayout(5, 5)); jpExtensionsTable.setPreferredSize(new Dimension(500, 200)); jpExtensionsTable.add(jspExtensionsTable, BorderLayout.CENTER); jpExtensionValue = new JPanel(new BorderLayout(5, 5)); jlExtensionValue = new JLabel(res.getString("DViewExtensions.jlExtensionValue.text")); jpExtensionValue.add(jlExtensionValue, BorderLayout.NORTH); jepExtensionValue = new JEditorPane(); jepExtensionValue.setFont(new Font(Font.MONOSPACED, Font.PLAIN, LnfUtil.getDefaultFontSize())); jepExtensionValue.setEditable(false); jepExtensionValue.setToolTipText(res.getString("DViewExtensions.jtaExtensionValue.tooltip")); // JGoodies - keep uneditable color same as editable jepExtensionValue.putClientProperty("JTextArea.infoBackground", Boolean.TRUE); // for displaying URLs in extensions as clickable links jepExtensionValue.setContentType("text/html"); jepExtensionValue.addHyperlinkListener(this); // use default font and foreground color from the component jepExtensionValue.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE); jspExtensionValue = PlatformUtil.createScrollPane(jepExtensionValue, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); jpExtensionValueTextArea = new JPanel(new BorderLayout(5, 5)); jpExtensionValueTextArea.setPreferredSize(new Dimension(500, 200)); jpExtensionValueTextArea.add(jspExtensionValue, BorderLayout.CENTER); jpExtensionValue.add(jpExtensionValueTextArea, BorderLayout.CENTER); jbAsn1 = new JButton(res.getString("DViewExtensions.jbAsn1.text")); PlatformUtil.setMnemonic(jbAsn1, res.getString("DViewExtensions.jbAsn1.mnemonic").charAt(0)); jbAsn1.setToolTipText(res.getString("DViewExtensions.jbAsn1.tooltip")); jbAsn1.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { try { CursorUtil.setCursorBusy(DViewExtensions.this); asn1DumpPressed(); } finally { CursorUtil.setCursorFree(DViewExtensions.this); } } }); jpExtensionValueAsn1 = new JPanel(new FlowLayout(FlowLayout.RIGHT)); jpExtensionValueAsn1.add(jbAsn1); jpExtensionValue.add(jpExtensionValueAsn1, BorderLayout.SOUTH); jpExtensions = new JPanel(new GridLayout(2, 1, 5, 5)); jpExtensions.setBorder(new CompoundBorder(new EmptyBorder(5, 5, 5, 5), new CompoundBorder(new EtchedBorder(), new EmptyBorder(5, 5, 5, 5)))); jpExtensions.add(jpExtensionsTable); jpExtensions.add(jpExtensionValue); jbOK = new JButton(res.getString("DViewExtensions.jbOK.text")); jbOK.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { okPressed(); } }); jpOK = PlatformUtil.createDialogButtonPanel(jbOK, false); extensionsTableModel.load(extensions); if (extensionsTableModel.getRowCount() > 0) { jtExtensions.changeSelection(0, 0, false, false); } getContentPane().add(jpExtensions, BorderLayout.CENTER); getContentPane().add(jpOK, BorderLayout.SOUTH); setResizable(false); addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent evt) { closeDialog(); } }); getRootPane().setDefaultButton(jbOK); pack(); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { jbOK.requestFocus(); } }); }
From source file:com.github.fritaly.dualcommander.DirectoryBrowser.java
public DirectoryBrowser(UserPreferences preferences, File directory) { Validate.notNull(preferences, "The given user preferences are null"); Validate.notNull(directory, "The given directory is null"); Validate.isTrue(directory.exists(),/* ww w . j a v a2s . c om*/ String.format("The given directory '%s' doesn't exist", directory.getAbsolutePath())); Validate.isTrue(directory.isDirectory(), String.format("The given path '%s' doesn't denote a directory", directory.getAbsolutePath())); this.preferences = preferences; // Layout, columns & rows setLayout(new MigLayout("insets 0px", "[grow]", "[]1[grow]1[]")); this.tableModel = new FileTableModel(this); this.table = new JTable(tableModel); this.table.setBackground(Utils.getDefaultBackgroundColor()); this.table.addKeyListener(this); this.table.addMouseListener(this); this.table.addFocusListener(this); this.table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); this.table.getSelectionModel().addListSelectionListener(this); // Listen to column event resize events final ColumnEventHelper eventHelper = new ColumnEventHelper(this); this.table.getColumnModel().addColumnModelListener(eventHelper); this.table.getTableHeader().addMouseListener(eventHelper); // Render the table headers with a bold font this.table.getTableHeader().setFont(Utils.getBoldFont(this.table.getTableHeader().getFont())); this.table.getTableHeader().setBackground(Utils.getDefaultBackgroundColor()); this.table.getTableHeader().setDefaultRenderer(new TableHeaderRenderer()); this.table.getTableHeader().addMouseListener(this); final TableColumn typeColumn = this.table.getColumn(FileTableModel.COLUMN_TYPE); typeColumn.setCellRenderer(new FileTypeRenderer()); typeColumn.setResizable(false); typeColumn.setHeaderValue(""); typeColumn.setMaxWidth(Icons.FOLDER_ICON.getIconWidth() + 5); final TableColumn fileColumn = this.table.getColumn(FileTableModel.COLUMN_NAME); fileColumn.setCellRenderer(new FileNameRenderer()); fileColumn.setResizable(true); final TableColumn sizeColumn = this.table.getColumn(FileTableModel.COLUMN_SIZE); sizeColumn.setCellRenderer(new FileSizeRenderer()); sizeColumn.setResizable(true); // Dynamically set the column to the correct size final TableColumn lastUpdateColumn = this.table.getColumn(FileTableModel.COLUMN_LAST_UPDATE); lastUpdateColumn.setCellRenderer(new LastUpdateRenderer()); lastUpdateColumn.setResizable(false); lastUpdateColumn.setMaxWidth(Utils.getTimestampRenderWidth() + 5); lastUpdateColumn.setMinWidth(Utils.getTimestampRenderWidth() + 5); // Use a square border (not one with rounded corners) this.directoryButton.setBorder(Utils.createRaisedBevelBorder()); this.directoryButton.setFont(Utils.getDefaultFont()); this.directoryButton.setFocusable(false); this.directoryButton.setHorizontalAlignment(SwingConstants.LEFT); this.summary = new JLabel(" "); this.summary.setBorder(Utils.createRaisedBevelBorder()); add(directoryButton, "grow, wrap"); add(new JScrollPane(table), "grow, wrap"); add(summary, "grow"); // Set the directory (this will populate the table) setDirectory(directory); }
From source file:de.mendelson.comm.as2.client.AS2Gui.java
/** * Creates new form NewJFrame//from ww w .j av a2s . 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:nz.govt.natlib.ndha.manualdeposit.bulkupload.BulkUploadPresenter.java
private void setupColumns() { final TableRenderer renderer = new TableRenderer(); final int width = 50; for (int i = 0; i < theJobListTable.getColumnCount(); i++) { final TableColumn col = theJobListTable.getColumnModel().getColumn(i); col.setCellRenderer(renderer);/*from w w w.ja va 2s .c om*/ col.setResizable(true); if (i < (theJobListTable.getColumnCount() - 1)) { col.setPreferredWidth(width); col.setWidth(width); } } }
From source file:nz.govt.natlib.ndha.manualdeposit.ManualDepositPresenter.java
private void setupMetaDataColumns() { TableRenderer renderer = new TableRenderer(); TableColumn col = theMetaDataTable.getColumnModel().getColumn(0); col.setCellRenderer(renderer);// ww w .j a va 2s . c om col.setResizable(true); col = theMetaDataTable.getColumnModel().getColumn(1); col.setCellRenderer(renderer); col.setCellEditor(new MetaDataElementCellEditor(standardFont)); }
From source file:org.kepler.gui.ComponentLibraryPreferencesTab.java
/** * Initialize the source list table./*from w w w .jav a 2 s. c o m*/ */ private void initSourceList() { try { ComponentSourceTableModel cstm = new ComponentSourceTableModel(); _sourceList = new JTable(cstm); _sourceList.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); _sourceList.setShowGrid(true); _sourceList.setShowHorizontalLines(true); _sourceList.setShowVerticalLines(true); _sourceList.setGridColor(Color.lightGray); _sourceList.setIntercellSpacing(new Dimension(5, 5)); _sourceList.setRowHeight(_sourceList.getRowHeight() + 10); _sourceList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); if (isDebugging) { log.debug("intercellspacing: " + _sourceList.getIntercellSpacing().toString()); log.debug("getRowHeight(): " + _sourceList.getRowHeight()); } // Search column TableColumn c0 = _sourceList.getColumnModel().getColumn(0); c0.setMinWidth(50); c0.setPreferredWidth(60); c0.setMaxWidth(100); c0.setResizable(true); // Save column TableColumn c1 = _sourceList.getColumnModel().getColumn(1); c1.setMinWidth(50); c1.setPreferredWidth(60); c1.setMaxWidth(100); c1.setResizable(true); // Type column TableColumn c2 = _sourceList.getColumnModel().getColumn(2); c2.setMinWidth(50); c2.setPreferredWidth(60); c2.setMaxWidth(100); c2.setResizable(true); // Name column TableColumn c3 = _sourceList.getColumnModel().getColumn(3); c3.setMinWidth(50); c3.setPreferredWidth(100); c3.setMaxWidth(200); c3.setResizable(true); // Source column TableColumn c4 = _sourceList.getColumnModel().getColumn(4); c4.setMinWidth(200); c4.setPreferredWidth(600); c4.setMaxWidth(2000); c4.setResizable(true); JScrollPane sourceListSP = new JScrollPane(_sourceList); sourceListSP.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); sourceListSP.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); sourceListSP.setBackground(TabManager.BGCOLOR); add(sourceListSP); } catch (Exception e) { System.out.println(e.toString()); } }
From source file:org.openmicroscopy.shoola.agents.fsimporter.chooser.FileSelectionTable.java
/** * Helper method to setup the column as a boolean column * @param column the column to set/*from w ww . jav a2s . com*/ */ private void setColumnAsBoolean(TableColumn column) { column.setCellEditor(table.getDefaultEditor(Boolean.class)); column.setCellRenderer(table.getDefaultRenderer(Boolean.class)); column.setResizable(false); }
From source file:org.pentaho.reporting.ui.datasources.table.TableEditor.java
public void addColumn(final TableColumn column) { stopEditing();//from w w w.j a v a2 s. c o m if (column.getHeaderValue() == null) { final int modelColumn = column.getModelIndex(); final String columnName = getModel().getColumnName(modelColumn); if (modelColumn == 0) { column.setResizable(false); column.setHeaderValue(columnName); column.setPreferredWidth(30); column.setMaxWidth(30); column.setMinWidth(30); } else { final Class columnType = getModel().getColumnClass(modelColumn); column.setHeaderValue(new TypedHeaderInformation(columnType, columnName)); } } getColumnModel().addColumn(column); }
From source file:pcgen.gui2.tabs.CompanionInfoTab.java
private void initComponents() { {//w ww. ja v a 2s . c om DefaultTableColumnModel model = new DefaultTableColumnModel(); TableColumn column = new TableColumn(0); column.setResizable(true); model.addColumn(column); column = new TableColumn(1, 120, new ButtonCellRenderer(), null); column.setMaxWidth(120); column.setResizable(false); model.addColumn(column); companionsTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); companionsTable.getTableHeader().setResizingAllowed(false); companionsTable.setAutoCreateColumnsFromModel(false); companionsTable.setColumnModel(model); } companionsTable.setIntercellSpacing(new Dimension(0, 0)); companionsTable.setFocusable(false); companionsTable.setRowHeight(23); companionsTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); setLeftComponent(new JScrollPane(companionsTable)); JPanel rightPane = new JPanel(new BorderLayout()); infoPane.setOpaque(false); infoPane.setEditable(false); infoPane.setFocusable(true); infoPane.setContentType("text/html"); //$NON-NLS-1$ rightPane.add(new JScrollPane(infoPane), BorderLayout.CENTER); JPanel buttonPane = new JPanel(new FlowLayout()); buttonPane.add(loadButton); rightPane.add(buttonPane, BorderLayout.SOUTH); setRightComponent(rightPane); }