Results 1 to 2 of 2
- 10-03-2011, 08:50 PM #1Member
- Join Date
- Jan 2011
- Rep Power
JList does not occupy all the space in the panel.
I am making a Contact Book application, where a JList displays all the contacts. The JList is inside a JPanel, and the problem that i'm having is that it isn't occupying all the space. I've attached a picture to illustrate what I mean:
Is there a way to fix this?
The relevant code is as follows:
contactList = new JList(contactListModel); ContactListCellRenderer renderer = new ContactListCellRenderer(); renderer.setPreferredSize(new Dimension(300,50)); contactList.setCellRenderer(renderer); contactList.setVisibleRowCount(3); contactList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); ... JPanel listPanel = new JPanel(); listPanel.add(contactList/*,BorderLayout.CENTER*/); listPanel.setBackground(Color.darkGray);
Re: JList does not occupy all the space in the panel.
You'll want to create and post an SSCCE for us to be able to do more than an ignorant guess as to your problem and its solution. I only hope and pray that you didn't create this gui with the NetBean's Swing code generator.
- By warchieflll in forum Advanced JavaReplies: 2Last Post: 01-29-2011, 09:29 PM
- By mib1bee in forum New To JavaReplies: 1Last Post: 12-30-2010, 07:24 PM
- By LovJava in forum AWT / SwingReplies: 10Last Post: 09-02-2010, 09:43 PM
- By rclausing in forum New To JavaReplies: 7Last Post: 02-02-2010, 06:56 AM
- By bobbie in forum SWT / JFaceReplies: 0Last Post: 07-05-2009, 01:31 PM