Columns in a JList

Hi
I have a JList and I want to display 3 values per line. How do I add column so everything looks nice and neat. Something like a listview.
eg.
3 aName aSurname
4 another yetanother
15 another surnames
What do I need to do to accomplish this or am I using the wrong class?
Or lets ask the question is there a grid control in Java?
Hope this was explained clearly enough.
Let me know if you need some more info.

Or....
Create your own ListCellRenderer....
These are simply subbed lightweight JLabels used to render the values... therefore you can do:
myRenderer.setLayoutManager(new java.awt.GridLayout(1, 3));
myRenderer.add(someLabel);
myRenderer.add(someLabel1);
myRenderer.add(someLabel2);Obviously in the renderer code you will have to perform some fancy checking in order to fill the three labels with the data required - but then that's just part of the fun.... :)

Similar Messages

  • Multiple columns in a JList ??

    Hi,
    is it possible to have a JList with more than one column ??
    If yes, how to do that ?? It's easy for one column but with more...
    Thanks in advance
    Steve

    I'm using JTables only with Select bean, si it's very easy.
    Can you explain me how to add, modify and remove rows of a JTable which hasn't model.
    Thanks
    Steve

  • How to do a JList with Columns???

    Hi... I'm trying to do a Zip compressor in Java... I don't know how, but i want to do it...
    But this is not my problem.... yet...
    I want to put the selected files (files to Zip) in a JList Object... but I want to show the FileName, the Size, the Date and the FilePath...
    For this I need to create Columns in my JList, but I don't know how I can do it...
    Please help me... or sugest some similar...
    Regards... and Sorry my English...

    [url http://java.sun.com/docs/books/tutorial/uiswing/components/table.html]How to Use Tables

  • Multiple Column in JLIst

    Hi friend,
    Please could u tell me how can i make a multiple Column in a JList without using JTable. It would be better if u send me a complete code for that.
    Thanks u very much in Advance.
    Khaled Mahmud

    First of all I would like to thank u for reply.
    I have searched through the Forums but I could not get any solution.
    Actually, I have a code for Multi Column JList but that was made up using JTable.
    But I want a Multi Column JList which is made up without using JTable.

  • Multiple related columns in JList

    Is it possible to have multiple columns in a JList?
    My problem is that I have a class called Volunteer who have a name, surname and id number.
    I would like these to be displayed in a JList like:
    name surname id
    name surname id
    and so on...
    I have currently managed to get the volunteers names displayed in a scrolling list, but can't seem to find how to add the surname and id fields to them.
    Is there anyone who knows (or has any idea) of how to do this? - Please help!!

    Hi,
    that can be done several way:
    1. create a cellrenderer for the JList which renders a string like "name,surname,id" to 3 labels with name, surname and id in it so, that the columns are placed correctly one above or below the other.
    2. use that JComponent, that is designed for that purpose - a JTable - instead
    greetings Marsian

  • How to make only one column non reorderble

    I want to make only one column (Column 0) of my JTable non reorderble.
    I also want to make the same column non resizable and I want to give it a specific size.
    Please help me on this?

    I have implemented a RowHeaderTable class which displays 1, 2, 3, ... in the first column. The column is in the scrollpane's RowHeaderView, so it is not resizable nor reorderable. But its width can be set in your code. Maybe this is what you need.
    Use the class the same way you use a JTable, except 3 added methods:
    getScrollPane();
    setMinRows(int r);
    setRowHeaderWidth(int w);
    Note: The table works perfectly in skinless L&F, such as the default java L&F. It looks ugly in Liquid L&F because I don't know how to steal column header's UI to use on a JList. If someone can help me on this one, I thank you in advance.
    * RowHeaderTable.java
    * Created on 2005-3-21
    * Copyright (c) 2005 Jing Ding, All Rights Reserved.
    * Permission to use, copy, modify, and distribute this software
    * and its documentation for NON-COMMERCIAL purposes and without
    * fee is hereby granted provided that this copyright notice
    * appears in all copies.
    * JING DING MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE
    * SUITABILITY OF THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING
    * BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY,
    * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. JING DING
    * SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT
    * OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
    import java.awt.BorderLayout;
    import java.awt.Component;
    import javax.swing.AbstractListModel;
    import javax.swing.JFrame;
    import javax.swing.JList;
    import javax.swing.JScrollPane;
    import javax.swing.JTable;
    import javax.swing.ListCellRenderer;
    import javax.swing.UIManager;
    import javax.swing.event.TableModelEvent;
    import javax.swing.event.TableModelListener;
    import javax.swing.table.DefaultTableModel;
    import javax.swing.table.JTableHeader;
    import javax.swing.table.TableCellRenderer;
    import javax.swing.table.TableColumn;
    import javax.swing.table.TableModel;
    * @author Jing Ding
    public class RowHeaderTable extends JTable {
      private int minRows = 10;                         // Minimum size of the row header.
      private static final int DEFAULT_WIDTH = 30;
      private JScrollPane jsp;
      // The row header is a JList with the same appearance as the column header.
      private JList rowHeader;
      // Repaint row header whenever the table inserts or deletes rows.
      private TableModelListener tmListener = new TableModelListener(){
        public void tableChanged(TableModelEvent e){
          if(e.getType() != TableModelEvent.UPDATE)
            rowHeader.repaint();
      /** Create a new instance of RowHeaderTable.
       * @param model
      public RowHeaderTable(TableModel model){
        setModel(model);
        initializeHeader();
        jsp = new JScrollPane(this);
        jsp.setRowHeaderView(rowHeader);
      private void initializeHeader(){
        rowHeader = new JList(new AbstractListModel(){
          public int getSize(){ return Math.max(getModel().getRowCount(), minRows); }
          public Object getElementAt(int index){ return "" + ++index; }
        setRowHeaderWidth(DEFAULT_WIDTH);
        rowHeader.setFixedCellHeight(getRowHeight());
        rowHeader.setCellRenderer(new TableRowHeaderRenderer());
      public void setRowHeaderWidth(int w){
        rowHeader.setFixedCellWidth(w);
      public void setMinRows(int m){ minRows = m; }
      public void setModel(TableModel model){
        super.setModel(model);
        model.addTableModelListener(tmListener);
      /**Use this method to get the scrollPane, instead of new JScrollPane(table).
       * @return
      public JScrollPane getScrollPane(){ return jsp; }
      protected class TableRowHeaderRenderer implements ListCellRenderer{
        TableCellRenderer colHeaderRenderer;
        public TableRowHeaderRenderer(){
          JTableHeader header = getTableHeader();
          TableColumn aColumn = header.getColumnModel().getColumn(0);
          colHeaderRenderer = aColumn.getHeaderRenderer();
          if(colHeaderRenderer == null)
            colHeaderRenderer = header.getDefaultRenderer();
        public Component getListCellRendererComponent(JList list, Object value,
            int index, boolean isSelected, boolean hasFocus){
          return colHeaderRenderer.getTableCellRendererComponent(
              RowHeaderTable.this, value, isSelected, hasFocus, -1, -1);
      public static void main(String[] args){
        try {
          UIManager.setLookAndFeel("com.birosoft.liquid.LiquidLookAndFeel");
        }catch (Exception e){ e.printStackTrace(); }
        String[] columnNames = {"First Name",
            "Last Name",
            "Sport",
            "# of Years",
            "Vegetarian"};
              Object[][] data = {
                   {"Mary", "Campione", "Snowboarding", new Integer(5), new Boolean(false)},
                   {"Alison", "Huml", "Rowing", new Integer(3), new Boolean(true)},
                   {"Kathy", "Walrath", "Knitting", new Integer(2), new Boolean(false)},
                   {"Sharon", "Zakhour", "Speed reading", new Integer(20), new Boolean(true)},
                   {"Philip", "Milne", "Pool", new Integer(10), new Boolean(false)}
        DefaultTableModel dtm = new DefaultTableModel(data, columnNames);
        RowHeaderTable rht = new RowHeaderTable(dtm);
        rht.setMinRows(0);
        JFrame frame = new JFrame("RowHeaderTable Demo");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.getContentPane().add(rht.getScrollPane(), BorderLayout.CENTER);
        frame.pack();
        frame.setVisible(true);
        dtm.addRow(new Object[]{"Mary", "Campione", "Snowboarding", new Integer(5), new Boolean(false)});
        dtm.addRow(new Object[]{"Mary", "Campione", "Snowboarding", new Integer(5), new Boolean(false)});
        dtm.addRow(new Object[]{"Mary", "Campione", "Snowboarding", new Integer(5), new Boolean(false)});
    }

  • JList with more Columns?

    Hi!
    Can a jlist have more than one "column"? Or is the only possibillity to make something similar like in the windows explorer a table?
    thanks
    qedi

    Hi!
    Yes you are right, a table is sounder.
    I have the problem, that i like to fill the table dynamic and therefor I created two vectors, one with my data an one for the columnnames. According to the documentation i used following statement to create the table:
    Vector data = new Vector();
    data.addElement(..);
    Vector columns = new Vector();
    columns.addElement(...);
    JTable myTable = new JTable(data, columns);
    But I get an Exception. I don't know which one.
    Made I something wrong??
    qedi

  • Populating JList with a single database column

    Hi all,
    I have the following code and i'm trying to popluate the JList with a particular colum from my MySQL Database..
    how do i go about doing it??
    Can some one please help
    import java.awt.*; import java.awt.event.*; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import javax.swing.*; public class RemoveD extends JDialog {     private JList list;     private JButton removeButton;     private JScrollPane scrollPane;     private Connection conn = null;     private Statement stat = null;         public RemoveD(Frame parent, boolean modal) {         super(parent, modal);         initComponents();     }     private void initComponents() {         scrollPane = new JScrollPane();         list = new JList();         removeButton = new JButton();         setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);         getContentPane().setLayout(new GridLayout(2, 0));         scrollPane.setViewportView(list);         getContentPane().add(scrollPane);         removeButton.setText("Remove");         removeButton.addActionListener(new ActionListener() {             public void actionPerformed(ActionEvent evt) {                 removeButtonActionPerformed(evt);             }         });         getContentPane().add(removeButton);         pack();         try {             Class.forName("com.mysql.jdbc.Driver");                    } catch (ClassNotFoundException ex) {             ex.printStackTrace();                    }         try {             String userID = "";             String psw = "";             String url;             url = "jdbc:mysql://localhost:3306/names";             conn = DriverManager.getConnection(url, userID, psw);             stat = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,                     ResultSet.CONCUR_READ_ONLY);             stat.close();             conn.close();         } catch (SQLException ex) {             ex.printStackTrace();         }     }     private void removeButtonActionPerformed(ActionEvent evt) {     }     public static void main(String args[]) {         EventQueue.invokeLater(new Runnable() {             public void run() {                 RemoveD dialog = new RemoveD(new JFrame(), true);                 dialog.addWindowListener(new WindowAdapter() {                     public void windowClosing(WindowEvent e) {                         System.exit(0);                     }                 });                 dialog.setVisible(true);             }         });     } }

    I figured out how to do it

  • How to display mulitple columns in JList

    Hi,
    I am able to display items in the JList. However, the list is
    scrolling down to the bottom. I would like the items to be
    listed horizontally than vertically. Could someone give me
    some insight?
    Thanks,
    Pin

    The items are just the name. I would like to display
    in the following format in the list
    NameA NameF Name...
    NameB NameG ...
    NameC NameH
    NameD NameI
    NameE NameJ
    instead of
    NameA
    NameB
    NameC
    I think there is something need to be done in the
    JScrollPane. Any info???
    Thanks,
    Pin

  • Is it possible for a JList to have multiple columns..

    And also at the same time have its header also.
    Thanks in advance.

    Try this
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    import java.text.*;
    public class SOSTester extends JFrame {
         public SOSTester() {
              JFrame thisFrame = new JFrame("Testing");
              Container thisCont = thisFrame.getContentPane();
              thisCont.setLayout(new BorderLayout(5,5));
              //// Start Testing
              String[] testList1 = new String[]{"AB","CD","EF"};
              JComboBox jcb = new JComboBox(testList1);
              jcb.setRenderer(new myRen());
              thisCont.add(jcb);
              //// End Testing
              thisFrame.pack();
              thisFrame.setBounds(200,200,400,50);
              thisFrame.setVisible(true);          
         public static void main(String args[]) { new SOSTester();}
    class myRen extends JPanel implements ListCellRenderer
         JPanel testPanel = null;
         //JPanel thisPanel = null;
         JLabel text1 = null;
         JLabel text2 = null;
         myRen()
              text1 = new JLabel("",10);
              text2 = new JLabel("",10);
              testPanel = new JPanel();
              testPanel.setLayout(new GridLayout(1,2));
              //testPanel.setLayout(null);
              testPanel.add(text1);
              testPanel.add(text2);
              //thisPanel = new JPanel(new BorderLayout(0,0));
              //thisPanel.add(testPanel, BorderLayout.CENTER);
         public Component getListCellRendererComponent(JList list, Object value, int idx, boolean isSel, boolean hasFocus)
              if (value!=null)
                   text1.setText(((String)value).substring(0,1));
                   text2.setText(((String)value).substring(1,2));
                   //text1.setBounds(5,0,20,25);
                   //text2.setBounds(25,0,20,25);
              testPanel.setBackground((isSel)?list.getSelectionBackground():list.getBackground());
              testPanel.setForeground((isSel)?list.getSelectionForeground():list.getForeground());
              //testPanel.setSize(30,30);
              return testPanel;
    }

  • Multi Column JList

    What i am trying to do is mimick the windows explorer detailed view list. I have a JList with each object in the list having 2 properties. I want to display the objects along with the properties beside it in the list without having to use a JTable. Any information on how to acheive this will be very appreciated.

    JList list = new JList(new String[] {"1", "2", "3", "4", "5", "6"});
    list.setLayoutOrientation(JList.VERTICAL_WRAP);
    list.setVisibleRowCount(3);Produces:
    1 4
    2 5
    3 6

  • Button Event Handler in a JList, Please help.

    Hi everyone,
    I have created a small Java application which has a JList. The JList uses a custom cell renderer I named SmartCellRenderer. The SmartCellRenderer extends JPanel and implements the ListCellRenderer. I have added two buttons on the right side inside the JPanel of the SmartCellRenderer, since I want to buttons for each list item, and I have added mouse/action listeners for both buttons. However, they don't respond. It seems that the JList property overcomes the buttons underneath it. So the buttons never really get clicked because before that happens the JList item is being selected beforehand. I've tried everything. I've put listeners in the Main class, called Editor, which has the JList and also have listeners in the SmartCellRenderer itself and none of them get invoked.
    I also tried a manual solution. Every time the event handler for the JList was invoked (this is the handler for the JList itself and not the buttons), I sent the mouse event object to the SmartCellRenderer to manually check if the point the click happened was on one of the buttons in order to handle it.
    I used:
    // Inside SmartCellRenderer.java
    // e is the mouse event object being passed from the Editor whenever
    // a JList item is selected or clicked on
    Component comp = this.getComponent (e.getX(), e.getY())
    if(!(comp instanceof JButton)) {
              System.out.println("Recoqnized Event, but not a button click...");
              //return;
    } else {
              System.out.println("Recognized Event, IT IS A MOUSE CLICK, PROCESSING...");
              System.out.println("VALUE: "+comp.toString());
    What I realized is that not only this still doesn't work (it never realizes the component as a JButton) it also throws an exception for the last line saying comp is null. Meaning with the passed x,y position the getComponent() returns a null which happens when the coordinates passed to it are outside the range of the Panel. Which is a whole other problem?
    I have yet to find an example on the web, using Google, that demonstrated using buttons inside a JList.
    Can anyone help me with this. Thanks.

    A renderer is not a component, so you can't click on it. A renderer is just used to paint a representation of a component at a certain position in your JList.
    I have yet to find an example on the web, using Google, that demonstrated using buttons inside a JList.Thats probably because this is not a common design. The following two designs are more common:
    a) Create a separate panel for your JButtons. Then when you click on the button it would act on each selected row in the JList
    b) Or maybe like windows explorer. Select the items in the list and then use a JPopupMenu to perform the desired functionality.
    I've never tried to add a clickable button to a panel, but this [url http://forum.java.sun.com/thread.jspa?threadID=573721]posting shows one way to add a clickable JButton as a column in a JTable. You might be able to use some of the concepts to add 2 button to the JPanel or maybe you could use a JTable with 3 columns, one for your data and the last two for your buttons.

  • How to specify the font in a JList?

    My application has four columns of data represented in a JList. The default font style does proportional spacing.
    I need to specify a fixed width font to control column alignment in the JList. Unless there's something like tab positions? If I can specify a fixed width font, I can format the display strings appropriately.
    I think I need to use a cell renderer to control the actual drawing of each cell in the JList?
    Also, where do I find a list of the font types?
    Thanks in advance!

    I don't think you need a cell renderer. You find out how to specify font names by (oddly enough) looking in the API documentation for the Font class; the info for the most usable-looking constructor tells you what you want to know.

  • How to set a Excel-like column-Filtering in the Table Header using swings

    I am currently working on the Database applications.Where i need to do column filter in the header field of the jTable, (i.e i need to keep a button in the Column header and when i click the button, it should pop-up a jList which has a unique values of the entire column. when i select that value it will show corresponding rows in the jTable). Can anyone pls help me....
    Thanks
    Karthik

    You can [get the table column header|http://java.sun.com/javase/6/docs/api/javax/swing/JTable.html#getTableHeader()] and add a mouse listener to it which waits for a popup menu trigger to display a popup menu.
    In that popup menu, you can display a list which contains the unique values of the column which was clicked on. Once a value is
    selected, you can filter the rows using that value.

  • JTable can't display column names and scroll bar in JDialog !!

    Dear All ,
    My flow of program is JFrame call JDialog.
    dialogCopy = new dialogCopyBay(frame, "Bay Name Define", true, Integer.parseInt(txtSourceBay.getText()) ,proVsl ,300 ,300);
    dialogCopy.setBounds(0, 0, 300, 300);
    dialogCopy.setVisible(true);        Then,I set the datasource of JTable is from a TableModel.
    It's wild that JTable can diplay the data without column names and scroll bar.
    I have no idea what's going wrong.Cause I follow the Sun Tutorial to code.
    Here with the code of my JDialog.
    Thanks & Best Regards
    package com.whl.panel;
    import com.whl.vslEditor.vslDefine;
    import java.awt.Container;
    import java.awt.Dimension;
    import java.awt.Frame;
    import javax.swing.JDialog;
    import javax.swing.JScrollPane;
    import javax.swing.JTable;
    import javax.swing.table.AbstractTableModel;
    public class dialogCopyBay extends JDialog {
        vslDefine glbVslDefine;
        int lvCnt = -1;
        JTable tableCopyBay;
        int bgnX = 0;
        int bgnY = 30;
        int tableWidth = 100;
        int tableHeight = 100;
        public dialogCopyBay(Frame frame, String title, boolean modal, int sourceBay,
                vslDefine pVslDefine, int ttlWidth, int ttlHeight) {
            super(frame, title, true);
            Container contentPane = getContentPane();
            System.out.println("dialogCopyBay Constructor");
            glbVslDefine = null;
            glbVslDefine = pVslDefine;
            copyBayModel copyBay = new copyBayModel((glbVslDefine.getVslBayStructure().length - 1),sourceBay);
            tableCopyBay = new JTable(copyBay);
            tableCopyBay.setPreferredScrollableViewportSize(new Dimension(tableWidth, tableHeight));
            JScrollPane scrollPane = new JScrollPane(tableCopyBay);
            scrollPane.setViewportView(tableCopyBay) ;
            tableCopyBay.setFillsViewportHeight(true);
            tableCopyBay.setBounds(bgnX, bgnY, tableWidth, tableHeight);
            tableCopyBay.setBounds(10, 10, 100, 200) ;
            contentPane.setLayout(null);
            contentPane.add(scrollPane);
            contentPane.add(tableCopyBay);
        class copyBayModel extends AbstractTableModel {
            String[] columnNames;
            Object[][] dataTarget;
            public copyBayModel(int rowNum ,int pSourceBay) {
                columnNames = new String[]{"Choose", "Bay Name"};
                dataTarget = new Object[rowNum][2];
                for (int i = 0; i <= glbVslDefine.getVslBayStructure().length - 1; i++) {
                    if (pSourceBay != glbVslDefine.getVslBayStructure().getBayName() &&
    glbVslDefine.getVslBayStructure()[i].getIsSuperStructure() == 'N') {
    lvCnt = lvCnt + 1;
    dataTarget[lvCnt][0] = false;
    dataTarget[lvCnt][1] = glbVslDefine.getVslBayStructure()[i].getBayName();
    System.out.println("lvCnt=" + lvCnt + ",BayName=" + glbVslDefine.getVslBayStructure()[i].getBayName());
    public int getRowCount() {
    return dataTarget.length;
    public int getColumnCount() {
    return columnNames.length;
    public String getColumnName(int col) {
    return columnNames[col];
    public Object getValueAt(int rowIndex, int columnIndex) {
    return dataTarget[rowIndex][columnIndex];
    public Class getColumnClass(int c) {
    return getValueAt(0, c).getClass();
    public boolean isCellEditable(int row, int col) {
    if (col == 1) {
    // Bay Name Not Allow To modify
    return false;
    } else {
    return true;
    public void setValueAt(Object value, int row, int col) {
    dataTarget[row][col] = value;
    fireTableCellUpdated(row, col);

    Dear DB ,
    I am not sure what you mean.
    Currently,I don't undestand which code is error.
    And I also saw some example is add JTable and JScrollPane in JDialog.
    Like Below examle in Sun tutorial
    public class ListDialog extends JDialog implements MouseListener, MouseMotionListener{
        private static ListDialog dialog;
        private static String value = "";
        private JList list;
        public static void initialize(Component comp,
                String[] possibleValues,
                String title,
                String labelText) {
            Frame frame = JOptionPane.getFrameForComponent(comp);
            dialog = new ListDialog(frame, possibleValues,
                    title, labelText);
         * Show the initialized dialog. The first argument should
         * be null if you want the dialog to come up in the center
         * of the screen. Otherwise, the argument should be the
         * component on top of which the dialog should appear.
        public static String showDialog(Component comp, String initialValue) {
            if (dialog != null) {
                dialog.setValue(initialValue);
                dialog.setLocationRelativeTo(comp);
                dialog.setVisible(true);
            } else {
                System.err.println("ListDialog requires you to call initialize " + "before calling showDialog.");
            return value;
        private void setValue(String newValue) {
            value = newValue;
            list.setSelectedValue(value, true);
        private ListDialog(Frame frame, Object[] data, String title,
                String labelText) {
            super(frame, title, true);
    //buttons
            JButton cancelButton = new JButton("Cancel");
            final JButton setButton = new JButton("Set");
            cancelButton.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    ListDialog.dialog.setVisible(false);
            setButton.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    ListDialog.value = (String) (list.getSelectedValue());
                    ListDialog.dialog.setVisible(false);
            getRootPane().setDefaultButton(setButton);
    //main part of the dialog
            list = new JList(data);
            list.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
            list.addMouseListener(new MouseAdapter() {
                public void mouseClicked(MouseEvent e) {
                    if (e.getClickCount() == 2) {
                        setButton.doClick();
            JScrollPane listScroller = new JScrollPane(list);
            listScroller.setPreferredSize(new Dimension(250, 80));
    //XXX: Must do the following, too, or else the scroller thinks
    //XXX: it's taller than it is:
            listScroller.setMinimumSize(new Dimension(250, 80));
            listScroller.setAlignmentX(LEFT_ALIGNMENT);
    //Create a container so that we can add a title around
    //the scroll pane. Can't add a title directly to the
    //scroll pane because its background would be white.
    //Lay out the label and scroll pane from top to button.
            JPanel listPane = new JPanel();
            listPane.setLayout(new BoxLayout(listPane, BoxLayout.Y_AXIS));
            JLabel label = new JLabel(labelText);
            label.setLabelFor(list);
            listPane.add(label);
            listPane.add(Box.createRigidArea(new Dimension(0, 5)));
            listPane.add(listScroller);
            listPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    //Lay out the buttons from left to right.
            JPanel buttonPane = new JPanel();
            buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.X_AXIS));
            buttonPane.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10));
            buttonPane.add(Box.createHorizontalGlue());
            buttonPane.add(cancelButton);
            buttonPane.add(Box.createRigidArea(new Dimension(10, 0)));
            buttonPane.add(setButton);
    //Put everything together, using the content pane's BorderLayout.
            Container contentPane = getContentPane();
            contentPane.add(listPane, BorderLayout.CENTER);
            contentPane.add(buttonPane, BorderLayout.SOUTH);
            pack();
        public void mouseClicked(MouseEvent e) {
            System.out.println("Mouse Click");
        public void mousePressed(MouseEvent e) {
            throw new UnsupportedOperationException("Not supported yet.");
        public void mouseReleased(MouseEvent e) {
            throw new UnsupportedOperationException("Not supported yet.");
        public void mouseEntered(MouseEvent e) {
            throw new UnsupportedOperationException("Not supported yet.");
        public void mouseExited(MouseEvent e) {
            throw new UnsupportedOperationException("Not supported yet.");
        public void mouseDragged(MouseEvent e) {
            throw new UnsupportedOperationException("Not supported yet.");
        public void mouseMoved(MouseEvent e) {
            throw new UnsupportedOperationException("Not supported yet.");
         * This is here so that you can view ListDialog even if you
         * haven't written the code to include it in a program.
    }

Maybe you are looking for

  • FiOS TV cutting out to snow, resetting TV and set-top box?

    Greetings all, I'm hoping someone can help here; I have a Motorola HD DVR 72161 (Verizon supplied) connected via HDMI to my Sharp Aquos LC-46D65U. Over the last few weeks, something odd is happening: after watching TV for a while, my picture will cha

  • A paying customer who's fed up with your 'customer service'

    Let me see - I'm paying customer trying to renew a subscription that was a reduced rate (hence why I'm not doing it online) - and sometimes I actually want to speak to a human being for a sales transaction.  I'm also a customer who's purchased your p

  • Mirror ipod touch to apple TV

    I've double tapped, gone left and can get my music through the apple TV but there is no mirror option to choose. What am i doing wrong? version 5.1.1 model MD057BT. Any ideas? Thanks

  • Blending options, fx, effects, copy, CS4

    Hi. In PS CS4 In my layers palette, I used to be able to have an effect (ex. drop shadow) on a layer & drag that effect onto another layer so the layers would have the exact same effect. In CS4 when I drag an effect, I lose that effect from that laye

  • I turned on my MacBook Pro 13 and it was completely wiped clean.

    I turned on my MacBook Pro 13 and it was completely wiped clean. I turned it on and it flashed a file folder with a question mark until I plugged in my external backup drive. It will not let me restore from time machine backups or reinstall the OS. I