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

  • Home
  • SEARCH
  • 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 8795625
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:25:47+00:00 2026-06-13T23:25:47+00:00

I have write a program which is suppose the set the application property. I

  • 0

I have write a program which is suppose the set the application property. I am using JSplit Pane with JScrollPane. Program is loading fine but it is not changing the value of the right panel in response to list element on the left. Please let me know if I am doing anything wrong. I have refered following program

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JDialog;
import javax.swing.JList;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JTabbedPane;
import javax.swing.ListSelectionModel;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;

public class ApplicationPropertyDlg extends JDialog implements ActionListener,ListSelectionListener {

   private DButton     pb_OK           = null ;
   private DButton     pb_CANCEL       = null ;
   private DButton     pb_APPLY        = null ;
   private String[]         appProp     = null;
   private JList            appList     = null;
   private JSplitPane       appPanel    = null;
   private JScrollPane      listScrollPanel,appScrollPanel  = null; 

   public ApplicationPropertyDlg ( AppDefaultWin parent ) {
      super ( parent, "Properties Application", true ) ;
      initializeAppProp();
      intializeAppList();
      initializeGUI();
      ButtonPanel buttonPanel = new ButtonPanel () ;
      setSize ( 800,700 ) ;
      WinUtil.centerChildInParent ( this, parent ) ;          
      pb_OK     = new JButton ( ) ;
      pb_APPLY  = new JButton ( ) ;
      pb_CANCEL = new JButton ( ) ;

      pb_OK.addActionListener ( this ) ;
      pb_APPLY.addActionListener ( this ) ;
      pb_CANCEL.addActionListener ( this ) ;
      GUISystem.setPreferredButton ( pb_OK ) ;
      GUISystem.setPreferredButton ( pb_CANCEL ) ;
      GUISystem.setPreferredButton ( pb_APPLY ) ;
      getContentPane().setLayout ( new BorderLayout (5,5) ) ;
      getContentPane().add(appPanel);
      getContentPane().add ( buttonPanel, BorderLayout.SOUTH ) ;
      buttonPanel.add ( pb_OK ) ;
      buttonPanel.add ( pb_APPLY ) ;
      buttonPanel.add ( pb_CANCEL ) ;                                 
      setVisible ( true ) ;   
   }

   private void initializeGUI() {
    // TODO Auto-generated method stub
       listScrollPanel = new JScrollPane(appList);
       appScrollPanel = new JScrollPane(new GeneralPage());
       appPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,listScrollPanel,appScrollPanel);
       appPanel.setOneTouchExpandable(true);
       appPanel.setDividerLocation(200);
       //minimum size for individual Panel
       Dimension minimumSize = new Dimension(100, 50);
       listScrollPanel.setMinimumSize(minimumSize);
       appScrollPanel.setMinimumSize(minimumSize);
       //Provide a preferred size for the split pane.
       appPanel.setPreferredSize(appPanel.getPreferredSize());     

}


private void intializeAppList() {
    // TODO Auto-generated method stub
       appList = new JList(appProp);
       appList.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
       appList.setSelectedIndex(0);
       appList.addListSelectionListener(this);


}





private void initializeAppProp() {
    // TODO Auto-generated method stub
    appProp = new String []{"General","Task Bar", "Look and Feel","Country"};
}

   public void propertyChanged ( int property, Object value ) {
      if ( property == PropertySystem.PROPERTY_LANGUAGE )
         setText() ;
      else if ( property == PropertySystem.PROPERTY_LAF )
         GUISystem.setLookAndFeel ( this ) ;
      else
         GUISystem.setPropertiesOnPanel ( getContentPane() ) ;
   }




   public void actionPerformed ( ActionEvent e ) {
         dispose() ;
   }



@Override
public void valueChanged(ListSelectionEvent e) {
    // TODO Auto-generated method stub
    JList list = (JList)e.getSource();
    updateAppPanel(appProp[list.getSelectedIndex()]);

}

private void updateAppPanel(String panelName) {
    // TODO Auto-generated method stub
    if(panelName.equalsIgnoreCase("General"){
        appScrollPanel.removeAll();
        appScrollPanel.add(new GeneralPage());
    }
    else if (panelName.equalsIgnoreCase("Task Bar"){
        appScrollPanel.removeAll();
        appScrollPanel.setViewportView(new TaskBarPage());
    }
    else if (panelName.equalsIgnoreCase("Language"){
        appScrollPanel.removeAll();
        appScrollPanel.setViewportView(new LanguagePage());
    }
    else if (panelName.equalsIgnoreCase("Look and Feel"){
        appScrollPanel.removeAll();
        appScrollPanel.setViewportView(new LookFeelPage());
    }
    else if (panelName.equalsIgnoreCase("Country"){
        appScrollPanel.removeAll();
        appScrollPanel.setViewportView(new SelectCountryPage());
    }
    appScrollPanel.revalidate();
    appScrollPanel.repaint();   
    }
} 
  • 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-06-13T23:25:48+00:00Added an answer on June 13, 2026 at 11:25 pm

    First, add a new control container to the class (preferable a JPanel):

        ...
        private JSplitPane       appPanel    = null;
        private JScrollPane      listScrollPanel,appScrollPanel  = null;
        // End of your controls...
    
        private JPanel tabContainer;   
    

    Then, in the code section where your code initialize the appScrollPanel variable, instead of passing a new instance of a GeneralPane, pass the tabContainer like this:

         tabContainer = new JPanel();
         tabContainer.setLayout(new CardLayout());
         tabContainer.add(new GeneralPage());
         // Instead of adding GeneralPane directly, add the GeneralPane container
         appScrollPanel = new JScrollPane(tabContainer);
    

    Then, in the updateAppPanel method, replace the appScrollPanel.setViewportView invocations like this:

    private void updateAppPanel(String panelName) {
        // TODO Auto-generated method stub
        if(panelName.equalsIgnoreCase("General")){
            tabContainer.removeAll();
            tabContainer.add(new GeneralPage());
        } 
        else if (panelName.equalsIgnoreCase("Task Bar")){
            tabContainer.removeAll();
            tabContainer.add(new TaskBarPage());
        }
        else if (panelName.equalsIgnoreCase("Language")){
            tabContainer.removeAll();
            tabContainer.add(new LanguagePage());
        }
        else if (panelName.equalsIgnoreCase("Look and Feel")){
            tabContainer.removeAll();
            tabContainer.add(new LookFeelPage());
        } 
        else if (panelName.equalsIgnoreCase("Country")){
            tabContainer.removeAll();
            tabContainer.add(new CountryPage());
        }
        appScrollPanel.revalidate();
        appScrollPanel.repaint();   
    }
    

    And it should work:

    enter image description here

    enter image description here

    May I suggest you to put the updateAppPanel code inside a loop? It could save some trouble if you need to make a modification to the inner body of every else if block

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

suppose we have two numbers i want write program which print common bits subsequent
I have a huge text file and I wanted to write a program which
How to write a java program which will tell me whether I have internet
Suppose I have have a program P which has a filename as argument. For
I have a problem with my program, which is using IPC message queue. Althought
Task: have a jailbroken iPhone need to write an application which would receive notifications
I have wrote the code below which was taken from Java How to program
i have to write a program in C to read a file containing several
I have to write a program that sniffs network packets (part1-the simple part). And
I have to write a program in python where the user is given a

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.