List of usage examples for javax.swing JList setSelectionMode
@BeanProperty(bound = false, enumerationValues = { "ListSelectionModel.SINGLE_SELECTION", "ListSelectionModel.SINGLE_INTERVAL_SELECTION", "ListSelectionModel.MULTIPLE_INTERVAL_SELECTION" }, description = "The selection mode.") public void setSelectionMode(int selectionMode)
From source file:org.executequery.gui.browser.FindAction.java
private JList initSearchResultsList() { final JList list = new JList(); list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); ListCellRenderer listCellRenderer = getListCellRenderer(); if (listCellRenderer != null) { list.setCellRenderer(listCellRenderer); }//from ww w. ja va2 s .c om list.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.getClickCount() >= 2) { listValueSelected((T) list.getSelectedValue()); } } }); list.addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent e) { int keyCode = e.getKeyCode(); if (keyCode == KeyEvent.VK_ENTER) { listValueSelected((T) list.getSelectedValue()); } else if (keyCode == KeyEvent.VK_BACK_SPACE) { searchField.requestFocus(); } } }); return list; }
From source file:org.geworkbench.components.lincs.LincsInterface.java
private JScrollPane buildJListPanel(List<String> dataList, JList aJlist) { aJlist.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); aJlist.setSelectionModel(new LincsListSelectionModel()); aJlist.setModel(new LincsListModel(dataList)); JScrollPane jScrollPane1 = new javax.swing.JScrollPane(aJlist, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); jScrollPane1.setPreferredSize(new java.awt.Dimension(200, 70)); return jScrollPane1; }
From source file:org.nebulaframework.ui.swing.node.NodeMainUI.java
/** * Setup Job History Tab Pane//from w w w . ja va2 s . co m * * @return JPanel for History tab */ private JPanel setupHistory() { JPanel historyPanel = new JPanel(); historyPanel.setLayout(new BorderLayout(10, 10)); /* -- Job List -- */ JPanel jobListPanel = new JPanel(); historyPanel.add(jobListPanel, BorderLayout.CENTER); jobListPanel.setLayout(new BorderLayout(10, 10)); jobListPanel.setBorder(BorderFactory.createTitledBorder("Grid Jobs")); final JList jobList = new JList(historyList); JScrollPane jobListScroll = new JScrollPane(jobList); jobListPanel.add(jobListScroll, BorderLayout.CENTER); jobListScroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); jobListScroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); addUIElement("history.joblist", jobList); jobList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); jobList.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { // Ignore intermediate events if (e.getValueIsAdjusting()) return; displayJobInfo(jobList.getSelectedValue()); } }); JPanel jobInfoPanel = new JPanel(); historyPanel.add(jobInfoPanel, BorderLayout.SOUTH); jobInfoPanel.setLayout(new BorderLayout(10, 10)); jobInfoPanel.setBorder(BorderFactory.createTitledBorder("Job Information")); JPanel centerPanel = new JPanel(); jobInfoPanel.add(centerPanel, BorderLayout.CENTER); centerPanel.setLayout(new GridLayout(0, 4, 10, 10)); JLabel jobIdLabel = new JLabel("GridJob ID :"); centerPanel.add(jobIdLabel); JLabel jobId = new JLabel("N/A"); centerPanel.add(jobId); addUIElement("history.jobid", jobId); // Add to components map JLabel jobNameLabel = new JLabel("GridJob Name :"); centerPanel.add(jobNameLabel); JLabel jobName = new JLabel("N/A"); centerPanel.add(jobName); addUIElement("history.jobname", jobName); // Add to components map JLabel startTimeLabel = new JLabel("Start Time :"); centerPanel.add(startTimeLabel); JLabel startTime = new JLabel("N/A"); centerPanel.add(startTime); addUIElement("history.starttime", startTime); // Add to components map JLabel durationLabel = new JLabel("Duration :"); centerPanel.add(durationLabel); JLabel duration = new JLabel("N/A"); centerPanel.add(duration); addUIElement("history.duration", duration); // Add to components map JLabel tasksLabel = new JLabel("Tasks Executed :"); centerPanel.add(tasksLabel); JLabel tasks = new JLabel("N/A"); centerPanel.add(tasks); addUIElement("history.tasks", tasks); // Add to components map JLabel failuresLabel = new JLabel("Failures :"); centerPanel.add(failuresLabel); JLabel failures = new JLabel("N/A"); centerPanel.add(failures); addUIElement("history.failures", failures); // Add to components map // Place Holders centerPanel.add(new JLabel()); centerPanel.add(new JLabel()); return historyPanel; }