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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:56:41+00:00 2026-05-26T00:56:41+00:00

I have this code: class FinalUI1 extends javax.swing.JFrame { //do something Thread t; try

  • 0

I have this code:

   class FinalUI1 extends javax.swing.JFrame 
     {
       //do something 
          Thread t;
        try {
            t = new Thread(new PcapTool(null));
            t.start();
           } catch (InterruptedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
           }
       // do something

     }

     class PcapTool extends ApplicationFrame implements Runnable
  {
     //do something
     public void run() {
        Display Graph based on above classes input
         }
   }

There is a Main UI window and new graphs are generated in separate window whenever user clicks a button.

I want to display graphs, when user clicks button in FinalUI1 class, but when I close any of generated graphs, the whole UI collapses, everything is gone. I want to retain the main UI and shut down the particular graph which user chose to close. It came to my mind that, since UI is on main thread and I can spawn new graphs in new thread, if I do this and close one of child threads, the main UI should still be running.


Additional code:

public class PcapTool extends ApplicationFrame { 
public static String domainChoice, domainConcatenate="";;
public static XYSeries series1;
public static XYSeriesCollection dataset=null;
public static XYSeries series2;
public static PacketInfo resPacketObject;
public static Hashtable<String, Object> DomainNameTable=new Hashtable<String, Object>();
public static String[] hasArray=new String[100];
public static JFreeChart chart;
public static String customTitle = " ";
public  ArrayList<Double> dataNumberList=new ArrayList<Double>(); 
public static String[]dataUsage;
public static String[]timeArrival,txRxTag;
private static final long serialVersionUID = 1L;
public PcapTool(final String title) throws InterruptedException {
    super(title);
    IntervalXYDataset dataset = createDataset();
    JFreeChart chart = createChart(dataset);
    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(2000,1000));//(width,height) of display
    setContentPane(chartPanel);
}
public IntervalXYDataset createDataset() throws InterruptedException {
      // add Series 1 and Series 2
    }
    dataset= new XYSeriesCollection(series1);
    dataset.addSeries(series2);
    dataset.setIntervalWidth(0.05);//set width here
    return dataset;
}
private JFreeChart createChart(IntervalXYDataset dataset) {
    final JFreeChart chart = ChartFactory.createXYBarChart(
            "Pcap Analysis Tool\n Domain: "+domainConcatenate,
            "Time (Seconds)", 
            false,
            "Data Usage (bytes)", 
            dataset,
            PlotOrientation.VERTICAL,
            true,
            true,
            false
            );
    return chart;    
}
public static void main(final String[] args) throws InterruptedException {

    final PcapTool demo = new PcapTool("PCAP Analysis");
    demo.pack();
    RefineryUtilities.centerFrameOnScreen(demo);
    demo.setVisible(true);
    System.out.println("domain: "+dropBoxUserValue);
}
}
  • 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-26T00:56:42+00:00Added an answer on May 26, 2026 at 12:56 am

    I’m guessing that this behavior is due to your using JFrames or something similar to display your child windows, and that the JFrame’s setDefaultCloseOperation properties have been set to JFrame.EXIT_ON_CLOSE which will cause the JVM to exit when any of the windows close.

    I think that you should show them in dialog windows such as a JDialog, not in a JFrame or ApplicationFrame. Also, I have to worry about your use of threading. All Swing code needs to be called on one single thread, the EDT, not separate threads as you may be doing above. Sure, do long-running calculations in a background thread, but the actual display of the chart and any other Swing calls must be on the EDT (unless you know for certain that the calls are thread-safe). The other option is to set the JFrame setDefaultCloseOperation to JFrame.DISPOSE_ON_CLOSE, but still these guys are behaving as dialogs and in my mind, should be shown as dialogs, JDialogs.

    If this doesn’t help, consider posting a minimal compilable and runnable example that is very small, has no extraneous code unrelated to the problem at hand, and that demonstrates your problem, an SSCCE.

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

Sidebar

Related Questions

Scenario: I have this code: class MyActor extends Actor { def act() { react
I have this code(class in class) in java (andorid) public class History extends Activity
I have this code: try { Class.forName(net.sourceforge.jtds.jdbc.Driver); Connection conn = DriverManager.getConnection( jdbc:jtds:sqlserver://myMachine:1433/myDB;instance=sql2008;user=myUserName;password=myPassword; ); System.out.println(connected);
I have this code: public static final <TypeVO extends BaseVo> List<SelectItem> populateSelectBoxForType( final Class<TypeVO>
my class extends Activity, not ListActivity. i have this code on create method but
Suppose we have this code: class My_controller extends CI_Controller { private $model_name; function __construct($model_name)
I have this code: public class Chronom extends Activity { Chronometer mChronometer; ProgressBar progre;
I have this code inside a class that is used by an application and
So I have this code for these Constructors of the Weapon class: Weapon(const WeaponsDB
Suppose I have code like this: template<class T, T initial_t> class Bar { //

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.