LINUX: Swing creates indestructible JFrame-threads

T

tom baker

Hi there,

I'm programming an application for touchscreens. Each 'page' on the
screen is a JFrame. Among other criterions it's IMHO the easiest way
to go into 'idle'-state (by using a javax-Timer with 'dispose').

Each new JFrame (e.g. gui_start_swt_log_inst=new
cls_gui_start_swt_log(getCode()); ) creates a new linux
thread (or process). But after dispose() the thread/process of this
JFrame is still there.

Now I worry about that the whole system could
slow down or stop after a certain time, because the OS still has to
provide ressources for these non-active processes/threads.

What is the cause? java?


I hope this is part of my code ist not to short but meaningful enough:




public class cls_gui_start extends JFrame
{

private cls_gui_start_swt_log gui_start_swt_log_inst;
private GuiStartListener listener_gui_start;
...


public cls_gui_start()
{
JTextField jtf_code;
JButtons, etc.
}

class GuiStartListener implements ActionListener {


public void actionPerformed(ActionEvent event)
{

// ----------------------------------------------------------------------------

if ( (jtf_code.getText()).startsWith("P") )
{

gui_start_swt_log_inst=new
cls_gui_start_swt_log(getCode());
gui_start_swt_log_inst.show();

gui_start_swt_log_inst.addWindowListener(new
WindowAdapter() {
public void windowClosed(WindowEvent event)
{
System.out.println("gui_start: the end of
gui_start_swt_log_inst");
}
});
}
}
}
}


##########################################################
##########################################################
//
// Staff Work time logging


public class cls_gui_start_swt_log extends JFrame
{

private GuiStartSwtLogListener listener_gui_start_swt_log;
private javax.swing.Timer countdown;
...

public cls_gui_start_swt_log(int code)
{
// Kills the window after 10 seconds if it is unused
countdown = new javax.swing.Timer(10000, new ActionListener()
{
public void actionPerformed(ActionEvent e) {
countdown.stop();
dispose();
}
});
countdown.start();

// Buttons etc.
}


class GuiStartSwtLogListener implements ActionListener {


public void actionPerformed(ActionEvent event)
{

// ------------------------------------------------------------------------

if (event.getSource() == btn_begin)
{
countdown.stop();
// write into file
dispose();
}
}
}




Thanks in advance !

tom
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top