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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T23:19:00+00:00 2026-05-22T23:19:00+00:00

UPDATE: I’m using Netbeans and Matise and it’s possible that it could be Matise

  • 0

UPDATE: I’m using Netbeans and Matise and it’s possible that it could be Matise causing the problems I describe below.

UPDATE 2: Thanks to those who offered constructive suggestions. After rewriting the code without Matise’s help, the answer offered by ignis worked as he described. I’m still not sure how the code the Netbeans code generator interfered.

Though I’ve been programming in Java for awhile I’ve never done any GUI programming until now. I would like to control a certain part of my program externally (updating a jTextArea field with output from an external source) without requiring any user action to trigger the display of this output in the jTextArea.

Specifically, I want this output to begin displaying on startup and to start and stop depending on external conditions that have nothing to do with the GUI or what the user is doing. From what I understand so far you can trigger such events through action listeners, but these action listeners assume they are listening for user activity. If I must use action listeners, is there a way to trick the GUI into thinking user interaction has happened or is there a more straightforward way to achieve what I want to do?

Also, I’d really like to know more about best practices for separating GUI code from the application logic. From the docs I’ve come across, it seems that GUI development demands more of a messy integration of logic and user interface than, say, a web application where one can achieve complete separation. I’d be very interested in any leads in this area.

  • 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-22T23:19:00+00:00Added an answer on May 22, 2026 at 11:19 pm

    There is no need to use listeners. GUI objects are just like any other objects in the program, so actually

    1. you can use the listener pattern in any part of the program, even if it is unrelated to the GUI
    2. you can invoke methods of objects of the GUI whenever you want during the program execution, even if you do not attach any listeners to the objects in the GUI.

    The main “rule” you must follow is that every method invocation performed on objects of the GUI must be run on the AWT Event Dispatch Thread (yes, that’s true for Swing also).

    http://download.oracle.com/javase/tutorial/uiswing/concurrency/dispatch.html

    So you must wrap code accessing the GUI objects, into either

    javax.swing.SwingUtilities.invokeLater( new Runnable() { ... } )
    

    or

    javax.swing.SwingUtilities.invokeAndWait( new Runnable() { ... } )
    

    http://download.oracle.com/javase/6/docs/api/javax/swing/SwingUtilities.html


    About “separating GUI code from the application logic”: google “MVC” or “model view controller”. This is the “standard” way of separating these things. It consists in making the GUI code (the “view”) just a “facade” for the contents (the “model”). Another part of the application (the “controller”) creates and invokes the model and the view as needed (it “controls” program execution, or it should do that, so it is named “controller”), and connects them with each other.

    http://download.oracle.com/javase/tutorial/uiswing/components/model.html

    For example, a JFoo class in the javax.swing package, that defines a Swing component, acts as the view for one or more FooModel class or interface defined either under javax.swing or one of its subpackages. You program will be the “controller” which instantiates the view and an implementation of the model properly (which may be one of the default implementations found under those packages I mentioned, or a custom implementation defined among your custom packages in the program).

    http://download.oracle.com/javase/1.4.2/docs/api/javax/swing/package-summary.html

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

Sidebar

Related Questions

Update: Solved, with code I got it working, see my answer below for the
UPDATE: Focus your answers on hardware solutions please. What hardware/tools/add-in are you using to
Update: Now that it's 2016 I'd use PowerShell for this unless there's a really
UPDATE: Thanks to everyone for the responses. I didn't realize document.write() was deprecated. Add
Update: Thanks for the suggestions guys. After further research, I’ve reformulated the question here:
UPDATE - No need to answer this now, I have solved below. Hi, I'm
[UPDATE] Thanks guys,final code: var EUR_share_cost = 0; var USD_share_cost = 0; var GBP_share_cost
Update: I've added an answer that describes my final solution (hint: the single Expr
UPDATE: Turns out my code works. Browser was caching previous failed response. Thanks for
Update - I fixed the query below. I had the wrong query/error statement :(

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.