Tabnine Logo
JList
Code IndexAdd Tabnine to your IDE (free)

How to use
JList
in
javax.swing

Best Java code snippets using javax.swing.JList (Showing top 20 results out of 5,544)

Refine searchRefine arrow

  • JScrollPane
  • DefaultListModel
  • Window
  • Container
  • JFrame
  • JButton
  • JPanel
origin: pmd/pmd

public DFAPanel() {
  super();
  setLayout(new BorderLayout());
  JPanel leftPanel = new JPanel();
  nodeList = new JList(nodes);
  nodeList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
  nodeList.setFixedCellWidth(150);
  nodeList.setBorder(BorderFactory.createLineBorder(Color.black));
  nodeList.addListSelectionListener(this);
  leftPanel.add(nodeList);
  add(leftPanel, BorderLayout.WEST);
  dfaCanvas = new DFACanvas();
  dfaCanvas.setBackground(Color.WHITE);
  dfaCanvas.setPreferredSize(new Dimension(900, 1400));
  JScrollPane scrollPane = new JScrollPane(dfaCanvas);
  add(scrollPane, BorderLayout.CENTER);
}
origin: opentripplanner/OpenTripPlanner

@Override
public void valueChanged(ListSelectionEvent ev) {
  
  PathPrinter pp = ((PathPrinter) pathsList.getSelectedValue());
  if(pp==null){
    return;
  }
  GraphPath path = pp.gp;
  
  DefaultListModel<State> pathModel = new DefaultListModel<State>();
  for( State st : path.states ){
    pathModel.addElement( st );
  }
  pathStates.setModel( pathModel );
  
  showGraph.highlightGraphPath(path);        
}
origin: stanfordnlp/CoreNLP

public void selectNextMatch() {
 int idx = Math.min(list.getModel().getSize() - 1,
           list.getSelectedIndex() + 1);
 list.setSelectedIndex(idx);
}
origin: go-lang-plugin-org/go-lang-idea-plugin

private static void scrollToSelection(JList list) {
 int selectedRow = list.getSelectedIndex();
 if (selectedRow >= 0) {
  list.scrollRectToVisible(list.getCellBounds(selectedRow, 0));
 }
}
origin: stanfordnlp/CoreNLP

public void selectPreviousMatch() {
 int idx = Math.max(0, list.getSelectedIndex() - 1);
 list.setSelectedIndex(idx);
}
origin: libgdx/libgdx

  JPanel fontPanel = new JPanel();
    JScrollPane fontScroll = new JScrollPane();
      fontList = new JList();
      fontScroll.setViewportView(fontList);
      fontList.setModel(fontListModel);
      fontList.setVisibleRowCount(6);
      fontList.setSelectedIndex(0);
      fontScroll.setMinimumSize(new Dimension(220, fontList.getPreferredScrollableViewportSize().height));
    browseButton = new JButton("...");
    browseButton.setMargin(new Insets(0, 0, 0, 0));
    sampleNeheButton = new JButton();
getContentPane().add(rightSidePanel, new GridBagConstraints(1, 0, 1, 2, 0.0, 0.0, GridBagConstraints.CENTER,
  GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
      effectsList = new JList();
      effectsScroll.setViewportView(effectsList);
      effectsList.setModel(effectsListModel);
      effectsList.setVisibleRowCount(7);
      effectsScroll.setMinimumSize(effectsList.getPreferredScrollableViewportSize());
origin: kiegroup/jbpm

private void initializeComponent() {
  JPanel panel = new JPanel();
  panel.setLayout(new GridBagLayout());
  getRootPane().setLayout(new BorderLayout());
  getRootPane().add(panel, BorderLayout.CENTER);
  workItemsList = new JList();
  workItemsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
  workItemsList.addMouseListener(new MouseAdapter() {
    public void mouseClicked(MouseEvent e) {
      if (e.getClickCount() == 2) {
  workItemsList.addListSelectionListener(new ListSelectionListener() {
    public void valueChanged(ListSelectionEvent e) {
      selectButton.setEnabled(getSelectedWorkItem() != null);
  c.fill = GridBagConstraints.BOTH;
  c.insets = new Insets(5, 5, 5, 5);
  panel.add(workItemsList, c);
  selectButton = new JButton("Select");
  selectButton.setEnabled(false);
  selectButton.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent event) {
      select();
origin: RipMeApp/ripme

JPanel ripPanel = new JPanel(new GridBagLayout());
ripPanel.setBorder(emptyBorder);
gbc.gridx = 0; ripPanel.add(new JLabel("URL:", JLabel.RIGHT), gbc);
gbc.weightx = 1;
gbc.weighty = 1;
logText = new JTextPane();
logText.setEditable(false);
JScrollPane logTextScroll = new JScrollPane(logText);
logTextScroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
JScrollPane historyTableScrollPane = new JScrollPane(historyTable);
queueListModel  = new DefaultListModel();
JList queueList = new JList(queueListModel);
queueList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
queueList.addMouseListener(new QueueMenuMouseListener());
    JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
for (String item : Utils.getConfigList("queue")) {
  queueListModel.addElement(item);
gbc.gridy = 0; pane.add(ripPanel, gbc);
gbc.gridy = 1; pane.add(statusPanel, gbc);
gbc.gridy = 2; pane.add(progressPanel, gbc);
origin: geotools/geotools

JButton cancelButton = new JButton("Cancel");
cancelButton.addActionListener(this);
final JButton setButton = new JButton("Select");
setButton.setActionCommand("Select");
setButton.addActionListener(this);
getRootPane().setDefaultButton(setButton);
model = new DefaultListModel();
list = new JList(model);
list.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
list.setLayoutOrientation(JList.VERTICAL);
list.setVisibleRowCount(-1);
list.addMouseListener(
    new MouseAdapter() {
      public void mouseClicked(MouseEvent e) {
contentPane.add(listPane, BorderLayout.CENTER);
contentPane.add(buttonPane, BorderLayout.PAGE_END);
origin: igniterealtime/Smack

private void createDebug() {
  frame = new JFrame("Smack Debug Window");
    frame.addWindowListener(new WindowAdapter() {
      @Override
      public void windowClosing(WindowEvent evt) {
  JPanel informationPanel = new JPanel();
  informationPanel.setLayout(new BoxLayout(informationPanel, BoxLayout.Y_AXIS));
  JPanel versionPanel = new JPanel();
  versionPanel.setLayout(new BoxLayout(versionPanel, BoxLayout.X_AXIS));
  versionPanel.setMaximumSize(new Dimension(2000, 31));
  JList list = new JList(providers);
  iqProvidersPanel.add(new JScrollPane(list));
  informationPanel.add(iqProvidersPanel);
  list = new JList(providers);
  extensionProvidersPanel.add(new JScrollPane(list));
  informationPanel.add(extensionProvidersPanel);
  frame.getContentPane().add(tabbedPane);
  frame.setSize(650, 400);
origin: apache/geode

Collections.sort(ids);
final FilterableListModel listModel = new FilterableListModel(ids);
final JList list = new JList(listModel);
JScrollPane selectGraphPane = new JScrollPane(list);
selectGraphPane.setPreferredSize(new Dimension(500, 500));
JButton apply = new JButton("Apply");
apply.addActionListener(new ActionListener() {
 @Override
 public void actionPerformed(ActionEvent e) {
JButton cancel = new JButton("Cancel");
cancel.addActionListener(new ActionListener() {
 @Override
JPanel buttonPane = new JPanel();
buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS));
buttonPane.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10));
buttonPane.add(Box.createHorizontalGlue());
buttonPane.add(apply);
contentPane.add(searchField, BorderLayout.PAGE_START);
contentPane.add(selectGraphPane, BorderLayout.CENTER);
contentPane.add(buttonPane, BorderLayout.PAGE_END);
origin: stackoverflow.com

DefaultListModel searchResultListModel = new DefaultListModel();
DefaultListSelectionModel searchResultSelectionModel = new DefaultListSelectionModel();
searchResultSelectionModel
Container contentPane = mainFrame.getContentPane();
JPanel searchInputPanel = new JPanel();
searchInputPanel.setLayout(new BorderLayout());
searchInputPanel.add(searchField, BorderLayout.CENTER);
searchField.addActionListener(searchPersonAction);
searchInputPanel.add(searchButton, BorderLayout.EAST);
JList searchResultList = new JList();
searchResultList.setModel(searchResultListModel);
searchResultList.setSelectionModel(searchResultSelectionModel);
JPanel searchResultPanel = new JPanel();
JPanel selectionOptionsPanel = new JPanel();
JButton showPersonDetailsButton = new JButton(personDetailsAction);
selectionOptionsPanel.add(showPersonDetailsButton);
mainFrame.setVisible(true);
origin: opentripplanner/OpenTripPlanner

private Container makeDiffTab() {
  JPanel pane = new JPanel();
  pane.setLayout(new GridLayout(0, 2));
  firstStateData = new JList<String>();
  secondStateData = new JList<String>();
  firstComparePathStates = new JList<State>();        
  JScrollPane stScrollPane = new JScrollPane(firstComparePathStates);
  stScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
  pane.add(stScrollPane);
  firstComparePathStates.addListSelectionListener(new ComparePathStatesClickListener(firstStateData));
  secondComparePathStates = new JList<State>();
  stScrollPane = new JScrollPane(secondComparePathStates);
  stScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
  pane.add(stScrollPane);
  secondComparePathStates.addListSelectionListener(new ComparePathStatesClickListener(secondStateData));
  JButton dominateButton = new JButton();
  dominateButton.setText("dominates");
  dominateButton.addActionListener(new ActionListener(){
    @Override
    public void actionPerformed(ActionEvent e) {
origin: wiztools/rest-client

public OptionsFontPanel(){
  JPanel jp = this;
  jp.setLayout(new BorderLayout());
  JPanel jp_north = new JPanel();
  jp_north.setLayout(new FlowLayout(FlowLayout.LEFT));
  JLabel jl = new JLabel("Font for Request Body & Response Body");
  jp_north.add(jl);
  jb_default.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent event) {
  jp_center.setLayout(new GridLayout(1, 2));
  String[] fontFamilyNames = GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
  jl_font = new JList<String>(fontFamilyNames);
  jl_font.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
  jl_font.addListSelectionListener(previewListner);
  JScrollPane jsp_font = new JScrollPane(jl_font);
  jsp_font.setPreferredSize(d);
  jp_center.add(jsp_font);
  String fontSizes[] = { "8", "10", "11", "12", "14", "16", "18",
    "20", "24", "30", "36", "40", "48", "60", "72" };
  jl_fontSize = new JList<String>(fontSizes);
  jl_fontSize.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
  jl_fontSize.addListSelectionListener(previewListner);
  JScrollPane jsp_fontSize = new JScrollPane(jl_fontSize);
  jsp_fontSize.setPreferredSize(d);
  jp_center.add(jsp_fontSize);
origin: jersey/jersey

javax.swing.JPanel jPanel3 = new javax.swing.JPanel();
newKeywordField = new javax.swing.JTextField();
addButton = new javax.swing.JButton();
javax.swing.JPanel jPanel1 = new javax.swing.JPanel();
connectionStatusLabel = new javax.swing.JLabel();
startStopButton = new javax.swing.JButton();
javax.swing.JScrollPane jScrollPane2 = new javax.swing.JScrollPane();
messagesArea = new javax.swing.JTextArea();
javax.swing.JPanel jPanel2 = new javax.swing.JPanel();
javax.swing.JScrollPane jScrollPane1 = new javax.swing.JScrollPane();
keywordList = new javax.swing.JList();
jPanel4 = new javax.swing.JPanel();
twitterCheckbox = new javax.swing.JCheckBox();
addButton.setText("Add");
addButton.addActionListener(new java.awt.event.ActionListener() {
  public void actionPerformed(java.awt.event.ActionEvent evt) {
messagesArea.setWrapStyleWord(true);
messagesArea.setFocusable(false);
jScrollPane2.setViewportView(messagesArea);
jPanel2.setBorder(javax.swing.BorderFactory.createEtchedBorder());
keywordList.setModel(keywordListModel);
jScrollPane1.setViewportView(keywordList);
origin: opentripplanner/OpenTripPlanner

private void initRightPanel(Container pane) {
  rightPanel.add(rightPanelTabs, BorderLayout.LINE_END);
  pathStates = new JList<State>();
  JScrollPane stScrollPane = new JScrollPane(pathStates);
  stScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
  rightPanelTabs.addTab("path states", stScrollPane);
  pathStates.addListSelectionListener(new ListSelectionListener(){
    @Override
    public void valueChanged(ListSelectionEvent e) {
  metadataList = new JList<String>();
  metadataModel = new DefaultListModel<String>();
  metadataList.setModel(metadataModel);
  JScrollPane mdScrollPane = new JScrollPane(metadataList);
  mdScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
  rightPanelTabs.addTab("metadata", mdScrollPane);
  annotationMatches = new JList<GraphBuilderAnnotation>();
  annotationMatches.addListSelectionListener(new ListSelectionListener() {
    public void valueChanged(ListSelectionEvent e) {
      @SuppressWarnings("unchecked")
  annotationMatchesModel = new DefaultListModel<GraphBuilderAnnotation>();
  annotationMatches.setModel(annotationMatchesModel);
  JScrollPane amScrollPane = new JScrollPane(annotationMatches);
  amScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
origin: org.protege/protege-editor-core-application

  public static void main(String[] args) {
    DefaultListModel m = new DefaultListModel();
    for (int i = 0; i < 5000; i++) {
      m.addElement("X" + i);
    }

    CheckList list = new CheckList(new JList(m));

    JFrame f = new JFrame();
    f.getContentPane().setLayout(new BorderLayout());
    f.getContentPane().add(new JScrollPane(list));
    f.setVisible(true);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  }
}
origin: libgdx/libgdx

JPanel contentPanel = getContentPanel();
  JPanel buttonsPanel = new JPanel(new GridLayout(3, 1));
  contentPanel.add(buttonsPanel, new GridBagConstraints(0, 0, 1, 1, 1, 0, GridBagConstraints.NORTHWEST,
    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
  JButton addButton = new JButton("Add");
  buttonsPanel.add(addButton);
  addButton.addActionListener(new ActionListener() {
    public void actionPerformed (ActionEvent event) {
      FileDialog dialog = new FileDialog(editor, "Open Image", FileDialog.LOAD);
  JButton defaultButton = new JButton("Default");
  buttonsPanel.add(defaultButton);
  defaultButton.addActionListener(new ActionListener() {
  contentPanel.add(imagesPanel, new GridBagConstraints(2, 0, 1, 1, 1, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
    new Insets(0, 0, 0, 0), 0, 0));
  imageListModel = new DefaultListModel<String>();
  imageList = new JList<String>(imageListModel);
  imageList.setFixedCellWidth(250);
  imageList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
  imagesPanel.add(imageList, new GridBagConstraints(0, 0, 1, 3, 0, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
    new Insets(0, 0, 0, 0), 0, 0));
origin: stackoverflow.com

 JList<Thumbnail> list = new JList<>(m);
 list.getSelectionModel().setSelectionMode(
  ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
 list.setTransferHandler(new ListItemTransferHandler());
 list.setDropMode(DropMode.INSERT);
 list.setDragEnabled(true);
 list.setLayoutOrientation(JList.HORIZONTAL_WRAP);
 list.setVisibleRowCount(0);
 list.setFixedCellWidth(80);
 list.setFixedCellHeight(80);
 list.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
 list.setCellRenderer(new ListCellRenderer<Thumbnail>() {
  private final JPanel p = new JPanel(new BorderLayout());
  private final JLabel icon = new JLabel((Icon)null, JLabel.CENTER);
  private final JLabel label = new JLabel("", JLabel.CENTER);
   icon.setIcon(value.icon);
   label.setText(value.name);
   label.setForeground(isSelected? list.getSelectionForeground()
                  : list.getForeground());
   p.add(icon);
   p.add(label, BorderLayout.SOUTH);
   p.setBackground(isSelected? list.getSelectionBackground()
                : list.getBackground());
   return p;
@Override protected Transferable createTransferable(JComponent c) {
origin: plantuml/plantuml

scrollPane = new JScrollPane(jList1);
scrollPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
final JPanel south = new JPanel(new BorderLayout());
final JLabel labelFileExtensions = new JLabel("File extensions: ");
extensions.setText(getExtensions());
    BorderFactory.createEtchedBorder());
border = BorderFactory.createCompoundBorder(border, BorderFactory.createEmptyBorder(5, 5, 5, 5));
south.setBorder(border);
south.add(labelFileExtensions, BorderLayout.WEST);
south.add(extensions, BorderLayout.CENTER);
south.add(changeDirButton, BorderLayout.SOUTH);
getContentPane().add(south, BorderLayout.SOUTH);
getContentPane().add(scrollPane, BorderLayout.CENTER);
jList1.addMouseListener(mouseListener);
changeDirButton.addActionListener(new ActionListener() {
  public void actionPerformed(ActionEvent e) {
    System.err.println("Opening Directory Window");
jList1.addKeyListener(new KeyAdapter() {
  @Override
  public void keyPressed(KeyEvent e) {
javax.swingJList

Most used methods

  • <init>
  • getSelectedValue
  • addListSelectionListener
  • setSelectionMode
  • getSelectedIndex
  • getModel
  • setSelectedIndex
  • setModel
  • setCellRenderer
  • addMouseListener
  • getBackground
  • getSelectionBackground
  • getBackground,
  • getSelectionBackground,
  • getSelectionForeground,
  • getForeground,
  • setVisibleRowCount,
  • getSelectedIndices,
  • clearSelection,
  • getSelectionModel,
  • setListData,
  • setSelectedValue

Popular in Java

  • Making http post requests using okhttp
  • onRequestPermissionsResult (Fragment)
  • setRequestProperty (URLConnection)
  • findViewById (Activity)
  • BorderLayout (java.awt)
    A border layout lays out a container, arranging and resizing its components to fit in five regions:
  • UUID (java.util)
    UUID is an immutable representation of a 128-bit universally unique identifier (UUID). There are mul
  • Stream (java.util.stream)
    A sequence of elements supporting sequential and parallel aggregate operations. The following exampl
  • ServletException (javax.servlet)
    Defines a general exception a servlet can throw when it encounters difficulty.
  • Options (org.apache.commons.cli)
    Main entry-point into the library. Options represents a collection of Option objects, which describ
  • Scheduler (org.quartz)
    This is the main interface of a Quartz Scheduler. A Scheduler maintains a registry of org.quartz.Job
  • Github Copilot alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now