Java Code Examples for javax.swing.JList#setFixedCellHeight()
The following examples show how to use
javax.swing.JList#setFixedCellHeight() .
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: ListPane.java From jdal with Apache License 2.0 | 6 votes |
public void init() { setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS)); tableIcon = FormUtils.getIcon(tableIcon, DEFAULT_TABLE_ICON); for (PanelHolder p : panels) p.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 0, 5)); list = new JList(new ListListModel(panels)); list.setBorder(BorderFactory.createEmptyBorder(5, 5 , 5, 5)); list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); list.setVisibleRowCount(-1); list.addListSelectionListener(this); list.setCellRenderer(renderer); list.setSelectedIndex(0); if (cellHeight != 0) list.setFixedCellHeight(cellHeight); JScrollPane scroll = new JScrollPane(list); split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, scroll, editorPanel); split.setResizeWeight(0); split.setDividerLocation(150); add(split); }
Example 2
Source File: ScoreTable.java From rcrs-server with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public JComponent getGUIComponent() { JTable table = new JTable(model.table); table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); JScrollPane scroll = new JScrollPane(table); JList rowHeader = new JList(model.list); rowHeader.setFixedCellHeight(table.getRowHeight()); rowHeader.setCellRenderer(new RowHeaderRenderer(table)); rowHeader.setBackground(table.getBackground()); rowHeader.setOpaque(true); scroll.setRowHeaderView(rowHeader); return scroll; }
Example 3
Source File: ConfigurableDialog.java From rapidminer-studio with GNU Affero General Public License v3.0 | 5 votes |
/** * Creates a new JList for a given source of a configurable * * @param source * can be null for local configurables, otherwise name of the source * @return the created JList */ private JList<Configurable> createNewConfigurableJList(String source) { final JList<Configurable> createdConfigList = new JList<>(); createdConfigList.setModel(source == null ? localConfigListModel : remoteConfigListModels.get(source)); createdConfigList.setCellRenderer(new ConfigurableRenderer()); createdConfigList.setFixedCellHeight(40); createdConfigList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); createdConfigList.setBackground(LIGHTER_GRAY); return createdConfigList; }
Example 4
Source File: ConfigurableDialog.java From rapidminer-studio with GNU Affero General Public License v3.0 | 5 votes |
/** * Creates a new JList for info labels of a source * * @param source * can be null for local source, otherwise name of the source * @return the created JList */ private JList<String> createNewInfoLabelJList(String source) { final JList<String> createdInfoLabelList = new JList<>(); createdInfoLabelList.setModel(source == null ? localInfoLabelListModel : remoteInfoLabelListModels.get(source)); createdInfoLabelList.setCellRenderer(new ConfigurableInfoLabelRenderer()); createdInfoLabelList.setFixedCellHeight(20); createdInfoLabelList.setBackground(LIGHTER_GRAY); return createdInfoLabelList; }
Example 5
Source File: ReadLogsWindow.java From Hotel-Properties-Management-System with GNU General Public License v2.0 | 4 votes |
private JList<String> logFilesList() { file = new File(System.getProperty("user.dir") + File.separator + "Logging Store/"); final JFileChooser fileChooser = new JFileChooser(); fileChooser.setCurrentDirectory(file); fileChooser.setMultiSelectionEnabled(true); final DefaultListModel<String> model = new DefaultListModel<String>(); final JList<String> list = new JList<String>(model); list.setPreferredSize(new Dimension(85, 480)); list.setFont(new Font("Dialog", Font.PLAIN, 12)); list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); list.setSelectedIndex(0); list.setFixedCellHeight(18); list.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { if (e.getClickCount() == 2) { selectedItem = list.getSelectedValue(); getSelectedFileName(); } } }); list.setCellRenderer(new LogRecordsListRenderer()); File[] selectedFiles = fileChooser.getCurrentDirectory().listFiles(); for (File f : selectedFiles) { if (f.getName().indexOf(".log") != -1) { model.addElement(f.getName()); }else { continue; } } if(model.isEmpty()) { model.addElement("List is empty!"); } return list; }
Example 6
Source File: JmxConnectionConfigurator.java From visualvm with GNU General Public License v2.0 | 4 votes |
private void initComponents() { okButton = new JButton(NbBundle.getMessage(JmxConnectionConfigurator.class, "LBL_OK")); // NOI18N hintLabel = new JLabel("") { // NOI18N public Dimension getPreferredSize() { Dimension d = super.getPreferredSize(); d.height = Math.max(d.height, okButton.getPreferredSize().height); return d; } }; hintLabel.setForeground(UIManager.getColor("Label.disabledForeground")); // NOI18N setLayout(new BorderLayout()); connectionTypeLabel = new JLabel(); Mnemonics.setLocalizedText(connectionTypeLabel, NbBundle.getMessage(JmxConnectionConfigurator.class, "LBL_Connection_type")); // NOI18N createBorder(connectionTypeLabel, BorderFactory.createEmptyBorder(15, 10, 0, 10)); add(connectionTypeLabel, BorderLayout.NORTH); connectionTypeListModel = new DefaultListModel(); connectionTypeList = new JList(connectionTypeListModel) { public String getToolTipText(MouseEvent evt) { JmxConnectionCustomizer cust = getCustomizer(evt.getPoint()); return cust == null ? null : cust.getPropertiesDescription(); } }; connectionTypeLabel.setLabelFor(connectionTypeList); connectionTypeList.setSelectionModel(new DefaultListSelectionModel() { public void removeSelectionInterval(int i1, int i2) {} }); connectionTypeList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); final ListCellRenderer defaultRenderer = connectionTypeList.getCellRenderer(); Component c = defaultRenderer.getListCellRendererComponent(connectionTypeList, "X", 0, false, false); // NOI18N connectionTypeList.setFixedCellHeight(c.getPreferredSize().height + 2); connectionTypeList.setCellRenderer(new ListCellRenderer() { public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { return defaultRenderer.getListCellRendererComponent(list, " " + value + " ", index, isSelected, cellHasFocus); // NOI18N } }); connectionTypeScroll = new JScrollPane(connectionTypeList, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED) { public Dimension getPreferredSize() { Dimension preferredSize = super.getPreferredSize(); preferredSize.width = Math.min(preferredSize.width, 300); preferredSize.width = Math.max(preferredSize.width, 120); return preferredSize; } }; createBorder(connectionTypeScroll, BorderFactory.createEmptyBorder(5, 10, 0, 0)); add(connectionTypeScroll, BorderLayout.WEST); customizerPanel = new JPanel(new BorderLayout()); customizerPanel.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); customizerPanelScroll = new ScrollableContainer(customizerPanel, ScrollableContainer.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollableContainer.HORIZONTAL_SCROLLBAR_NEVER); customizerPanelScroll.setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 5)); add(customizerPanelScroll, BorderLayout.CENTER); }