public SplitPaneDemo() { // Create the list of images and put it in a scroll pane. list = new JList(imageNames); list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); list.setSelectedIndex(0); list.addListSelectionListener(this); JScrollPane listScrollPane = new JScrollPane(list); picture = new JLabel(); picture.setFont(picture.getFont().deriveFont(Font.ITALIC)); picture.setHorizontalAlignment(JLabel.CENTER); JScrollPane pictureScrollPane = new JScrollPane(picture); // Create a split pane with the two scroll panes in it. splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, listScrollPane, pictureScrollPane); splitPane.setOneTouchExpandable(true); splitPane.setDividerLocation(150); // Provide minimum sizes for the two components in the split pane. Dimension minimumSize = new Dimension(100, 50); listScrollPane.setMinimumSize(minimumSize); pictureScrollPane.setMinimumSize(minimumSize); // Provide a preferred size for the split pane. splitPane.setPreferredSize(new Dimension(400, 200)); updateLabel(imageNames[list.getSelectedIndex()]); }
public Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { // #93658: GTK needs name to render cell renderer "natively" setName("ComboBox.listRenderer"); // NOI18N String config = (String) value; String label; if (config == null) { // uninitialized? label = null; } else if (config.length() > 0) { Map<String, String> m = configs.get(config); label = m != null ? m.get("$label") : /* temporary? */ null; // NOI18N if (label == null) { label = config; } } else { label = NbBundle.getBundle("org.netbeans.modules.java.j2seproject.Bundle") .getString("J2SEConfigurationProvider.default.label"); // NOI18N } setText(label); if (isSelected) { setBackground(list.getSelectionBackground()); setForeground(list.getSelectionForeground()); } else { setBackground(list.getBackground()); setForeground(list.getForeground()); } return this; }
@Override protected void doOKAction() { apply((SeverityBasedTextAttributes) myOptionsList.getSelectedValue()); final Collection<SeverityBasedTextAttributes> infoTypes = new HashSet<SeverityBasedTextAttributes>( SeverityUtil.getRegisteredHighlightingInfoTypes(mySeverityRegistrar)); final ListModel listModel = myOptionsList.getModel(); final List<HighlightSeverity> order = new ArrayList<HighlightSeverity>(); for (int i = listModel.getSize() - 1; i >= 0; i--) { final SeverityBasedTextAttributes info = (SeverityBasedTextAttributes) listModel.getElementAt(i); order.add(info.getSeverity()); if (!mySeverityRegistrar.isDefaultSeverity(info.getSeverity())) { infoTypes.remove(info); final Color stripeColor = info.getAttributes().getErrorStripeColor(); mySeverityRegistrar.registerSeverity( info, stripeColor != null ? stripeColor : LightColors.YELLOW); } } for (SeverityBasedTextAttributes info : infoTypes) { mySeverityRegistrar.unregisterSeverity(info.getSeverity()); } mySeverityRegistrar.setOrder(order); super.doOKAction(); }
private void fillList(final HighlightSeverity severity) { DefaultListModel model = new DefaultListModel(); model.removeAllElements(); final List<SeverityBasedTextAttributes> infoTypes = new ArrayList<SeverityBasedTextAttributes>(); infoTypes.addAll(SeverityUtil.getRegisteredHighlightingInfoTypes(mySeverityRegistrar)); Collections.sort( infoTypes, new Comparator<SeverityBasedTextAttributes>() { @Override public int compare( SeverityBasedTextAttributes attributes1, SeverityBasedTextAttributes attributes2) { return -mySeverityRegistrar.compare( attributes1.getSeverity(), attributes2.getSeverity()); } }); SeverityBasedTextAttributes preselection = null; for (SeverityBasedTextAttributes type : infoTypes) { model.addElement(type); if (type.getSeverity().equals(severity)) { preselection = type; } } myOptionsList.setModel(model); myOptionsList.setSelectedValue(preselection, true); }
@Override public void actionPerformed(ActionEvent e) { if (e.getSource() == btnQAuswahl) { addQListBoxEintrag(dateiAuswählen()); } if (e.getSource() == btnQEntfernen) { subQListBoxEintrag(); } if (e.getSource() == btnZAuswahl) { addZListBoxEintrag(dateiAuswählen()); } if (e.getSource() == btnZEntfernen) { subZListBoxEintrag(); } if (e.getSource() == btnSync) { startCopy( (Path) quellJList.getSelectedValue().getValueMember(), (Path) zielJList.getSelectedValue().getValueMember()); } if (e.getSource() == btnAbbruch) { setAbbruch(); } if (e.getSource() == btnBackup) { MainNtray.bwvisible(); this.invisible(); } }
/** Set the contents of the field selector list. */ private void setupFieldSelector() { fieldListModel.clear(); SortedSet<String> contents = new TreeSet<String>(); for (String s : metaData) { if (s.startsWith(Globals.SELECTOR_META_PREFIX)) { contents.add(s.substring(Globals.SELECTOR_META_PREFIX.length())); } } if (contents.size() == 0) { // if nothing was added, put the default fields (as described in the help) fieldListModel.addElement("author"); fieldListModel.addElement("journal"); fieldListModel.addElement("keywords"); fieldListModel.addElement("publisher"); } else { for (String s : contents) { fieldListModel.addElement(s); } } if (currentField == null) { // if dialog is created for the whole database, // select the first field to avoid confusions in GUI usage fieldList.setSelectedIndex(0); } else { // a specific field has been chosen at the constructur // select this field int i = fieldListModel.indexOf(currentField); if (i != -1) { // field has been found in list, select it fieldList.setSelectedIndex(i); } } }
private void removeSdk() { final Sdk currentSdk = getSelectedSdk(); if (currentSdk != null) { final Sdk sdk = myProjectSdksModel.findSdk(currentSdk); final PySdkService sdkService = PySdkService.getInstance(); sdkService.removeSdk(currentSdk); DumbService.allowStartingDumbModeInside( DumbModePermission.MAY_START_MODAL, () -> SdkConfigurationUtil.removeSdk(sdk)); myProjectSdksModel.removeSdk(sdk); myProjectSdksModel.removeSdk(currentSdk); if (myModificators.containsKey(currentSdk)) { SdkModificator modificator = myModificators.get(currentSdk); myModifiedModificators.remove(modificator); myModificators.remove(currentSdk); } refreshSdkList(); mySdkListChanged = true; // TODO select initially selected SDK if (mySdkList.getSelectedIndex() < 0) { mySdkList.setSelectedIndex(0); } } }
// サーバーから送られてきたメッセージの処理 public void reachedMessage(String name, String value) { // チャットルームのリストに変更が加えられた if (name.equals("rooms")) { if (value.equals("")) { roomList.setModel(new DefaultListModel()); } else { String[] rooms = value.split(" "); roomList.setListData(rooms); } } // ユーザーが入退室した else if (name.equals("users")) { if (value.equals("")) { userList.setModel(new DefaultListModel()); } else { String[] users = value.split(" "); userList.setListData(users); } } // メッセージが送られてきた else if (name.equals("msg")) { msgTextArea.append(value + "\n"); } // 処理に成功した else if (name.equals("successful")) { if (value.equals("setName")) msgTextArea.append(">名前を変更しました\n"); } // エラーが発生した else if (name.equals("error")) { msgTextArea.append("ERROR>" + value + "\n"); } }
public void update() { setLabels(); hallList.setListData(getHalls()); roomItemsList.setListData(getRoomItems()); Object[] items = (model.getPlayer().getItemList().toArray()); playerItemsList.setListData(items); if (model.playerDied()) endGame("You Lose!"); }
/** Creates a JList of files and sets and makes it non-selectable. */ private static JList<String> createFileList(List<String> fileNames) { JList<String> fileList = new JList<String>(fileNames.toArray(new String[0])); fileList.setVisibleRowCount(5); fileList.setCellRenderer(new FileNameListCellRenderer()); // fileList.setSelectionForeground(fileList.getForeground()); // fileList.setSelectionBackground(fileList.getBackground()); fileList.setFocusable(false); return fileList; }
public void valueChanged(ListSelectionEvent evt) { if (!evt.getValueIsAdjusting()) { JFileChooser chooser = getFileChooser(); FileSystemView fsv = chooser.getFileSystemView(); JList list = (JList) evt.getSource(); int fsm = chooser.getFileSelectionMode(); boolean useSetDirectory = usesSingleFilePane && (fsm == JFileChooser.FILES_ONLY); if (chooser.isMultiSelectionEnabled()) { File[] files = null; Object[] objects = list.getSelectedValues(); if (objects != null) { if (objects.length == 1 && ((File) objects[0]).isDirectory() && chooser.isTraversable(((File) objects[0])) && (useSetDirectory || !fsv.isFileSystem(((File) objects[0])))) { setDirectorySelected(true); setDirectory(((File) objects[0])); } else { ArrayList<File> fList = new ArrayList<File>(objects.length); for (Object object : objects) { File f = (File) object; boolean isDir = f.isDirectory(); if ((chooser.isFileSelectionEnabled() && !isDir) || (chooser.isDirectorySelectionEnabled() && fsv.isFileSystem(f) && isDir)) { fList.add(f); } } if (fList.size() > 0) { files = fList.toArray(new File[fList.size()]); } setDirectorySelected(false); } } chooser.setSelectedFiles(files); } else { File file = (File) list.getSelectedValue(); if (file != null && file.isDirectory() && chooser.isTraversable(file) && (useSetDirectory || !fsv.isFileSystem(file))) { setDirectorySelected(true); setDirectory(file); if (usesSingleFilePane) { chooser.setSelectedFile(null); } } else { setDirectorySelected(false); if (file != null) { chooser.setSelectedFile(file); } } } } }
private boolean ensureSelectionExists() { if (myList.getSelectedIndex() < 0 || myList.getSelectedIndex() >= myList.getModel().getSize()) { if (myList.getModel().getSize() >= 0) { myList.setSelectedIndex(0); return false; } } return true; }
/** Update the workspace's list of files */ private void updateWorkspace() { File home[] = (new File(directory)).listFiles(); ((DefaultListModel) workspaceList.getModel()).clear(); ((DefaultListModel) workspaceList.getModel()).ensureCapacity(home.length); for (int x = 0; x < home.length; x++) { ((DefaultListModel) workspaceList.getModel()).addElement(home[x]); } }
/** Update state dialog depending on the current state of the fields */ private void updateDialogState() { String branch = myBranchTextField.getText(); if (branch.length() != 0) { setOKButtonText(GitBundle.getString("unstash.button.branch")); myPopStashCheckBox.setEnabled(false); myPopStashCheckBox.setSelected(true); myReinstateIndexCheckBox.setEnabled(false); myReinstateIndexCheckBox.setSelected(true); if (!GitBranchNameValidator.INSTANCE.checkInput(branch)) { setErrorText(GitBundle.getString("unstash.error.invalid.branch.name")); setOKActionEnabled(false); return; } if (myBranches.contains(branch)) { setErrorText(GitBundle.getString("unstash.error.branch.exists")); setOKActionEnabled(false); return; } } else { if (!myPopStashCheckBox.isEnabled()) { myPopStashCheckBox.setSelected(false); } myPopStashCheckBox.setEnabled(true); setOKButtonText( myPopStashCheckBox.isSelected() ? GitBundle.getString("unstash.button.pop") : GitBundle.getString("unstash.button.apply")); if (!myReinstateIndexCheckBox.isEnabled()) { myReinstateIndexCheckBox.setSelected(false); } myReinstateIndexCheckBox.setEnabled(true); } if (myStashList.getModel().getSize() == 0) { myViewButton.setEnabled(false); myDropButton.setEnabled(false); myClearButton.setEnabled(false); setErrorText(null); setOKActionEnabled(false); return; } else { myClearButton.setEnabled(true); } if (myStashList.getSelectedIndex() == -1) { myViewButton.setEnabled(false); myDropButton.setEnabled(false); setErrorText(null); setOKActionEnabled(false); return; } else { myViewButton.setEnabled(true); myDropButton.setEnabled(true); } setErrorText(null); setOKActionEnabled(true); }
private void showContextMenu(JList characterList, MouseEvent mouseEvent) { // TODO: handle right-click outside of selected range correctly (should treat as single // selection, but not deselect) boolean multipleSelected = herolabsCharacterList.getSelectedValues().length > 1; if (mouseEvent.isPopupTrigger() && mouseEvent.getClickCount() == 1) { if (!multipleSelected) { herolabsCharacterList.setSelectedIndex( herolabsCharacterList.locationToIndex(mouseEvent.getPoint())); } if (contextMenuEnabled) { JPopupMenu menu = new JPopupMenu(); JMenuItem menuItem; menuItem = new JMenuItem("Configure character" + (multipleSelected ? "s" : "") + "..."); menuItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { configureSelectedCharacters(); } }); menu.add(menuItem); menuItem = new JMenuItem("Configure using portfolio defaults"); menuItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { resetToDefaultsForSelectedCharacters(); } }); menu.add(menuItem); menuItem = new JMenuItem("Export character" + (multipleSelected ? "s" : "")); menuItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { exportSelectedCharacters(); } }); menu.add(menuItem); menuItem = new JMenuItem("Clear configuration" + (multipleSelected ? "s" : "")); menuItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { clearConfigForSelectedCharacters(); } }); menu.add(menuItem); menu.show(characterList, mouseEvent.getX(), mouseEvent.getY()); } } }
/** Create the tabbed panels for the GUI */ private void createTabs() { // Create the tabbed pane mainPanel = new JTabbedPane(JTabbedPane.BOTTOM); // Create the various panels workspacePanel = new JPanel(new BorderLayout()); userListPanel = new JPanel(new BorderLayout()); searchPanel = new JPanel(new GridLayout(0, 2)); // Create the pieces of the workspace panel workspaceList.setLayoutOrientation(JList.VERTICAL_WRAP); workspacePanel.add(new JScrollPane(workspaceList)); workspacePanel.add(new JLabel("Local File Listing"), BorderLayout.NORTH); // Create the UserList tab JPanel labelPanel = new JPanel(new GridLayout(0, 2)); labelPanel.add(new JLabel("Users Connected:")); labelPanel.add(new JLabel("Selected User's Files:")); JPanel listPanel = new JPanel(new GridLayout(0, 2)); listPanel.add(new JScrollPane(userList)); listPanel.add(new JScrollPane(fileList)); userList.addMouseListener(mouseHandler); fileList.addMouseListener(mouseHandler); userListPanel.add(labelPanel, BorderLayout.NORTH); userListPanel.add(listPanel, BorderLayout.CENTER); // Create Search Panel searchPanel = new JPanel(new BorderLayout()); JPanel searchOpsPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); searchName = new JTextField(20); searchInit = new JButton("Search"); searchInit.addMouseListener(mouseHandler); String types[] = {"Image", "Video", "Audio", "Any"}; searchType = new JComboBox(types); searchType.setSelectedIndex(3); searchOpsPanel.add(new JLabel("Search String")); searchOpsPanel.add(searchName); searchOpsPanel.add(new JLabel("File Type")); searchOpsPanel.add(searchType); searchOpsPanel.add(searchInit); searchPanel.add(new JScrollPane(searchList)); searchPanel.add(searchOpsPanel, BorderLayout.NORTH); // Add panels to the tab pane mainPanel.addTab("Home", workspacePanel); mainPanel.addTab("Server", userListPanel); mainPanel.addTab("Search", searchPanel); }
public void mouseEntered(MouseEvent evt) { if (list != null) { TransferHandler th1 = getFileChooser().getTransferHandler(); TransferHandler th2 = list.getTransferHandler(); if (th1 != th2) { list.setTransferHandler(th1); } if (getFileChooser().getDragEnabled() != list.getDragEnabled()) { list.setDragEnabled(getFileChooser().getDragEnabled()); } } }
/** Requests and displays all packages older than the date in the text field */ private void buttonOldPackagesActionPerformed(ActionEvent event) { try { queryTime.setTime(dateFormatter.parse(jTextDate.getText().replace("-", "") + "2359")); this.packages = DataAdapter.getOlderPackages(queryTime); jListPackages.setListData(new Vector(this.packages)); jButtonSetLost.setEnabled(this.packages.size() > 0); jButtonSetFound.setEnabled(false); jListScans.setListData(new Vector()); } catch (Exception ex) { JOptionPane.showMessageDialog(this, "Invalid date entered"); } }
/** Update the list of files on remote host */ private void updateFileList() { ArrayList files = link.getFiles(); ((DefaultListModel) fileList.getModel()).clear(); ((DefaultListModel) fileList.getModel()).ensureCapacity(files.size()); for (int x = 0; x < files.size(); x++) { ((DefaultListModel) fileList.getModel()).addElement(files.get(x)); } // fileList.ensureIndexIsVisible(files.size()); }
/** Update the list of connected users */ private void updateUserList() { ArrayList users = active.getHosts(); ((DefaultListModel) userList.getModel()).clear(); ((DefaultListModel) userList.getModel()).ensureCapacity(users.size()); for (int x = 0; x < users.size(); x++) { ((DefaultListModel) userList.getModel()).addElement(users.get(x)); } // userList.ensureIndexIsVisible(users.size()); }
@Override public void mousePressed(MouseEvent e) { JList list = (JList) e.getComponent(); Point pt = e.getPoint(); int index = list.locationToIndex(pt); if (index >= 0) { JButton button = getButton(list, pt, index); if (Objects.nonNull(button)) { listRepaint(list, list.getCellBounds(index, index)); } } }
/** adds a found scan to a seleceted lost package */ private void buttonSetFoundActionPerformed(ActionEvent event) { int index = jListPackages.getSelectedIndex(); if (index >= 0) { Package p = this.packages.get(index); if (p.lastScan().event == ScanEvents.lost) { p.scan(ScanEvents.found, this.user); this.packages.remove(p); this.jListPackages.setListData(new Vector(this.packages)); jListScans.setListData(new Vector()); } } }
/** Constructor */ public ServiceFilterPanel(String text, Vector list) { empty_border = new EmptyBorder(5, 5, 0, 5); indent_border = new EmptyBorder(5, 25, 5, 5); service_box = new JCheckBox(text); service_box.addActionListener(this); service_data = new Vector(); if (list != null) { service_box.setSelected(true); service_data = (Vector) list.clone(); } service_list = new JList(service_data); service_list.setBorder(new EtchedBorder()); service_list.setVisibleRowCount(5); service_list.addListSelectionListener(this); service_list.setEnabled(service_box.isSelected()); service_scroll = new JScrollPane(service_list); service_scroll.setBorder(new EtchedBorder()); remove_service_button = new JButton("Remove"); remove_service_button.addActionListener(this); remove_service_button.setEnabled(false); remove_service_panel = new JPanel(); remove_service_panel.setLayout(new FlowLayout()); remove_service_panel.add(remove_service_button); service_area = new JPanel(); service_area.setLayout(new BorderLayout()); service_area.add(service_scroll, BorderLayout.CENTER); service_area.add(remove_service_panel, BorderLayout.EAST); service_area.setBorder(indent_border); add_service_field = new JTextField(); add_service_field.addActionListener(this); add_service_field.getDocument().addDocumentListener(this); add_service_field.setEnabled(service_box.isSelected()); add_service_button = new JButton("Add"); add_service_button.addActionListener(this); add_service_button.setEnabled(false); add_service_panel = new JPanel(); add_service_panel.setLayout(new BorderLayout()); JPanel dummy = new JPanel(); dummy.setBorder(empty_border); add_service_panel.add(dummy, BorderLayout.WEST); add_service_panel.add(add_service_button, BorderLayout.EAST); add_service_area = new JPanel(); add_service_area.setLayout(new BorderLayout()); add_service_area.add(add_service_field, BorderLayout.CENTER); add_service_area.add(add_service_panel, BorderLayout.EAST); add_service_area.setBorder(indent_border); setLayout(new BorderLayout()); add(service_box, BorderLayout.NORTH); add(service_area, BorderLayout.CENTER); add(add_service_area, BorderLayout.SOUTH); setBorder(empty_border); }
public Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { setText(value.toString()); setBackground(isSelected ? list.getSelectionBackground() : list.getBackground()); setForeground(isSelected ? list.getSelectionForeground() : list.getForeground()); setFont(list.getFont()); setBorder( (cellHasFocus) ? UIManager.getBorder("List.focusCellHighlightBorder") : m_noFocusBorder); return this; }
/** * Return a component that has been configured to display the specified value. * * @see javax.swing.ListCellRenderer#getListCellRendererComponent(javax.swing.JList, Object, * int, boolean, boolean) */ public Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { final String key = (String) value; final Icon icon = IconSource.getIcon(key); final Color back = isSelected ? list.getSelectionBackground() : list.getBackground(); setBackground(back); iconLabel.setBackground(back); iconLabel.setIcon(icon); return this; }
private static JButton getButton(JList<String> list, Point pt, int index) { Component c = list.getCellRenderer().getListCellRendererComponent(list, "", index, false, false); Rectangle r = list.getCellBounds(index, index); c.setBounds(r); // c.doLayout(); //may be needed for mone LayoutManager pt.translate(-r.x, -r.y); Component b = SwingUtilities.getDeepestComponentAt(c, pt.x, pt.y); if (b instanceof JButton) { return (JButton) b; } else { return null; } }
private void assembleAction() { String line; messages = new Vector(); mainFrame.resetExecWindow(); save(); assembleFailed = false; haveAssemblyErrors = false; if (Assembler.version()) { while ((line = Assembler.output()) != null) { messages.addElement(line); } Assembler.setPaths(baseName, sourcePath); if (Assembler.assemble()) { while ((line = Assembler.output()) != null) { System.out.println(line); messages.addElement(line); if (line.startsWith(" [ERROR:")) { haveAssemblyErrors = true; } } messageList.setListData(messages); messageList.ensureIndexIsVisible(0); mainFrame.showExecWindow(baseName); } else { assembleFailed = true; } } else { assembleFailed = true; } if (assembleFailed) { String message = String.format( "Autocoder failed!\nVerify the correctness of autocoder path\n%s", AssemblerOptions.assemblerPath); System.out.println(message); JOptionPane.showMessageDialog(this, message, "ROPE", JOptionPane.ERROR_MESSAGE); } }
private void suggestCompletion(final boolean selectReplacedText, final boolean isExplicitCall) { if (isExplicitCall) { myAutopopup = true; } if (!getField().isFocusOwner()) return; final CompletionResult result = new CompletionResult(); if (myList != null && myCurrentCompletion != null) { int index = myList.getSelectedIndex(); if (index >= 0 && index < myList.getModel().getSize()) { result.myPreselected = (LookupFile) myList.getSelectedValue(); } } myUiUpdater.queue( new Update("textField.suggestCompletion") { public void run() { final String completionBase = getCompletionBase(); if (completionBase != null) { final LookupFile file = myFinder.find(completionBase); if (file != null && !file.isDirectory()) { // we've entered a complete path already, no need to autopopup completion again // (IDEA-78996) return; } } result.myCompletionBase = completionBase; if (result.myCompletionBase == null) return; result.myFieldText = myPathTextField.getText(); ApplicationManager.getApplication() .executeOnPooledThread( new Runnable() { public void run() { processCompletion(result); SwingUtilities.invokeLater( new Runnable() { public void run() { if (!result.myCompletionBase.equals(getCompletionBase())) return; int pos = selectCompletionRemoveText(result, selectReplacedText); showCompletionPopup(result, pos, isExplicitCall); } }); } }); } }); }
private MyCheckboxTreeCellRenderer( final SelectionManager selectionManager, Map<VirtualFile, String> modulesSet, final Project project, final JTree tree, final Collection<VirtualFile> roots) { super(new BorderLayout()); mySelectionManager = selectionManager; myModulesSet = modulesSet; myRoots = roots; setBackground(tree.getBackground()); myColoredRenderer = new ColoredTreeCellRenderer() { @Override public void customizeCellRenderer( JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { append(value.toString()); } }; myFictive = new JBList(); myFictive.setBackground(tree.getBackground()); myFictive.setSelectionBackground(UIUtil.getListSelectionBackground()); myFictive.setSelectionForeground(UIUtil.getListSelectionForeground()); myTextRenderer = new WithModulesListCellRenderer(project, myModulesSet) { @Override protected void putParentPath(Object value, FilePath path, FilePath self) { if (myRoots.contains(self.getVirtualFile())) { super.putParentPath(value, path, self); } } }; myTextRenderer.setBackground(tree.getBackground()); myCheckbox = new JCheckBox(); myCheckbox.setBackground(tree.getBackground()); myEmpty = new JLabel(""); add(myCheckbox, BorderLayout.WEST); add(myTextRenderer, BorderLayout.CENTER); myCheckbox.setVisible(true); }
@Override public void mousePressed(MouseEvent e) { // JList list = (JList) e.getComponent(); Point pt = e.getPoint(); int index = list.locationToIndex(pt); if (index >= 0) { JButton button = getButton(list, pt, index); if (Objects.nonNull(button)) { ButtonsRenderer renderer = (ButtonsRenderer) list.getCellRenderer(); renderer.pressedIndex = index; renderer.button = button; listRepaint(list, list.getCellBounds(index, index)); } } }