Results 1 to 2 of 2
- 10-03-2011, 07:50 PM #1
Member
- Join Date
- Jan 2011
- Posts
- 93
- Rep Power
- 0
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:
Thanks for your help.Java Code: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.
Similar Threads
-
panel on a panel not visible
By warchieflll in forum Advanced JavaReplies: 2Last Post: 01-29-2011, 08:29 PM -
Link one JList to another JList
By mib1bee in forum New To JavaReplies: 1Last Post: 12-30-2010, 06:24 PM -
Add panel to parent panel
By LovJava in forum AWT / SwingReplies: 10Last Post: 09-02-2010, 08:43 PM -
Adding a panel to a panel
By rclausing in forum New To JavaReplies: 7Last Post: 02-02-2010, 05:56 AM -
SWT Canvas drawing realtive to image space not canvas space.
By bobbie in forum SWT / JFaceReplies: 0Last Post: 07-05-2009, 12:31 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks