Java Code Examples for javax.swing.JSeparator#setPreferredSize()
The following examples show how to use
javax.swing.JSeparator#setPreferredSize() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: XJPopupMenu.java From gate-core with GNU Lesser General Public License v3.0 | 6 votes |
/** * Force separators to be the same width as the JPopupMenu. * This is because the MenuLayout make separators invisible contrary * to the default JPopupMenu layout manager. * @param aFlag true if the popupmenu is visible */ @Override public void setVisible(boolean aFlag) { super.setVisible(aFlag); if (!aFlag) { return; } MenuLayout layout = (MenuLayout) getLayout(); for (int i = 0; i < getComponents().length; i++) { Component component = getComponents()[i]; if (component instanceof JSeparator) { JSeparator separator = (JSeparator) component; int column = layout.getColumnForComponentIndex(i); int preferredWidth = layout.getPreferredWidthForColumn(column); // use the popupmenu width to set the separators width separator.setPreferredSize(new Dimension( preferredWidth, separator.getHeight())); } } revalidate(); }
Example 2
Source File: GridBagPanel.java From mzmine3 with GNU General Public License v2.0 | 5 votes |
public void addSeparator(int gridx, int gridy, int width) { JSeparator sep = new JSeparator(JSeparator.HORIZONTAL); sep.setPreferredSize(new Dimension(2, 1)); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridx = gridx; gbc.gridy = gridy; gbc.gridwidth = width; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.weightx = 1; add(sep, gbc); }
Example 3
Source File: PersistenceProviderComboboxHelper.java From netbeans with Apache License 2.0 | 5 votes |
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { if (isSelected) { setBackground(list.getSelectionBackground()); setForeground(list.getSelectionForeground()); } else { setBackground(list.getBackground()); setForeground(list.getForeground()); } if (value instanceof Provider) { Provider provider = (Provider)value; String text = provider.getDisplayName(); if (value.equals(defaultProvider) && (!(value instanceof DefaultProvider))) { text += NbBundle.getMessage(PersistenceProviderComboboxHelper.class, "LBL_DEFAULT_PROVIDER"); } setText(text); } else if (SEPARATOR.equals(value)) { JSeparator s = new JSeparator(); s.setPreferredSize(new Dimension(s.getWidth(), 1)); s.setForeground(Color.BLACK); return s; } else if (EMPTY.equals(value)) { setText(" "); } else if (value instanceof LibraryItem) { setText(((LibraryItem) value).getText()); } else { setText(value != null ? value.toString() : ""); // NOI18N } return this; }
Example 4
Source File: GridBagPanel.java From mzmine2 with GNU General Public License v2.0 | 5 votes |
public void addSeparator(int gridx, int gridy, int width) { JSeparator sep = new JSeparator(JSeparator.HORIZONTAL); sep.setPreferredSize(new Dimension(2, 1)); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridx = gridx; gbc.gridy = gridy; gbc.gridwidth = width; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.weightx = 1; add(sep, gbc); }
Example 5
Source File: UpdatePreferencesPanel.java From bigtable-sql with Apache License 2.0 | 5 votes |
private JSeparator getSep() { JSeparator sep = new JSeparator(SwingConstants.HORIZONTAL); // separators need preferred size in GridBagLayout sep.setPreferredSize(new Dimension(100, 20)); sep.setMinimumSize(new Dimension(100, 20)); return sep; }
Example 6
Source File: WebLaF.java From Cafebabe with GNU General Public License v3.0 | 4 votes |
public static JSeparator createSeparator() { JSeparator sep = new JSeparator(); sep.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED)); sep.setPreferredSize(new Dimension(5, 2)); return sep; }
Example 7
Source File: ReservedCheckinWindow.java From Hotel-Properties-Management-System with GNU General Public License v2.0 | 4 votes |
/** * Create the dialog. */ public ReservedCheckinWindow(Room roomNumber) { this.ownInjectedRoom = roomNumber; loggingEngine = LoggingEngine.getInstance(); loggingEngine.setMessage("User is : " + sessionBean.getNickName()); setMinimumSize(new Dimension(750, 495)); setPreferredSize(new Dimension(750, 495)); setLocationRelativeTo(null); this.setIconImage(Toolkit.getDefaultToolkit(). getImage(getClass().getResource(LOGOPATH))); getContentPane().setForeground(new Color(255, 99, 71)); getContentPane().setFocusCycleRoot(true); getContentPane().setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT); getContentPane().setFont(new Font("Verdana", Font.BOLD, 12)); setModalExclusionType(ModalExclusionType.APPLICATION_EXCLUDE); setDefaultCloseOperation(DISPOSE_ON_CLOSE); setModal(true); setResizable(false); this.setTitle("Coder HPMSA - [Checkin]"); contentPanel.setAutoscrolls(true); contentPanel.setPreferredSize(new Dimension(10, 415)); contentPanel.setBackground(Color.decode("#066d95")); contentPanel.setLayout(new BorderLayout(0, 0)); getContentPane().add(contentPanel, BorderLayout.SOUTH); upperPanel = new JPanel(); upperPanel.setBorder(new SoftBevelBorder(BevelBorder.RAISED, null, null, null, null)); upperPanel.setBackground(new Color(135, 206, 235)); upperPanel.setPreferredSize(new Dimension(10, 35)); contentPanel.add(upperPanel, BorderLayout.NORTH); JLabel lblChangeRoomPerson = new JLabel("Change person count : "); lblChangeRoomPerson.setFont(new Font("Arial", Font.PLAIN, 15)); upperPanel.add(lblChangeRoomPerson); spinner = new JSpinner(); spinner.setModel(new SpinnerNumberModel(1, 1, 3, 1)); spinner.setPreferredSize(new Dimension(40, 20)); spinner.setMinimumSize(new Dimension(35, 20)); spinner.addChangeListener(customerCounterListener()); upperPanel.add(spinner); JPanel buttonPanel = new JPanel(); buttonPanel.setBorder(new SoftBevelBorder(BevelBorder.RAISED, null, null, null, null)); buttonPanel.setPreferredSize(new Dimension(10, 50)); buttonPanel.setLayout(null); getContentPane().add(buttonPanel, BorderLayout.NORTH); JButton roomCheckinBtn = new JButton("Room checkin"); roomCheckinBtn.addActionListener(this); roomCheckinBtn.setIcon(new ImageIcon(ReservedCheckinWindow.class .getResource("/com/coder/hms/icons/extra_checkin.png"))); roomCheckinBtn.setBounds(7, 4, 130, 42); buttonPanel.add(roomCheckinBtn); final JSeparator separator = new JSeparator(); separator.setBackground(Color.DARK_GRAY); separator.setBounds(149, 6, 10, 36); separator.setOrientation(SwingConstants.VERTICAL); separator.setFocusable(true); separator.setForeground(Color.DARK_GRAY); separator.setAutoscrolls(true); separator.setPreferredSize(new Dimension(10, 20)); buttonPanel.add(separator); JLabel lblRoom = new JLabel("ROOM : "); lblRoom.setFont(new Font("Verdana", Font.BOLD, 15)); lblRoom.setBounds(330, 8, 68, 33); buttonPanel.add(lblRoom); JLabel roomNumberLbl = new JLabel(ownInjectedRoom.getNumber()); roomNumberLbl.setForeground(new Color(220, 20, 60)); roomNumberLbl.setFont(new Font("Verdana", Font.BOLD, 17)); roomNumberLbl.setBounds(406, 8, 103, 33); buttonPanel.add(roomNumberLbl); contentPanel.add(customerFormOne.setCustomerDetailPanel(), BorderLayout.WEST); prepareCustomerForms(ownInjectedRoom.getNumber()); }
Example 8
Source File: SearchPanelProvider.java From lucene-solr with Apache License 2.0 | 4 votes |
private JPanel initSearchResultsHeaderPane() { JPanel panel = new JPanel(new GridLayout(1, 2)); panel.setOpaque(false); JLabel label = new JLabel(FontUtils.elegantIconHtml("", MessageUtils.getLocalizedMessage("search.label.results"))); label.setHorizontalTextPosition(JLabel.LEFT); label.setBorder(BorderFactory.createEmptyBorder(2, 0, 2, 0)); panel.add(label); JPanel resultsInfo = new JPanel(new FlowLayout(FlowLayout.TRAILING)); resultsInfo.setOpaque(false); resultsInfo.setOpaque(false); JLabel totalLabel = new JLabel(MessageUtils.getLocalizedMessage("search.label.total")); resultsInfo.add(totalLabel); totalHitsLbl.setText("?"); resultsInfo.add(totalHitsLbl); prevBtn.setText(FontUtils.elegantIconHtml("D")); prevBtn.setMargin(new Insets(5, 0, 5, 0)); prevBtn.setPreferredSize(new Dimension(30, 20)); prevBtn.setEnabled(false); prevBtn.addActionListener(listeners::prevPage); resultsInfo.add(prevBtn); startLbl.setText("0"); resultsInfo.add(startLbl); resultsInfo.add(new JLabel(" ~ ")); endLbl.setText("0"); resultsInfo.add(endLbl); nextBtn.setText(FontUtils.elegantIconHtml("E")); nextBtn.setMargin(new Insets(3, 0, 3, 0)); nextBtn.setPreferredSize(new Dimension(30, 20)); nextBtn.setEnabled(false); nextBtn.addActionListener(listeners::nextPage); resultsInfo.add(nextBtn); JSeparator sep = new JSeparator(JSeparator.VERTICAL); sep.setPreferredSize(new Dimension(5, 1)); resultsInfo.add(sep); delBtn.setText(FontUtils.elegantIconHtml("", MessageUtils.getLocalizedMessage("search.button.del_all"))); delBtn.setMargin(new Insets(5, 0, 5, 0)); delBtn.setEnabled(false); delBtn.addActionListener(listeners::confirmDeletion); resultsInfo.add(delBtn); panel.add(resultsInfo, BorderLayout.CENTER); return panel; }
Example 9
Source File: frmMain.java From Course_Generator with GNU General Public License v3.0 | 4 votes |
/** * Separator for the status bar * * @return Separator object */ static JComponent createStatusbarSeparator() { JSeparator x = new JSeparator(SwingConstants.VERTICAL); x.setPreferredSize(new Dimension(3, 20)); return x; }
Example 10
Source File: AbstractUndoableMovesPanel.java From triplea with GNU General Public License v3.0 | 4 votes |
private void initLayout() { removeAll(); setLayout(new BorderLayout()); final JPanel items = new JPanel(); items.setLayout(new BoxLayout(items, BoxLayout.Y_AXIS)); // we want the newest move at the top moves = new ArrayList<>(moves); Collections.reverse(moves); final Iterator<AbstractUndoableMove> iter = moves.iterator(); if (iter.hasNext()) { add( new JLabel((this instanceof UndoablePlacementsPanel) ? "Placements:" : "Moves:"), BorderLayout.NORTH); } int scrollIncrement = 10; final Dimension separatorSize = new Dimension(150, 20); while (iter.hasNext()) { final AbstractUndoableMove item = iter.next(); final JComponent moveComponent = newComponentForMove(item); scrollIncrement = moveComponent.getPreferredSize().height; items.add(moveComponent); if (iter.hasNext()) { final JSeparator separator = new JSeparator(SwingConstants.HORIZONTAL); separator.setPreferredSize(separatorSize); separator.setMaximumSize(separatorSize); items.add(separator); } } if (movePanel.getUndoableMoves() != null && movePanel.getUndoableMoves().size() > 1) { final JButton undoAllButton = new JButton("Undo All"); undoAllButton.addActionListener(new UndoAllMovesActionListener()); items.add(undoAllButton); } final int scrollIncrementFinal = scrollIncrement + separatorSize.height; // JScrollPane scroll = new JScrollPane(items); scroll = new JScrollPane(items) { private static final long serialVersionUID = -1064967105431785533L; @Override public void paint(final Graphics g) { if (previousVisibleIndex != null) { items.scrollRectToVisible( new Rectangle( 0, scrollIncrementFinal * (moves.size() - previousVisibleIndex), 1, scrollIncrementFinal)); previousVisibleIndex = null; } super.paint(g); } }; scroll.setBorder(null); scroll.getVerticalScrollBar().setUnitIncrement(scrollIncrementFinal); if (scrollBarPreviousValue != null) { scroll.getVerticalScrollBar().setValue(scrollBarPreviousValue); scrollBarPreviousValue = null; } add(scroll, BorderLayout.CENTER); SwingUtilities.invokeLater(this::validate); }
Example 11
Source File: WebSocketUiHelper.java From zap-extensions with Apache License 2.0 | 4 votes |
public JComponent createVerticalSeparator() { JSeparator x = new JSeparator(SwingConstants.VERTICAL); x.setPreferredSize(DisplayUtils.getScaledDimension(20, 20)); return x; }
Example 12
Source File: AKDockLayout.java From WorldPainter with GNU General Public License v3.0 | 2 votes |
private void flipSeparators(Component c, int orientn) { if (c != null && c instanceof JToolBar && UIManager.getLookAndFeel().getName().toLowerCase().indexOf("windows") != -1) { JToolBar jtb = (JToolBar) c; Component comps[] = jtb.getComponents(); if (comps != null && comps.length > 0) { for (int i = 0; i < comps.length; i++) { try { Component component = comps[i]; if (component != null) { if (component instanceof JSeparator) { jtb.remove(component); JSeparator separ = new JSeparator(); if (orientn == SwingConstants.VERTICAL) { separ.setOrientation(SwingConstants.VERTICAL); separ.setMinimumSize(new Dimension(2, 6)); separ.setPreferredSize(new Dimension(2, 6)); separ.setMaximumSize(new Dimension(2, 100)); } else { separ.setOrientation(SwingConstants.HORIZONTAL); separ.setMinimumSize(new Dimension(6, 2)); separ.setPreferredSize(new Dimension(6, 2)); separ.setMaximumSize(new Dimension(100, 2)); } jtb.add(separ, i); } } } catch (Exception e) { e.printStackTrace(); } } } } }