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 8702499
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T02:40:15+00:00 2026-06-13T02:40:15+00:00

I have VTreePanel class that extends from CPanel which extends from JPanel. The class

  • 0

I have VTreePanel class that extends from CPanel which extends from JPanel. The class has a JSplitPane object that is divided into two area: left & right. The left side contains tree menu selection object. At right side, it contains JTabbedPane object. The VTreePanel class is like this:

public final class VTreePanel extends CPanel
    implements ActionListener
{
    private JSplitPane centerSplitPane = new JSplitPane();

    private JTabbedPane tabbedPane;

    ...

    // GET method for the tabbedPane    
    public JTabbedPane getTabbedPane() {
        return tabbedPane;
    }

    // Constructor
    public VTreePanel(int WindowNo, boolean hasBar, boolean editable)
    {

        ...

        tabbedPane = new JTabbedPane();
        centerSplitPane.add(treePart, JSplitPane.LEFT);
        centerSplitPane.add(tabbedPane, JSplitPane.RIGHT);  // Look at this

        ...
    }

}

In constructor, I added the tree selection (treePart) and JTabbedPane object (tabbedPane) into the JSplitPane object (centerSplitPane). I don’t add any Tab into the tabbedPane yet. Look at the screenshot below:

http://i45.tinypic.com/2v3j0nl.jpg

Then how do I add the tab when user click one of the menu?

I have AMenu class where it has implemented PropertyChangeListener that fired propertyChange method when user clicked a menu:

public final class AMenu extends CFrame
    implements ActionListener, PropertyChangeListener, ChangeListener
{

    private VTreePanel treePanel = null;    // this is the VTreePanel object

    ...

    public void propertyChange(PropertyChangeEvent e)
    {
        ...

        // Here I pass the VTreePanel object as parameter to AMenuStartItem thread object
        (new AMenuStartItem(cmd, true, sta, this, treePanel)).start();
    }

}

You can see that I have VTreePanel object (treePanel) and I pass the VTreePanel object as parameter to AMenuStartItem thread. The AMenuStartItem contains logic that perform adding Tab in JTabbedPane (remember, JTabbedPane object (tabbedPane) is in the VTreePanel).

Here is the AMenuStartItem thread class:

public class AMenuStartItem extends Thread implements ActionListener
{
    private VTreePanel m_vtreePanel;

    public AMenuStartItem (int ID, boolean isMenu, String name, AMenu menu, VTreePanel vtreepanel)
    {
        ...

        m_vtreePanel = vtreepanel;  // save the VTreePanel object
    }

    // The thread method that executed when thread is started
    public void run()
    {
        ...

        startWindow(0, cmd);

        ...
    }

    private void startWindow(int AD_Workbench_ID, int AD_Window_ID)
    {
        ...

        // Here I perform adding new tab
        m_vtreePanel.getTabbedPane().addTab(frame.getTitle(), frame.getAPanel());

        ...
    }

}

So, the getTabbedPane() returned the JTabbedPane object and the addTab() method is executed but no tab showed up at all.

Anyone know how to fix this problem?

  • 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-13T02:40:16+00:00Added an answer on June 13, 2026 at 2:40 am

    All interactions with the UI MUST be done via the Event Dispatching Thread, no exceptions…

    public class AMenuStartItem extends Thread implements ActionListener
    {
        private VTreePanel m_vtreePanel;
    
        public AMenuStartItem (int ID, boolean isMenu, String name, AMenu menu, VTreePanel vtreepanel)
        {
            ...
    
            m_vtreePanel = vtreepanel;  // save the VTreePanel object
        }
    
        // The thread method that executed when thread is started
        public void run()
        {
            ...
    
            startWindow(0, cmd);
    
            ...
        }
    
        private void startWindow(final int AD_Workbench_ID, final int AD_Window_ID)
        {
            ...
    
            if (EventQueue.isDispatchingThread()) {
                // This is safe, we're in the EDT
                m_vtreePanel.getTabbedPane().addTab(frame.getTitle(), frame.getAPanel());
                m_vtreePanel.getTabbedPane().invalidate();
                m_vtreePanel.getTabbedPane().repaint();
            } else {
                // This is unsafe, we need to resync with the EDT
                SwingUtilities.invokeLater(new Runnable() {
                    public void run() {
                        // Here I perform adding new tab
                        m_vtreePanel.getTabbedPane().addTab(frame.getTitle(), frame.getAPanel());
                        m_vtreePanel.getTabbedPane().invalidate();
                        m_vtreePanel.getTabbedPane().repaint();
    
                    }
                });
            }
    
            ...
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

have written this little class, which generates a UUID every time an object of
Have data that has this kind of structure. Will be in ascending order by
Have data that has this kind of structure: $input = [ { animal: 'cat',
I have defined a class which represents a tree structure GeographicalUnits = Ext.extend(Ext.tree.TreePanel, {
I have an Ext TreePanel which I'm trying to add some server-side pagination to.
Have a procedure which looks like Procedure TestProc(TVar1, TVar2 : variant); Begin TVar1 :=
Have deployed numerous report parts which reference the same view however one of them
I have this treepanel and i want to call this.getId() method of mainpaneltree from
I have separated my screen into 4.I like to use the same static variable
I have seen Ext.net's examples site in which each new page is added as

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.