private MyWindow() { super(FEST65_JListFixtureNotSelectingItemsWithLongText_Test.class); list.setName("list"); JScrollPane scrollPane = new JScrollPane(list); scrollPane.setPreferredSize(new Dimension(150, 100)); addComponents(scrollPane); }
private JList<String> getPmListaCodigosSud() { if (pmListaCodigosSud == null) { pmListaCodigosSud = new JList<String>(); pmListaCodigosSud.setName("List_Sudokus_Modificar"); pmListaCodigosSud.addListSelectionListener(getControlador()); pmListaCodigosSud.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); pmListaCodigosSud.setModel(getPmListModelCodigosSud()); pmListaCodigosSud.setBorder(new LineBorder(new Color(0, 0, 0))); } return pmListaCodigosSud; }
/** * This method initializes this * * @return void */ private void initialize() { this.setLayout(new CardLayout()); // this.setSize(474, 251); this.setName(Constant.messages.getString("search.panel.title")); this.setIcon( new ImageIcon( getClass().getResource("/resource/icon/16/049.png"))); // 'magnifying glass' icon this.add(getPanelCommand(), getPanelCommand().getName()); resultsModel = new DefaultListModel(); resultsList.setModel(resultsModel); resultsList.setName("listSearch"); resultsList.setFixedCellHeight(16); // Significantly speeds up rendering resultsList.addMouseListener( new java.awt.event.MouseAdapter() { @Override public void mousePressed(java.awt.event.MouseEvent e) { if (SwingUtilities.isRightMouseButton(e)) { View.getSingleton().getPopupMenu().show(e.getComponent(), e.getX(), e.getY()); // Select list item on right click int Idx = resultsList.locationToIndex(e.getPoint()); if (Idx >= 0) { Rectangle Rect = resultsList.getCellBounds(Idx, Idx); Idx = Rect.contains(e.getPoint().x, e.getPoint().y) ? Idx : -1; } if (Idx < 0 || !resultsList.getSelectionModel().isSelectedIndex(Idx)) { resultsList.getSelectionModel().clearSelection(); if (Idx >= 0) { resultsList.getSelectionModel().setSelectionInterval(Idx, Idx); } } } } }); resultsList.setCellRenderer(getSearchPanelCellRenderer()); resultsList.addListSelectionListener( new javax.swing.event.ListSelectionListener() { @Override public void valueChanged(javax.swing.event.ListSelectionEvent e) { if (resultsList.getSelectedValue() == null) { return; } if (!e.getValueIsAdjusting()) { displayMessage(((SearchResult) resultsList.getSelectedValue())); } } }); }
/** * Returns the message to display from the JOptionPane the receiver is providing the look and feel * for. */ protected Object getMessage() { inputComponent = null; if (optionPane != null) { if (optionPane.getWantsInput()) { /* Create a user component to capture the input. If the selectionValues are non null the component and there are < 20 values it'll be a combobox, if non null and >= 20, it'll be a list, otherwise it'll be a textfield. */ Object message = optionPane.getMessage(); Object[] sValues = optionPane.getSelectionValues(); Object inputValue = optionPane.getInitialSelectionValue(); JComponent toAdd; if (sValues != null) { if (sValues.length < 20) { JComboBox cBox = new JComboBox(); cBox.setName("OptionPane.comboBox"); for (int counter = 0, maxCounter = sValues.length; counter < maxCounter; counter++) { cBox.addItem(sValues[counter]); } if (inputValue != null) { cBox.setSelectedItem(inputValue); } inputComponent = cBox; toAdd = cBox; } else { JList list = new JList(sValues); JScrollPane sp = new JScrollPane(list); sp.setName("OptionPane.scrollPane"); list.setName("OptionPane.list"); list.setVisibleRowCount(10); list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); if (inputValue != null) list.setSelectedValue(inputValue, true); list.addMouseListener(getHandler()); toAdd = sp; inputComponent = list; } } else { MultiplexingTextField tf = new MultiplexingTextField(20); tf.setName("OptionPane.textField"); tf.setKeyStrokes(new KeyStroke[] {KeyStroke.getKeyStroke("ENTER")}); if (inputValue != null) { String inputString = inputValue.toString(); tf.setText(inputString); tf.setSelectionStart(0); tf.setSelectionEnd(inputString.length()); } tf.addActionListener(getHandler()); toAdd = inputComponent = tf; } Object[] newMessage; if (message == null) { newMessage = new Object[1]; newMessage[0] = toAdd; } else { newMessage = new Object[2]; newMessage[0] = message; newMessage[1] = toAdd; } return newMessage; } return optionPane.getMessage(); } return null; }
private JList usersList() { todoItemsList = new JList(); todoItemsList.setName("todolist"); updateTodoItems(); return todoItemsList; }