Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6551183
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:18:17+00:00 2026-05-25T12:18:17+00:00

I programmed a JFrame that have a Button and JList , and when i

  • 0

I programmed a JFrame that have a Button and JList , and when i click on the Button , the JList list will be displayed . Instead it shows nothing unless i click on maximaze , or refresh the frame.
the button listener class

class b0listener implements ActionListener{

                @Override
                public void actionPerformed(ActionEvent e) {
                    // TODO Auto-generated method stub
                    MessageList.removeAll();    
                    Messages = new JList(lireRepertoire("C:/Documents and Settings/Java/eclipse data file"));


                    Pane =new JScrollPane(Messages);
                    Pane.setPreferredSize(new Dimension(400,400));
                    //Messages.setMaximumSize(MessageList.getPreferredSize()) ;
                    MessageList.add( Pane);

                }}

the class constructor code

Fframe.setTitle("Boite Message");
        Fframe.setSize(800,300);
        Fframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        Fframe.setVisible(true);    
        //  panels Layout 

        ButtonMenu.setLayout(new BoxLayout(ButtonMenu, BoxLayout.Y_AXIS));//Jpanel
        MessageList.setLayout(new FlowLayout());//JPanel
        ButtonMenu.setBackground(Color.LIGHT_GRAY);
        MessageList.setBackground(Color.orange);
        MessageList.setPreferredSize(new Dimension(400, 400));

                Fframe.add(ButtonMenu,BorderLayout.WEST);
        Fframe.add(MessageList,BorderLayout.CENTER);
        ButtonMenu.add(b0);
                b0.addActionListener(new b0listener());
                 Pane =new JScrollPane(Messages);
        Messages.setPreferredSize(new Dimension(800,250));
        //Pane.setMaximumSize(MessageList.getSize()) ;
        MessageList.add( Pane);

I already declared the Jpanels and Jframe , button as class members

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T12:18:17+00:00Added an answer on May 25, 2026 at 12:18 pm

    First of all, learn an use the proper Java naming conventions. Variables should not start with an upper case character.

    When dynamically adding/removing components from a panel you need to revalidate() the panel:

    messageList.add( pane); 
    messageList.revalidate();
    messageList.repaint();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have programmed a sub procedure that will be called in the main procedure
I have a JFrame that contains a JTextPane. The purpose of this JTextPane is
I programmed a bluetooth Television-Remote control for cellphones in J2ME using javax.microedition.lcdui.* (Gauge, List,
I have recently programmed a console application and I've experienced a lot of pain
I have never programmed a gadget for Vista or Seven, but I would like
I have a webservice programmed in coldfusion which I'm attempting to consume using c#.net.
I have programmed an emulator, but I have some doubts about how to organizate
I programmed a CMS that has a log of who has recently logged into
I have programmed with procedural style a lot before and in these few months
I have programmed an embedded software (using C of course) and now I'm considering

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.