Article View: borland.public.jbuilder.java.swing
Article #13253Re: JList with scrollbar
From: Martin Anders
Date: Wed, 26 Aug 1998 00:00
Date: Wed, 26 Aug 1998 00:00
62 lines
2537 bytes
2537 bytes
Hi Alex,
ok I see, I've got the same problem with the jlist. It has maybe something to do
with the graphic update of the jList.
I have two jLists on two jPanels with a cardlayout. When I add elements to one
list I see no scrollbar. After I've changed between the two panels (put the
first panel behind the second one and then bring it back to front) suddenly the
jlist has a scrollbar.
First try to add the elements before you set the viewport and see how that
works.
Maybe you have to call a repaint event, I am still looking for a solution for my
application, I'll inform you once I've found one.
Martin
zimmerer wrote:
> It does not work there still is no scrollbar. I've wrote a little test code,
> perhaps someone can take a short look at it and tell me whats wrong.
>
> import com.sun.java.swing.*;
> import java.awt.*;
> import java.awt.event.*;
>
> public class Test extends JFrame {
>
> public Test() {
> Frame1 frame = new Frame1();
> frame.setVisible(true);
> }
> public static void main(String[] args) {
> new Test();
> }
>
> class Frame1 extends JFrame {
> GridLayout grid = new GridLayout();
> public Frame1() {
> this.getContentPane().setLayout(grid);
> this.setSize(200,200);
> DefaultListModel model = new DefaultListModel();
> JList list = new JList(model);
> JScrollPane scroll = new JScrollPane();
> scroll.getViewport().setView(list);
> //this doesn't work, too
> //JList list =new JList(model);
> //JScrollPane scroll = new JScrollPane(list);
> this.getContentPane().add(list);
> for (int i=0;i<20;i++) {
> model.addElement("item"+i);
> }
> }
> protected void processWindowEvent(WindowEvent e) {
> super.processWindowEvent(e);
> if (e.getID() == WindowEvent.WINDOW_CLOSING) {
> System.exit(0);
> }
> }
> }
> }
>
Technical Details
Message-ID:
<35E3EB20.E51998A5@ddsynergy.de>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<35E2A7B4.B5EC3479@cimag.de> <35E2F53B.2269C0AA@csi.com> <35E3D07E.FA559753@cimag.de>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,b5ee876fbd119f83 X-Google-Attributes: gid111d45,public From: Martin Anders <m_anders@ddsynergy.de> Subject: Re: JList with scrollbar Date: 1998/08/26 Message-ID: <35E3EB20.E51998A5@ddsynergy.de> X-Deja-AN: 384877083 Content-Transfer-Encoding: 7bit References: <35E2A7B4.B5EC3479@cimag.de> <35E2F53B.2269C0AA@csi.com> <35E3D07E.FA559753@cimag.de> Content-Type: text/plain; charset=us-ascii Organization: Another Netscape Collabra Server User Mime-Version: 1.0 Newsgroups: borland.public.jbuilder.java.swing