public FileNameRenderer(JTable table) { Border b = UIManager.getBorder("Table.noFocusBorder"); if (Objects.isNull(b)) { // Nimbus??? Insets i = focusCellHighlightBorder.getBorderInsets(textLabel); b = BorderFactory.createEmptyBorder(i.top, i.left, i.bottom, i.right); } noFocusBorder = b; p.setOpaque(false); panel.setOpaque(false); // http://www.icongalore.com/ XP Style Icons - Windows Application Icon, Software XP Icons nicon = new ImageIcon(getClass().getResource("wi0063-16.png")); sicon = new ImageIcon( p.createImage( new FilteredImageSource(nicon.getImage().getSource(), new SelectedImageFilter()))); iconLabel = new JLabel(nicon); iconLabel.setBorder(BorderFactory.createEmptyBorder()); p.add(iconLabel, BorderLayout.WEST); p.add(textLabel); panel.add(p, BorderLayout.WEST); Dimension d = iconLabel.getPreferredSize(); dim.setSize(d); table.setRowHeight(d.height); }
/** Initialize the panel containing the node. */ public PluginListCellRenderer() { super(new BorderLayout(8, 8)); JPanel mainPanel = new JPanel(new BorderLayout()); this.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); this.setBackground(Color.WHITE); this.setOpaque(true); mainPanel.setOpaque(false); this.nameVersionPanel.setOpaque(false); this.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); this.nameLabel.setIconTextGap(2); this.nameLabel.setFont(this.getFont().deriveFont(Font.BOLD)); this.systemLabel.setFont(this.getFont().deriveFont(Font.BOLD)); this.nameVersionPanel.add(nameLabel); this.nameVersionPanel.add(versionLabel); mainPanel.add(nameVersionPanel, BorderLayout.NORTH); mainPanel.add(descriptionLabel, BorderLayout.CENTER); this.add(iconLabel, BorderLayout.WEST); this.add(mainPanel, BorderLayout.CENTER); this.add(stateLabel, BorderLayout.WEST); }
protected RolloverBooleanRenderer(HighlightListener highlighter) { super(); this.highlighter = highlighter; setHorizontalAlignment(SwingConstants.CENTER); setBorderPainted(true); setRolloverEnabled(true); setOpaque(true); setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1)); }
/** Creates an instance <tt>PropertiesEditorPanel</tt>. */ public PropertiesEditorPanel() { super(new BorderLayout()); /** * Instantiates the properties table and adds selection model and listener and adds a row sorter * to the table model */ ResourceManagementService r = PropertiesEditorActivator.getResourceManagementService(); String[] columnNames = new String[] {r.getI18NString("service.gui.NAME"), r.getI18NString("service.gui.VALUE")}; propsTable = new JTable(new PropsTableModel(initTableModel(), columnNames)); propsTable.setRowSorter(new TableRowSorter<TableModel>(propsTable.getModel())); propsTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); PropsListSelectionListener selectionListener = new PropsListSelectionListener(); propsTable.getSelectionModel().addListSelectionListener(selectionListener); propsTable.getColumnModel().getSelectionModel().addListSelectionListener(selectionListener); JScrollPane scrollPane = new JScrollPane(propsTable); SearchField searchField = new SearchField("", propsTable); buttonsPanel = new ButtonsPanel(propsTable, searchField); centerPanel = new TransparentPanel(new BorderLayout()); centerPanel.add(scrollPane, BorderLayout.CENTER); centerPanel.add(buttonsPanel, BorderLayout.EAST); JLabel needRestart = new JLabel(r.getI18NString("plugin.propertieseditor.NEED_RESTART")); needRestart.setForeground(Color.RED); TransparentPanel searchPanel = new TransparentPanel(new BorderLayout(5, 0)); searchPanel.setBorder(BorderFactory.createEmptyBorder(3, 5, 3, 5)); searchPanel.add(searchField, BorderLayout.CENTER); setBorder(BorderFactory.createEmptyBorder(8, 8, 8, 8)); add(searchPanel, BorderLayout.NORTH); add(centerPanel, BorderLayout.CENTER); add(needRestart, BorderLayout.SOUTH); }
public TextAreaCellEditor() { super(); scroll = new JScrollPane(this); scroll.setBorder(BorderFactory.createEmptyBorder()); // scroll.setViewportBorder(BorderFactory.createEmptyBorder()); setLineWrap(true); setBorder(BorderFactory.createEmptyBorder(2, 4, 2, 4)); KeyStroke enter = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.CTRL_DOWN_MASK); getInputMap(JComponent.WHEN_FOCUSED).put(enter, KEY); getActionMap() .put( KEY, new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { stopCellEditing(); } }); }
public MainPanel() { super(new BorderLayout()); table.setAutoCreateRowSorter(true); JPanel p = new JPanel(new GridLayout(2, 1, 5, 5)); p.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); p.add(componentChoices); p.add( new JButton( new AbstractAction("show") { @Override public void actionPerformed(ActionEvent e) { model.setRowCount(0); JComponent c = ((JComponentType) componentChoices.getSelectedItem()).component; for (Integer f : focusType) { loadBindingMap(f, c.getInputMap(f), c.getActionMap()); } } })); add(p, BorderLayout.NORTH); add(new JScrollPane(table)); setPreferredSize(new Dimension(320, 240)); }
protected void initComponents( AirspaceBuilderModel model, final AirspaceBuilderController controller) { final JCheckBox resizeNewShapesCheckBox; final JCheckBox enableEditCheckBox; JPanel newShapePanel = new JPanel(); { JButton newShapeButton = new JButton("New shape"); newShapeButton.setActionCommand(NEW_AIRSPACE); newShapeButton.addActionListener(controller); newShapeButton.setToolTipText("Create a new shape centered in the viewport"); this.factoryComboBox = new JComboBox(defaultAirspaceFactories); this.factoryComboBox.setEditable(false); this.factoryComboBox.setToolTipText("Choose shape type to create"); resizeNewShapesCheckBox = new JCheckBox("Fit new shapes to viewport"); resizeNewShapesCheckBox.setActionCommand(SIZE_NEW_SHAPES_TO_VIEWPORT); resizeNewShapesCheckBox.addActionListener(controller); resizeNewShapesCheckBox.setSelected(controller.isResizeNewShapesToViewport()); resizeNewShapesCheckBox.setAlignmentX(Component.LEFT_ALIGNMENT); resizeNewShapesCheckBox.setToolTipText( "New shapes are sized to fit the geographic viewport"); enableEditCheckBox = new JCheckBox("Enable shape editing"); enableEditCheckBox.setActionCommand(ENABLE_EDIT); enableEditCheckBox.addActionListener(controller); enableEditCheckBox.setSelected(controller.isEnableEdit()); enableEditCheckBox.setAlignmentX(Component.LEFT_ALIGNMENT); enableEditCheckBox.setToolTipText("Allow modifications to shapes"); Box newShapeBox = Box.createHorizontalBox(); newShapeBox.add(newShapeButton); newShapeBox.add(Box.createHorizontalStrut(5)); newShapeBox.add(this.factoryComboBox); newShapeBox.setAlignmentX(Component.LEFT_ALIGNMENT); JPanel gridPanel = new JPanel(new GridLayout(0, 1, 0, 5)); // rows, cols, hgap, vgap gridPanel.add(newShapeBox); gridPanel.add(resizeNewShapesCheckBox); gridPanel.add(enableEditCheckBox); newShapePanel.setLayout(new BorderLayout()); newShapePanel.add(gridPanel, BorderLayout.NORTH); } JPanel entryPanel = new JPanel(); { this.entryTable = new JTable(model); this.entryTable.setColumnSelectionAllowed(false); this.entryTable.setRowSelectionAllowed(true); this.entryTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); this.entryTable .getSelectionModel() .addListSelectionListener( new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (!ignoreSelectEvents) { controller.actionPerformed( new ActionEvent(e.getSource(), -1, SELECTION_CHANGED)); } } }); this.entryTable.setToolTipText("<html>Click to select<br>Double-Click to rename</html>"); JScrollPane tablePane = new JScrollPane(this.entryTable); tablePane.setPreferredSize(new Dimension(200, 100)); entryPanel.setLayout(new BorderLayout(0, 0)); // hgap, vgap entryPanel.add(tablePane, BorderLayout.CENTER); } JPanel selectionPanel = new JPanel(); { JButton delselectButton = new JButton("Deselect"); delselectButton.setActionCommand(CLEAR_SELECTION); delselectButton.addActionListener(controller); delselectButton.setToolTipText("Clear the selection"); JButton deleteButton = new JButton("Delete Selected"); deleteButton.setActionCommand(REMOVE_SELECTED); deleteButton.addActionListener(controller); deleteButton.setToolTipText("Delete selected shapes"); JPanel gridPanel = new JPanel(new GridLayout(0, 1, 0, 5)); // rows, cols, hgap, vgap gridPanel.add(delselectButton); gridPanel.add(deleteButton); selectionPanel.setLayout(new BorderLayout()); selectionPanel.add(gridPanel, BorderLayout.NORTH); } this.setLayout(new BorderLayout(30, 0)); // hgap, vgap this.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); // top, left, bottom, right this.add(newShapePanel, BorderLayout.WEST); this.add(entryPanel, BorderLayout.CENTER); this.add(selectionPanel, BorderLayout.EAST); controller.addPropertyChangeListener( new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { if (SIZE_NEW_SHAPES_TO_VIEWPORT.equals(e.getPropertyName())) { resizeNewShapesCheckBox.setSelected(controller.isResizeNewShapesToViewport()); } else if (ENABLE_EDIT.equals(e.getPropertyName())) { enableEditCheckBox.setSelected(controller.isEnableEdit()); } } }); }
public void setContent(String cat) { cat = cat.trim(); selectAllCB.setVisible(false); selectAllCB.setSelected(false); deleteBut.setVisible(false); restoreBut.setVisible(false); refreshBut.setVisible(true); Object columns[] = null; int count = 0; switch (cat) { case "Inbox": columns = new Object[] {"", "From", "Date", "Subject", "Content"}; count = Database.getCount("Inbox"); workingSet = db.getData("SELECT * FROM messages WHERE tag='inbox' ORDER BY msg_id desc"); ; break; case "SentMail": columns = new Object[] {"", "To", "Date", "Subject", "Content"}; count = Database.getCount("Sentmail"); workingSet = db.getData("SELECT * FROM messages WHERE tag='sentmail' ORDER BY msg_id desc"); break; case "Draft": columns = new Object[] {"", "To", "Date", "Subject", "Content"}; count = Database.getCount("Draft"); workingSet = db.getData("SELECT * FROM messages WHERE tag='draft' ORDER BY msg_id desc"); break; case "Outbox": columns = new Object[] {"", "To", "Date", "Subject", "Content"}; count = Database.getCount("Outbox"); workingSet = db.getData("SELECT * FROM messages WHERE tag='outbox' ORDER BY msg_id desc"); break; case "Trash": // restoreBut.setVisible(true); columns = new Object[] {"", "To/From", "Date", "Subject", "Content"}; count = Database.getCount("Trash"); workingSet = db.getData( "SELECT * FROM messages,trash WHERE messages.tag='trash' and messages.msg_id=trash.msg_id ORDER BY deleted_at desc"); break; default: System.out.println("in default case"); } if (count > 0) { selectAllCB.setVisible(true); rows = new Object[count][]; msgID = new int[count]; try { workingSet.beforeFirst(); for (int i = 0; i < count && workingSet.next(); i++) { msgID[i] = workingSet.getInt(1); rows[i] = new Object[] { false, workingSet.getString(2), workingSet.getDate(3), workingSet.getString(4), workingSet.getString(5) }; } } catch (SQLException sqlExc) { JOptionPane.showMessageDialog(null, sqlExc, "EXCEPTION", JOptionPane.ERROR_MESSAGE); sqlExc.printStackTrace(); } tableModel = new MyDefaultTableModel(rows, columns); table = new JTable(tableModel); table.getSelectionModel().addListSelectionListener(this); table.addMouseListener(this); table.getTableHeader().setOpaque(true); table.getTableHeader().setReorderingAllowed(false); // table.getTableHeader().setBackground(Color.blue); table.getTableHeader().setForeground(Color.blue); // table.setRowSelectionAllowed(false); // table.setColumnSelectionAllowed(false); table.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 14)); table.setRowHeight(20); table.setFillsViewportHeight(true); TableColumn column = null; for (int i = 0; i < 5; i++) { column = table.getColumnModel().getColumn(i); if (i == 0) { column.setPreferredWidth(6); } else if (i == 3) { column.setPreferredWidth(250); } else if (i == 4) { column.setPreferredWidth(450); } else { column.setPreferredWidth(40); } } table.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS); remove(contentPan); contentPan = new JScrollPane(table); contentPan.setBackground(Color.orange); contentPan.setOpaque(true); contentPan.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); add(contentPan, "Center"); Home.home.homeFrame.setVisible(true); } else { JPanel centPan = new JPanel(new GridBagLayout()); centPan.setBackground(new Color(52, 86, 70)); JLabel label = new JLabel("No Messages In This Category"); label.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 22)); label.setForeground(Color.orange); centPan.add(label); remove(contentPan); contentPan = new JScrollPane(centPan); contentPan.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); add(contentPan, "Center"); contentPan.repaint(); } }
public void createGUI() { setLayout(new BorderLayout()); toolBar = new JToolBar("options", JToolBar.HORIZONTAL); toolBar.setFloatable(false); toolBar.setOpaque(true); toolBar.setBackground(new Color(154, 12, 12)); toolBar.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 15)); selectAllCB = new JCheckBox("Select All"); selectAllCB.setVisible(false); selectAllCB.setForeground(Color.white); selectAllCB.addActionListener(this); refreshBut = new JButton(new ImageIcon(this.getClass().getResource("/images/reloadIcon.png"))); refreshBut.setVisible(false); refreshBut.setToolTipText("Refresh"); refreshBut.setForeground(new Color(20, 88, 49)); refreshBut.addActionListener(this); backBut = new JButton(new ImageIcon(this.getClass().getResource("/images/backIcon.png"))); backBut.setVisible(false); backBut.setToolTipText("Back"); backBut.setForeground(new Color(20, 88, 49)); backBut.addActionListener(this); deleteBut = new JButton(new ImageIcon(this.getClass().getResource("/images/trashIcon.png"))); deleteBut.setToolTipText("Delete"); deleteBut.setForeground(Color.red); deleteBut.setVisible(false); deleteBut.addActionListener(this); deleteBut.setBackground(Color.red); restoreBut = new JButton(new ImageIcon(this.getClass().getResource("/images/restoreIcon.png"))); restoreBut.setToolTipText("Restore"); restoreBut.setForeground(Color.blue); restoreBut.setVisible(false); restoreBut.addActionListener(this); toolBar.addSeparator(new Dimension(10, 5)); toolBar.add(selectAllCB); toolBar.add(backBut); toolBar.add(refreshBut); toolBar.add(deleteBut); toolBar.add(restoreBut); add(toolBar, "North"); JPanel centPan = new JPanel(new GridBagLayout()); centPan.setBackground(new Color(52, 86, 70)); JLabel label = new JLabel("Select A Category From Left Pane"); label.setFont(new Font("arial", Font.BOLD, 35)); label.setForeground(Color.yellow); centPan.add(label); contentPan = new JScrollPane(centPan); contentPan.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); add(contentPan, "Center"); contentPan.repaint(); db = new Database(); // inboxSet = db.getData("SELECT * FROM messages WHERE tag='inbox' ORDER BY msg_id // desc"); // sentmailSet = db.getData("SELECT * FROM messages WHERE tag='sentmail' ORDER BY msg_id // desc"); // draftSet = db.getData("SELECT * FROM messages WHERE tag='draft' ORDER BY msg_id // desc"); // outboxSet = db.getData("SELECT * FROM messages WHERE tag='outbox' ORDER BY msg_id // desc"); // trashSet = db.getData("SELECT * FROM messages,trash WHERE messages.tag='trash' and // messages.msg_id=trash.msg_id ORDER BY deleted_at desc"); }
TextAreaCellRenderer() { super(); setLineWrap(true); setBorder(BorderFactory.createEmptyBorder(2, 4, 2, 4)); // setName("Table.cellRenderer"); }
JPanel criteriaPanel() { int height = getHeightPanel(m_field); m_table = new SearchTable(m_field); m_statusComboBox = new JComboBox(new Object[] {"Active", "Retired", "All"}); m_andRadioBt = new JRadioButton("and"); m_andRadioBt.setSelected(true); m_orRadioBt = new JRadioButton("or"); m_containsRadioBt = new JRadioButton("Text Contains Criteria"); m_containsRadioBt.setSelected(true); m_matchRadioBt = new JRadioButton("Match Case"); m_wholeRadioBt = new JRadioButton("Find Whole Words only"); m_findBt = new JButton("Find"); m_findBt.addActionListener(this); m_closeBt = new JButton("Close"); m_closeBt.addActionListener(this); m_clearBt = new JButton("Clear"); m_clearBt.addActionListener(this); ButtonGroup bg = new ButtonGroup(); bg.add(m_andRadioBt); bg.add(m_orRadioBt); ButtonGroup bg2 = new ButtonGroup(); bg2.add(m_containsRadioBt); bg2.add(m_matchRadioBt); bg2.add(m_wholeRadioBt); JPanel centerPanel = new JPanel(); JPanel criteriaPanel = new JPanel(); JPanel buttonPanel = new JPanel(); JPanel operatorPanel = new JPanel(); JPanel optionPanel = new JPanel(); JScrollPane scrollPane = new JScrollPane(); GridBagConstraints gridBagConstraints; scrollPane.setPreferredSize(new Dimension(100, height)); scrollPane.getViewport().add(m_table); operatorPanel.setLayout(new GridLayout(2, 1)); operatorPanel.add(m_andRadioBt); operatorPanel.add(m_orRadioBt); setBorder(operatorPanel, "Search Operator"); optionPanel.setLayout(new GridLayout(3, 1)); optionPanel.add(m_containsRadioBt); optionPanel.add(m_matchRadioBt); optionPanel.add(m_wholeRadioBt); setBorder(optionPanel, "Option"); criteriaPanel.setLayout(new GridBagLayout()); gridBagConstraints = new GridBagConstraints(); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER; gridBagConstraints.insets = new Insets(1, 0, 2, 0); gridBagConstraints.weightx = 1.0; // criteriaPanel.add(new JLabel("Search Criterion"), gridBagConstraints); setBorder(criteriaPanel, "Search Criterion"); gridBagConstraints.gridy = 1; gridBagConstraints.insets = new Insets(1, 0, 5, 0); criteriaPanel.add(scrollPane, gridBagConstraints); gridBagConstraints.gridy = 2; gridBagConstraints.insets = new Insets(1, 0, 2, 0); // criteriaPanel.add(new JLabel("Search Operator"), gridBagConstraints); gridBagConstraints.gridy = 3; gridBagConstraints.insets = new Insets(1, 0, 5, 0); criteriaPanel.add(operatorPanel, gridBagConstraints); gridBagConstraints.gridy = 4; gridBagConstraints.insets = new Insets(1, 0, 2, 0); gridBagConstraints.gridy = 5; criteriaPanel.add(optionPanel, gridBagConstraints); gridBagConstraints.gridy = 6; criteriaPanel.add(buttonPanel, gridBagConstraints); buttonPanel.setLayout(new FlowLayout(FlowLayout.RIGHT)); buttonPanel.add(m_findBt); buttonPanel.add(m_closeBt); buttonPanel.add(m_clearBt); centerPanel.setLayout(new BorderLayout()); centerPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); centerPanel.add(criteriaPanel, BorderLayout.NORTH); // centerPanel.add(buttonPanel, BorderLayout.SOUTH); return centerPanel; }
/** Initializes all GUI components */ private void initComponents() { mainPanel = new JPanel(); editPanel = new JPanel(); editPanelLeft = new JPanel(); editPanelCenter = new JPanel(); editPanelRight = new JPanel(); tablePanel = new JPanel(); companyIdTextField = new JTextField(); companyIdTextField.setEditable(false); companyNameTextField = new JTextField(); urlTextField = new JTextField(); insuranceTypesTextField = new JTextField(); telephoneTextField = new JTextField(); percentageTextField = new JTextField(); percentageTextField.setToolTipText("<html>Only <b>numerical</b> values allowed</html>"); searchTextField = new JTextField(); searchTextField.setToolTipText( "<html>Use either <b>AND</b> or <b>OR</b> for combined search queries<br>You can also use <b>spaces</b> instead of <b>OR</b></html>"); generalDescriptionTextField = new JTextField(); companyIdLabel = new InsuranceCompanyLabel("ID"); companyNameLabel = new InsuranceCompanyLabel("Company"); urlLabel = new InsuranceCompanyLabel("Website"); insuranceTypesLabel = new InsuranceCompanyLabel("Insurance Types"); telephoneLabel = new InsuranceCompanyLabel("Telephone"); percentageLabel = new InsuranceCompanyLabel("Broker Percentage"); searchLabel = new InsuranceCompanyLabel("Search Insurance Types"); generalDescriptionLabel = new InsuranceCompanyLabel("General Description"); sortLabel = new InsuranceCompanyLabel("Sorting"); addInsuranceCompanyButton = new InsuranceCompanyButton("New Insurance Company", 190, 45); addInsuranceCompanyButton.setToolTipText( "<html>Create a new <b>empty</b> Insurance Company</html>"); saveInsuranceCompanyButton = new InsuranceCompanyButton("Save Insurance Company", 190, 45); saveInsuranceCompanyButton.setToolTipText( "<html>Save the <b>selected</b> Insurance Company<br>Hint: Press <b>Enter</b> to quickly save an entry</html>"); saveInsuranceCompanyButton.setDefaultCapable(true); getRootPane() .setDefaultButton( saveInsuranceCompanyButton); // Set the save button as default button, so quicker // editing by pressing Enter is possible deleteInsuranceCompanyButton = new InsuranceCompanyButton("Delete Insurance Company", 190, 45); deleteInsuranceCompanyButton.setToolTipText( "<html>Delete the <b>selected</b> Insurance Company</html>"); clearSearchButton = new InsuranceCompanyButton("x", 40, 35); clearSearchButton.setToolTipText("<html>Click to <b>clear</b> the search field</html>"); String[] sortStrategies = {"ID", "Company Name", "Percentage"}; sortComboBox = new JComboBox(sortStrategies); tableData = new InsuranceCompanyTableModel(model.getInsuranceCompanies()); insuranceCompaniesTable = new JTable(); insuranceCompanyScrollPane = new JScrollPane(insuranceCompaniesTable); // Set layout and add components to panels setLayout(new BorderLayout()); add(mainPanel, BorderLayout.CENTER); mainPanel.setLayout(new BorderLayout()); mainPanel.add(editPanel, BorderLayout.NORTH); editPanel.setBorder(new EmptyBorder(10, 10, 10, 10)); editPanel.setLayout(new BorderLayout()); editPanel.add(editPanelLeft, BorderLayout.CENTER); editPanelLeft.setBorder(new EmptyBorder(0, 0, 5, 15)); editPanelLeft.setLayout(new GridLayout(4, 4, 5, 0)); editPanelLeft.add(companyIdLabel); editPanelLeft.add(companyNameLabel); editPanelLeft.add(urlLabel); editPanelLeft.add(telephoneLabel); editPanelLeft.add(companyIdTextField); editPanelLeft.add(companyNameTextField); editPanelLeft.add(urlTextField); editPanelLeft.add(telephoneTextField); editPanelLeft.add(percentageLabel); editPanelLeft.add(searchLabel); editPanelLeft.add(new JLabel()); editPanelLeft.add(sortLabel); editPanelLeft.add(percentageTextField); editPanelLeft.add(searchTextField); Container searchBox = Box.createVerticalBox(); searchBox.add(clearSearchButton); editPanelLeft.add(searchBox); editPanelLeft.add(sortComboBox); editPanel.add(editPanelRight, BorderLayout.EAST); Container box = Box.createVerticalBox(); box.add(saveInsuranceCompanyButton); box.add(Box.createVerticalStrut(5)); box.add(addInsuranceCompanyButton); box.add(Box.createVerticalStrut(5)); box.add(deleteInsuranceCompanyButton); editPanelRight.add(box); editPanel.add(editPanelCenter, BorderLayout.SOUTH); editPanelCenter.setLayout(new GridLayout(4, 1)); editPanelCenter.add(insuranceTypesLabel); editPanelCenter.add(insuranceTypesTextField); editPanelCenter.add(generalDescriptionLabel); editPanelCenter.add(generalDescriptionTextField); mainPanel.add(tablePanel, BorderLayout.CENTER); tablePanel.setBorder( BorderFactory.createTitledBorder( BorderFactory.createEmptyBorder(10, 10, 10, 10), "Insurance Companies Overview")); tablePanel.setLayout(new BorderLayout()); tablePanel.add(insuranceCompanyScrollPane, BorderLayout.CENTER); setMinimumSize(new Dimension(800, 600)); setPreferredSize(new Dimension(900, 600)); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); pack(); }
public ListSelectionDemo() { super(new BorderLayout()); String[] listData = {"one", "two", "three", "four", "five", "six", "seven"}; String[] columnNames = {"French", "Spanish", "Italian"}; list = new JList(listData); listSelectionModel = list.getSelectionModel(); listSelectionModel.addListSelectionListener(new SharedListSelectionHandler()); JScrollPane listPane = new JScrollPane(list); JPanel controlPane = new JPanel(); String[] modes = { "SINGLE_SELECTION", "SINGLE_INTERVAL_SELECTION", "MULTIPLE_INTERVAL_SELECTION" }; final JComboBox comboBox = new JComboBox(modes); comboBox.setSelectedIndex(2); comboBox.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { String newMode = (String) comboBox.getSelectedItem(); if (newMode.equals("SINGLE_SELECTION")) { listSelectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); } else if (newMode.equals("SINGLE_INTERVAL_SELECTION")) { listSelectionModel.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); } else { listSelectionModel.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); } output.append("----------" + "Mode: " + newMode + "----------" + newline); } }); controlPane.add(new JLabel("Selection mode:")); controlPane.add(comboBox); // Build output area. output = new JTextArea(1, 10); output.setEditable(false); JScrollPane outputPane = new JScrollPane( output, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); // Do the layout. JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); add(splitPane, BorderLayout.CENTER); JPanel topHalf = new JPanel(); topHalf.setLayout(new BoxLayout(topHalf, BoxLayout.LINE_AXIS)); JPanel listContainer = new JPanel(new GridLayout(1, 1)); listContainer.setBorder(BorderFactory.createTitledBorder("List")); listContainer.add(listPane); topHalf.setBorder(BorderFactory.createEmptyBorder(5, 5, 0, 5)); topHalf.add(listContainer); // topHalf.add(tableContainer); topHalf.setMinimumSize(new Dimension(100, 50)); topHalf.setPreferredSize(new Dimension(100, 110)); splitPane.add(topHalf); JPanel bottomHalf = new JPanel(new BorderLayout()); bottomHalf.add(controlPane, BorderLayout.PAGE_START); bottomHalf.add(outputPane, BorderLayout.CENTER); // XXX: next line needed if bottomHalf is a scroll pane: // bottomHalf.setMinimumSize(new Dimension(400, 50)); bottomHalf.setPreferredSize(new Dimension(450, 135)); splitPane.add(bottomHalf); }
/** Creates the Renderer. */ public ProtocolProviderTableCellRenderer() { this.setHorizontalAlignment(JLabel.LEFT); this.setOpaque(true); this.setBorder(BorderFactory.createEmptyBorder(0, 8, 0, 0)); }
private <T extends Enum<T>> void createControls(JPanel panel, ZrtpConfigureTableModel<T> model) { ResourceManagementService resources = NeomediaActivator.getResources(); final JButton upButton = new JButton(resources.getI18NString("impl.media.configform.UP")); upButton.setOpaque(false); final JButton downButton = new JButton(resources.getI18NString("impl.media.configform.DOWN")); downButton.setOpaque(false); Container buttonBar = new TransparentPanel(new GridLayout(0, 1)); buttonBar.add(upButton); buttonBar.add(downButton); panel.setBorder(BorderFactory.createEmptyBorder(MARGIN, MARGIN, MARGIN, MARGIN)); panel.setLayout(new GridBagLayout()); final JTable table = new JTable(model.getRowCount(), 2); table.setShowGrid(false); table.setTableHeader(null); table.setModel(model); // table.setFillsViewportHeight(true); // Since 1.6 only - nicer view /* * The first column contains the check boxes which enable/disable their * associated encodings and it doesn't make sense to make it wider than * the check boxes. */ TableColumnModel tableColumnModel = table.getColumnModel(); TableColumn tableColumn = tableColumnModel.getColumn(0); tableColumn.setMaxWidth(tableColumn.getMinWidth() + 5); table.doLayout(); GridBagConstraints constraints = new GridBagConstraints(); constraints.anchor = GridBagConstraints.CENTER; constraints.fill = GridBagConstraints.BOTH; constraints.gridwidth = 1; constraints.gridx = 0; constraints.gridy = 1; constraints.weightx = 1; constraints.weighty = 1; panel.add(new JScrollPane(table), constraints); constraints.anchor = GridBagConstraints.NORTHEAST; constraints.fill = GridBagConstraints.NONE; constraints.gridwidth = 1; constraints.gridx = 1; constraints.gridy = 1; constraints.weightx = 0; constraints.weighty = 0; panel.add(buttonBar, constraints); ListSelectionListener tableSelectionListener = new ListSelectionListener() { @SuppressWarnings("unchecked") public void valueChanged(ListSelectionEvent event) { if (table.getSelectedRowCount() == 1) { int selectedRow = table.getSelectedRow(); if (selectedRow > -1) { ZrtpConfigureTableModel<T> model = (ZrtpConfigureTableModel<T>) table.getModel(); upButton.setEnabled(selectedRow > 0 && model.checkEnableUp(selectedRow)); downButton.setEnabled( selectedRow < (table.getRowCount() - 1) && model.checkEnableDown(selectedRow)); return; } } upButton.setEnabled(false); downButton.setEnabled(false); } }; table.getSelectionModel().addListSelectionListener(tableSelectionListener); TableModelListener tableListener = new TableModelListener() { @SuppressWarnings("unchecked") public void tableChanged(TableModelEvent e) { if (table.getSelectedRowCount() == 1) { int selectedRow = table.getSelectedRow(); if (selectedRow > -1) { ZrtpConfigureTableModel<T> model = (ZrtpConfigureTableModel<T>) table.getModel(); upButton.setEnabled(selectedRow > 0 && model.checkEnableUp(selectedRow)); downButton.setEnabled( selectedRow < (table.getRowCount() - 1) && model.checkEnableDown(selectedRow)); return; } } upButton.setEnabled(false); downButton.setEnabled(false); } }; table.getModel().addTableModelListener(tableListener); tableSelectionListener.valueChanged(null); ActionListener buttonListener = new ActionListener() { @SuppressWarnings("unchecked") public void actionPerformed(ActionEvent event) { Object source = event.getSource(); boolean up; if (source == upButton) up = true; else if (source == downButton) up = false; else return; int index = ((ZrtpConfigureTableModel<T>) table.getModel()) .move(table.getSelectedRow(), up, up); table.getSelectionModel().setSelectionInterval(index, index); } }; upButton.addActionListener(buttonListener); downButton.addActionListener(buttonListener); }
public AncestralStatesPanel(BeautiFrame parent) { super(); this.frame = parent; partitionTableModel = new PartitionTableModel(); partitionTable = new JTable(partitionTableModel); partitionTable.getTableHeader().setReorderingAllowed(false); partitionTable.getTableHeader().setResizingAllowed(false); // modelTable.getTableHeader().setDefaultRenderer( // new HeaderRenderer(SwingConstants.LEFT, new Insets(0, 4, 0, 4))); final TableColumnModel model = partitionTable.getColumnModel(); final TableColumn tableColumn0 = model.getColumn(0); TableEditorStopper.ensureEditingStopWhenTableLosesFocus(partitionTable); partitionTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); partitionTable .getSelectionModel() .addListSelectionListener( new ListSelectionListener() { public void valueChanged(ListSelectionEvent evt) { selectionChanged(); } }); JScrollPane scrollPane = new JScrollPane( partitionTable, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); scrollPane.setOpaque(false); JPanel panel = new JPanel(new BorderLayout(0, 0)); panel.setOpaque(false); panel.add(scrollPane, BorderLayout.CENTER); panel.setMinimumSize(new Dimension(MINIMUM_TABLE_WIDTH, 0)); optionsPanelParent = new JPanel(new FlowLayout(FlowLayout.CENTER)); optionsPanelParent.setOpaque(false); optionsBorder = new TitledBorder("Ancestral state options:"); optionsPanelParent.setBorder(optionsBorder); setCurrentPartition(null); JScrollPane scrollPane2 = new JScrollPane( optionsPanelParent, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); scrollPane2.setOpaque(false); scrollPane2.setBorder(null); scrollPane2.getViewport().setOpaque(false); JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, panel, scrollPane2); splitPane.setDividerLocation(MINIMUM_TABLE_WIDTH); splitPane.setContinuousLayout(true); splitPane.setBorder(BorderFactory.createEmptyBorder()); splitPane.setOpaque(false); setOpaque(false); setBorder(new BorderUIResource.EmptyBorderUIResource(new Insets(12, 12, 12, 12))); setLayout(new BorderLayout(0, 0)); add(splitPane, BorderLayout.CENTER); }