Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Other Java > Java GUI
|
Java GUI Discussions specific to programming Java GUI.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Java GUI section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 10th, 2004, 04:56 AM
Registered User
 
Join Date: Nov 2003
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default how to refresh a Jlist in a JSscrollPane

Hi,

first , sorry for my poor english

i have a JScrollPane with a Jlist inside .
After pushing a button , i recreate the Jlist
and i would like to REFRESH the JScrollPane with my new Jlist.

How can i do that ??

many thanks


   code:

.....
private javax.swing.JScrollPane jScrollPane = null;
private JList jList1 = null;
......

private void initialize() {
    this.setSize(630, 500);
    this.setTitle("Filtre CAO");
    this.setName("frmFCAO");
    this.setContentPane([u]getJContentPane</u>());
    }

private javax.swing.JPanel [u]getJContentPane</u>() {
    if (jContentPane == null) {
    jContentPane = new javax.swing.JPanel();
    jContentPane.setLayout(null);
        ...
        JButton b1 = new JButton("chercher");
        b1.addActionListener (new ActionListener() {
      public void actionPerformed(ActionEvent e) {
           ...... processing ......
           jList1 = new JList(....);

             here , HOW TO REFRESH ????
                                     });

        .....
        jContentPane.add(getJScrollPane(), null);
    }
    return jContentPane;


........

private javax.swing.JScrollPane getJScrollPane() {
if(jScrollPane == null) {
    jScrollPane = new javax.swing.JScrollPane();
    jList1 = new JList(........);
    jScrollPane.setViewportView(jList1);
    jScrollPane.setBounds(25, 34, 299, 129);
    jScrollPane.setSize(269, 134);
    jScrollPane.setLocation(17, 49);
        }
        return jScrollPane;
                                            }



 
Old August 24th, 2004, 08:02 AM
Authorized User
 
Join Date: Aug 2004
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The methods revalidate() and repaint() in JComponent should 'refresh'.

validate = resizes the container if the component in it changes size.
repaint = redraws the component/container.
 
Old November 20th, 2008, 10:16 AM
Registered User
 
Join Date: Nov 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

This worked for me:
You need to refresh the main panel that holds all the other panels

mainPanel.validate();
mainPanel.repaint();

your jContentPane might work like this:
jContentPane.validate();
jContentPane.repaint();

I am just learning too so your not dealing with an expert. Let me know if it works.







Similar Threads
Thread Thread Starter Forum Replies Last Post
Refresh GridView Using Refresh Button msbsam ASP.NET 2.0 Professional 0 December 6th, 2006 05:57 AM
help add, delete from a JList in a Vector egolileopablo J2EE 1 January 1st, 2005 06:16 AM
refresh marclena Javascript 4 March 24th, 2004 10:29 AM
help me add, delete from a JList in a Vector egolileopablo Java GUI 0 October 22nd, 2003 09:34 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.