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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T10:43:36+00:00 2026-06-03T10:43:36+00:00

How do I wire output to paneWithList ? PaneWithList has a listener on its

  • 0

How do I wire output to paneWithList?

PaneWithList has a listener on its JList so that the selected row is output to the console. How can I direct that output to the JTextPane on output?

Could PaneWithList fire an event which Main picks up? Would PropertyChangeSupport suffice?

Main.java:

package dur.bounceme.net;

import javax.swing.JTabbedPane;

public class Main {

    private static JTabbedPane tabs;
    private static PaneWithList paneWithList;
    private static PaneWithTable paneWithTable;
    private static Output output;

    public static void main(String[] args) {
        tabs = new javax.swing.JTabbedPane();
        paneWithList = new PaneWithList();
        paneWithTable = new PaneWithTable();
        tabs.addTab("list", paneWithList);
        tabs.addTab("table", paneWithTable);
        tabs.addTab("output", output);
    }
}
  • 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-03T10:43:57+00:00Added an answer on June 3, 2026 at 10:43 am

    Here’s an example using the observer pattern, also seen here, here and here. Note that it would also be possible to listen to the combo’s model.

    enter image description here

    import java.awt.GridLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.beans.PropertyChangeEvent;
    import java.beans.PropertyChangeListener;
    import javax.swing.*;
    
    /**
    * @see http://en.wikipedia.org/wiki/Observer_pattern
    * @see https://stackoverflow.com/a/10523401/230513
    */
    public class PropertyChangeDemo {
    
        public PropertyChangeDemo() {
            JFrame f = new JFrame();
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.setResizable(false);
            f.add(new ObserverPanel());
            f.pack();
            f.setLocationByPlatform(true);
            f.setVisible(true);
        }
    
        public static void main(String[] args) {
            SwingUtilities.invokeLater(new Runnable() {
    
                @Override
                public void run() {
                    PropertyChangeDemo example = new PropertyChangeDemo();
                }
            });
        }
    }
    
    class ObserverPanel extends JPanel {
    
        private JLabel title = new JLabel("Value received: ");
        private JLabel label = new JLabel("null", JLabel.CENTER);
    
        public ObserverPanel() {
            this.setBorder(BorderFactory.createTitledBorder("ObserverPanel"));
            JPanel panel = new JPanel(new GridLayout(0, 1));
            panel.add(title);
            panel.add(label);
            this.add(panel);
            ObservedPanel observed = new ObservedPanel();
            observed.addPropertyChangeListener(new PropertyChangeListener() {
    
                @Override
                public void propertyChange(PropertyChangeEvent e) {
                    if (e.getPropertyName().equals(ObservedPanel.PHYSICIST)) {
                        String value = e.getNewValue().toString();
                        label.setText(value);
                    }
                }
            });
            this.add(observed);
        }
    }
    
    class ObservedPanel extends JPanel {
    
        public static final String PHYSICIST = "Physicist";
        private static final String[] items = new String[]{
            "Alpher", "Bethe", "Gamow", "Dirac", "Einstein"
        };
        private JComboBox combo = new JComboBox(items);
        private String oldValue;
    
        public ObservedPanel() {
            this.setBorder(BorderFactory.createTitledBorder("ObservedPanel"));
            combo.addActionListener(new ComboBoxListener());
            this.add(combo);
        }
    
        private class ComboBoxListener implements ActionListener {
    
            @Override
            public void actionPerformed(ActionEvent ae) {
                String newValue = (String) combo.getSelectedItem();
                firePropertyChange(PHYSICIST, oldValue, newValue);
                oldValue = newValue;
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to wire up Spring Data JPA objects manually so that I can
how i can delete this wire lines that devide my prism on triangles? http://img217.imageshack.us/img217/1535/31477485.jpg
I am using AddHandler to wire a function to a control's event that I
I work with a propriety client/server message format that restricts what I can send
Background: I am working on a large database that is used to track wire
So, I have the log4j configurations set up and it output to the console
I have the following module: module add_8bit ( output wire co, output wire [7:0]
I can wire up Elmah to log Exceptions in my ASP.Net application and it
I'm using jQuery to wire up some mouseover effects on elements that are inside
How do we remove a header (e.g. Last-Modified ) that has already been set

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.