private void initializeComponents () { setLayout(new GridBagLayout()); JPanel sideButtons = new JPanel(new GridBagLayout()); add(sideButtons, new GridBagConstraints(1, 0, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); sideButtons.add(newButton, new GridBagConstraints(0, -1, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 6, 0), 0, 0)); newButton.addActionListener(new ActionListener() { sideButtons.add(newButton, new GridBagConstraints(0, -1, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 6, 0), 0, 0)); newButton.addActionListener(new ActionListener() { JScrollPane scroll = new JScrollPane(); add(scroll, new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 6), 0, 0)); emitterTable.getTableHeader().setReorderingAllowed(false); emitterTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); scroll.setViewportView(emitterTable); emitterTableModel = new DefaultTableModel(new String[0][0], new String[] {"Emitter", ""}); emitterTable.setModel(emitterTableModel); emitterTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged (ListSelectionEvent event) { if (event.getValueIsAdjusting()) return;
void emitterSelected () { int row = emitterTable.getSelectedRow(); if (row == -1) { row = editIndex; emitterTable.getSelectionModel().setSelectionInterval(row, row); } if (row == editIndex) return; editIndex = row; editor.reloadRows(); }
public void valueChanged(ListSelectionEvent e) { if (e.getValueIsAdjusting()) { return; ListSelectionModel lsm = (ListSelectionModel) e.getSource(); if (lsm.isSelectionEmpty()) { int selectedRow = lsm.getMinSelectionIndex(); Object obj = _table.getModel().getValueAt(selectedRow, i); if (obj != null) { value = obj.toString(); Object obj = _table.getModel().getValueAt(selectedRow, _numCols - 1); if (obj != null) { buf.append(obj.toString());
public void propertyChange(PropertyChangeEvent event) { update(); ((ListSelectionModel) event.getOldValue()).removeListSelectionListener(this); ((ListSelectionModel) event.getNewValue()).addListSelectionListener(this); }
@Override public void valueChanged(ListSelectionEvent e) { ListSelectionModel lsm = (ListSelectionModel) e.getSource(); if (!lsm.isSelectionEmpty()) { Object o = xpathResults.get(lsm.getMinSelectionIndex()); if (o instanceof Node) { codeEditorPane.select((Node) o); } } } }
this.networkTable.getColumnModel().getColumn(1).setCellRenderer(new PathCellRenderer()); this.networkTable.getColumnModel().getColumn(2).setCellRenderer(centerHorizontalAlignment); this.networkTable.getColumnModel().getColumn(3).setCellRenderer(centerHorizontalAlignment); this.networkTable.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put( scrollerNetwork.scrollPane.setBorder(BorderFactory.createEmptyBorder(0, 0, -1, -1)); scrollerNetwork.scrollPane.setViewportBorder(BorderFactory.createEmptyBorder(0, 0, -1, -1)); scrollerNetwork.scrollPane.getVerticalScrollBar().addAdjustmentListener(singleItemScroll); scrollerNetwork.scrollPane.getHorizontalScrollBar().addAdjustmentListener(singleItemScroll); this.networkTable.getColumnModel().getColumn(3).setPreferredWidth(50); this.networkTable.getSelectionModel().addListSelectionListener(event -> { if (!event.getValueIsAdjusting() && PanelConsoles.this.networkTable.getSelectedRow() > -1) { this.changeTextNetwork(); PanelConsoles.BUTTON_SHOW_NORTH.addActionListener(SplitHorizontalTopBottom.getActionHideShowResult()); arrowDownPanel.setBorder(BorderFactory.createEmptyBorder(1, 0, 0, 0)); arrowDownPanel.setMaximumSize(new Dimension(Integer.MAX_VALUE, 26));
/** * Creates a new <code>DetailPanel</code> instance. * * @param aTable the table to listen for selections on * @param aModel the model backing the table */ DetailPanel(JTable aTable, final MyTableModel aModel) { mModel = aModel; setLayout(new BorderLayout()); setBorder(BorderFactory.createTitledBorder("Details: ")); mDetails = new JEditorPane(); mDetails.setEditable(false); mDetails.setContentType("text/html"); add(new JScrollPane(mDetails), BorderLayout.CENTER); final ListSelectionModel rowSM = aTable.getSelectionModel(); rowSM.addListSelectionListener(this); }
final JPanel mainPanel = new JPanel(); mainPanel.setLayout(new BorderLayout()); getContentPane().setLayout(new BorderLayout()); getContentPane().add(mainPanel, BorderLayout.CENTER); mainPanel.setBorder(new EmptyBorder(10, 10, 10, 10)); mainPanel.add(createSearchPanel(list), BorderLayout.NORTH); mainPanel.add(new JScrollPane(list), BorderLayout.CENTER); list.getSelectionModel().addListSelectionListener( new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) {
private JComponent getChooserPanel() { JPanel p = new JPanel(new BorderLayout()); p.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); p.setOpaque(false); JLabel l = new JLabel("Please choose installation directory:"); l.setVerticalAlignment(JLabel.NORTH); l.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 10)); p.add(l, BorderLayout.NORTH); table = new JTable(installations); table.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); table.setColumnSelectionAllowed(false); table.setDefaultRenderer(Object.class, new InstallationTableCellRenderer()); table.getColumnModel().getColumn(0).setHeaderValue("Directory"); table.getColumnModel().getColumn(0).setPreferredWidth(300); table.getColumnModel().getColumn(1).setHeaderValue("Java Version"); table.getColumnModel().getColumn(3).setPreferredWidth(100); table.getColumnModel().getColumn(2).setHeaderValue("Type"); table.getColumnModel().getColumn(3).setPreferredWidth(100); table.getColumnModel().getColumn(3).setHeaderValue("Replaced by DCEVM?"); table.getColumnModel().getColumn(3).setPreferredWidth(200); table.getColumnModel().getColumn(4).setHeaderValue("Installed altjvm?"); table.getColumnModel().getColumn(4).setPreferredWidth(200); JScrollPane lists = new JScrollPane(table); lists.setPreferredSize(new Dimension(900, 200)); p.add(lists, BorderLayout.CENTER); return p; }
public void resetContentPanel() { JPanel buttonPanel = new JPanel(new FlowLayout()); Action okAction = new AbstractAction("OK") { @Override buttonPanel.add(new JButton(okAction)); if (!solutionBusiness.isConstraintMatchEnabled()) { JPanel unsupportedPanel = new JPanel(new BorderLayout()); = solutionBusiness.getConstraintMatchTotalList(); JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); final JTable table = new JTable(new ConstraintMatchTotalTableModel(constraintMatchTotalList)); TableColumnModel columnModel = table.getColumnModel(); columnModel.getColumn(0).setPreferredWidth(300); columnModel.getColumn(1).setPreferredWidth(80); columnModel.getColumn(2).setPreferredWidth(80); JScrollPane tableScrollPane = new JScrollPane(table); tableScrollPane.setPreferredSize(new Dimension(700, 300)); splitPane.setTopComponent(tableScrollPane); JPanel bottomPanel = new JPanel(new BorderLayout()); JLabel detailLabel = new JLabel("Constraint matches of selected constraint type"); JScrollPane detailScrollPane = new JScrollPane(detailTextArea); bottomPanel.add(detailScrollPane, BorderLayout.CENTER); table.getSelectionModel().addListSelectionListener(
JTable table = new JTable(messagesTable); table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); table.getColumnModel().getColumn(0).setMaxWidth(0); table.getColumnModel().getColumn(0).setMinWidth(0); table.getTableHeader().getColumnModel().getColumn(0).setMaxWidth(0); table.getTableHeader().getColumnModel().getColumn(0).setMinWidth(0); table.getSelectionModel().addListSelectionListener(selectionListener); table.getColumnModel().getSelectionModel().addListSelectionListener(selectionListener); allPane.setTopComponent(new JScrollPane(table)); messageTextArea = new JTextArea(); messageTextArea.setEditable(false); JPanel sublayout = new JPanel(new BorderLayout()); sublayout.add(new JScrollPane(messageTextArea), BorderLayout.CENTER); sublayout.add(clearb, BorderLayout.NORTH); allPane.setBottomComponent(sublayout); sentText.setEditable(false); sentText.setForeground(new Color(112, 3, 3)); tabbedPane.add("Raw Sent Packets", new JScrollPane(sentText)); tabbedPane.setToolTipTextAt(1, "Raw text of the sent packets");
private JPanel fatherCenter = new JPanel(); private JScrollPane tableScroll = new JScrollPane(); private myTableModel tableModel; private JTable dialogTable; Component comp = super.prepareRenderer(renderer, row, column); tableScroll = new JScrollPane(dialogTable, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); tableScroll.setBorder(null); ListSelectionModel rowSelMod = dialogTable.getSelectionModel(); rowSelMod.addListSelectionListener(this); fatherCenter = new JPanel(); fatherCenter.setLayout(new BorderLayout(10, 10)); fatherCenter.add(tableScroll, BorderLayout.CENTER); pane.add(fatherCenter); frame.setLayout(new BorderLayout(10, 10)); addComponentsToPane(frame.getContentPane()); addData();
stateVariablesTable.getSelectionModel().addListSelectionListener( new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { stateVariablesScrollPane = new JScrollPane(stateVariablesTable); JPanel mainPanel = new JPanel(new BorderLayout()); mainPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); mainPanel.add(monitoringToolBar, BorderLayout.NORTH); mainPanel.add(stateVariablesScrollPane, BorderLayout.CENTER); mainPanel.add(toolBar, BorderLayout.SOUTH);
m.addElement(new Thumbnail(s)); JList<Thumbnail> list = new JList<>(m); list.getSelectionModel().setSelectionMode( ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); list.setTransferHandler(new ListItemTransferHandler()); list.setDropMode(DropMode.INSERT); list.setDragEnabled(true); list.setCellRenderer(new ListCellRenderer<Thumbnail>() { private final JPanel p = new JPanel(new BorderLayout()); private final JLabel icon = new JLabel((Icon)null, JLabel.CENTER); private final JLabel label = new JLabel("", JLabel.CENTER); label.setForeground(isSelected? list.getSelectionForeground() : list.getForeground()); p.add(icon); p.add(label, BorderLayout.SOUTH); p.setBackground(isSelected? list.getSelectionBackground() : list.getBackground()); return new JScrollPane(list); JFrame f = new JFrame(); f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); f.getContentPane().add(new DragAndDropTest().makeUI()); f.setSize(320, 240); f.setLocationRelativeTo(null);
table = new JTable(4, 4); for (int i = 0; i < table.getRowCount(); i++) { table.setValueAt(i, i, 0); sorter = new TableRowSorter<TableModel>(table.getModel()); headerTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); headerTable.setPreferredScrollableViewportSize(new Dimension(50, 0)); headerTable.getColumnModel().getColumn(0).setPreferredWidth(50); headerTable.getColumnModel().getColumn(0).setCellRenderer(new TableCellRenderer() { boolean selected = table.getSelectionModel().isSelectedIndex(row); Component component = table.getTableHeader().getDefaultRenderer().getTableCellRendererComponent(table, value, false, false, -1, -2); ((JLabel) component).setHorizontalAlignment(SwingConstants.CENTER); table.getSelectionModel().addListSelectionListener(new ListSelectionListener() { scrollPane = new JScrollPane(table); scrollPane.setRowHeaderView(headerTable); table.setPreferredScrollableViewportSize(table.getPreferredSize()); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); frame.add(scrollPane); frame.add(new JButton(new AbstractAction("Toggle filter") {
@PostConstruct public void init() { setLayout(new BorderLayout()); logTable = new JTable(logTableModel); logTable.setDefaultRenderer( LogMessage.class, new LogTableCellRenderer() { logTable.setCellSelectionEnabled(false); logTable.setRowSelectionAllowed(true); logTable.getSelectionModel().addListSelectionListener( new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { add(new JScrollPane(logTable), BorderLayout.CENTER); add(toolBar, BorderLayout.SOUTH);
/** Create UI components. */ private void createUIComponents() { templatesListPanel = new TemplatesListPanel(); editorPanel = new EditorPanel(); editorPanel.setPreferredSize(new Dimension(Integer.MAX_VALUE, 200)); templatesSplitter = new Splitter(false, 0.3f); templatesSplitter.setFirstComponent(templatesListPanel); templatesSplitter.setSecondComponent(editorPanel); languagesTable = new JBTable(); languagesTable.setModel(new LanguagesTableModel()); languagesTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); languagesTable.setColumnSelectionAllowed(false); languagesTable.setRowHeight(22); languagesTable.setPreferredScrollableViewportSize(new Dimension(-1, languagesTable.getRowHeight() * IgnoreBundle.LANGUAGES.size() / 2)); languagesTable.setStriped(true); languagesTable.setShowGrid(false); languagesTable.setBorder(JBUI.Borders.empty()); languagesTable.setDragEnabled(false); languagesPanel = ScrollPaneFactory.createScrollPane(languagesTable); donatePanel = new JBPanel(new BorderLayout()); donatePanel.setBorder(JBUI.Borders.empty(10, 0)); donatePanel.add(new JBLabel(IgnoreBundle.message("settings.general.donate")), BorderLayout.WEST); donatePanel.add(createLink( "Donate with PayPal", "https://www.paypal.me/hsz" ), BorderLayout.CENTER); }
/** * Creates a new <code>DetailPanel</code> instance. * * @param aTable the table to listen for selections on * @param aModel the model backing the table */ DetailPanel(JTable aTable, final MyTableModel aModel) { mModel = aModel; setLayout(new BorderLayout()); setBorder(BorderFactory.createTitledBorder("Details: ")); mDetails = new JEditorPane(); mDetails.setEditable(false); mDetails.setContentType("text/html"); add(new JScrollPane(mDetails), BorderLayout.CENTER); final ListSelectionModel rowSM = aTable.getSelectionModel(); rowSM.addListSelectionListener(this); }
private JComponent createXPathResultPanel() { xpathResults.addElement("No XPath results yet, run an XPath Query first."); xpathResultList.setBorder(BorderFactory.createLineBorder(Color.black)); xpathResultList.setFixedCellWidth(300); xpathResultList.setCellRenderer(new ASTListCellRenderer()); xpathResultList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); xpathResultList.getSelectionModel().addListSelectionListener(new ASTSelectionListener()); JScrollPane scrollPane = new JScrollPane(); scrollPane.getViewport().setView(xpathResultList); return scrollPane; }
this.scrollPane = scrollPane; this.mainTable = (JTable) scrollPane.getViewport().getView(); this.mainTable.setAutoCreateColumnsFromModel(false); this.mainTable.addPropertyChangeListener(this); this.fixedTable.setAutoCreateColumnsFromModel(false); final DefaultTableModel modelFixedTable = new DefaultTableModel(){ @Override TableColumnModel columnModel = this.mainTable.getColumnModel(); for (int i = 0 ; i < fixedColumns ; i++) { TableColumn column = columnModel.getColumn(i); column.setMinWidth(0); column.setMaxWidth(0); this.fixedTable.getColumnModel().addColumn(new TableColumn(i)); this.fixedTable.getColumnModel().getColumn(0).setCellRenderer(new RowHeaderRenderer()); this.fixedTable.getColumnModel().getColumn(0).setResizable(false); this.fixedTable.getColumnModel().getColumn(0).setPreferredWidth(38); this.mainTable.getSelectionModel().addListSelectionListener(listSelectionEvent -> modelFixedTable.fireTableRowsUpdated(0, modelFixedTable.getRowCount() - 1) ); this.fixedTable.setPreferredScrollableViewportSize(this.fixedTable.getPreferredSize()); scrollPane.setRowHeaderView(this.fixedTable); scrollPane.setCorner(ScrollPaneConstants.UPPER_LEFT_CORNER, this.fixedTable.getTableHeader());