Blocking mainthread till gui event

I know this has been posted many a times .
But i'm unable to make out the solution specific to my code . I,ve created a class MyFrame extending Jframe. i've placed a button on it.I need this class to define a method get_table() which returns a specific datatable only wen the button is clicked . in other words calling get_table should pause or block the main thread until the button is clicked; I've implemented spinlocking before using a while loop in the main thread. Give me an alternative solution please ;

jamesybaby wrote:
jamesybaby wrote:
Give me an alternative solution please ;No. Think for yourself. You have not posted any code.
Why should we help you?Please ignore this comment. I got told off by sabre(And rightly so) I was just a bit fed up.
Please read the following Swing tutorial on GUI and Threads.
[http://java.sun.com/products/jfc/tsc/articles/threads/threads1.html]
Sorry about not posting any code , jamesybaby . I'm a newbie :-) ;
About the tutorial, it's great .But I never understood how to apply it into my context ; You recommend using invokeandwait() ?
Here's my code for MyFrame
public class MyFrame extends javax.swing.JFrame implements ActionListener {
    public MyFrame() {
        super();
        initComponents();
        panel = new MyRow[9];
        for (int i = 0; i < 9; i++) {
            panel[i] = new MyRow();
            getContentPane().add(panel);
action = new JPanel();
_OK = new JButton("Solve");
_OK.addActionListener(this);
action.add(_OK);
add(action);
MyFrame(MyTable t) {
initComponents();
panel = new MyRow[9];
for (int i = 0; i < 9; i++) {
panel[i] = new MyRow(t.getrow(i+1));
getContentPane().add(panel[i]);
action = new JPanel();
_OK = new JButton("Solve");
_OK.addActionListener(this);
action.add(_OK);
getContentPane().add(action);
public int getData(int row, int col) {
return panel[row].getBox(col);
private void initComponents() {
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
getContentPane().setLayout(new javax.swing.BoxLayout(getContentPane(), javax.swing.BoxLayout.PAGE_AXIS));
pack();
MyRow panel[];
JPanel action;
JButton _OK;
MyTable table;
private boolean done = false;
boolean isdone() {
return done;
public void actionPerformed(ActionEvent e) {
done = true;
public MyTable getdata(){
MyTable t=new MyTable();
try{
catch(Exception e){
for (int i = 0; i < 9; i++) {
for (int j = 0; j < 9; j++) {
if (getData(i, j) == 0) {
continue;
} else {
t.setdata(i+1, j+1, getData(i, j));
return t;
}After this i need to call getdata from the main function to  store the returned table.
The table should only be returned when the button is clicked
And thank ya sabre150                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

Similar Messages

  • VI's GUI events disturb another VI's work

    Platform: Win2K, LabView 6.0i.
    I saw that some VI's GUI events (like pressing a mouse button on the VI's caption) pause the VI for a while and may disturb the work of other VIs too. For example, open two attached files and run them both. Then press and hold the left mouse button on a.vi's caption - you will see that both a.vi and b.vi will stop counting for a while.
    My problem is that the "b.vi" in my application is a time-critical one, so if the user plays with the application GUI it can crash the application. May I disable such a behaviour by setting VI priorities or somehow else ?
    Thank you,
    Sergey.
    Attachments:
    a.vi ‏10 KB
    b.vi ‏10 KB

    Far be from me to suggest that a local rep might be blowing smoke, but I just retried your two VIs on a Win2k machine and nothing I do causes the other VI from even hesitate--let alone stop.
    What exactly is the effect? Is there a knowledgebase entry explaining it? Pin your local rep down and get specifics.
    Mike...
    Certified Professional Instructor
    Certified LabVIEW Architect
    LabVIEW Champion
    "... after all, He's not a tame lion..."
    Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps

  • Monitor GUI events using JVMTI

    I'm looking for a way to create a log of all GUI events (JButton clicks, JInternalFrame init/close/minimize, etc.) with a timestamp. I would like to do this without editing the application source code (sprinkling trace statements throughout the app source). Is JVMTI the way to go for this endeavor? Could someone provide a road map of how to accomplish this?
    thanks!

    Jean-Francois Denise from the JMX team has a nice MBean which might be useful to you:
    http://blogs.sun.com/roller/page/jmxnetbeans?entry=jmx2awt_mbean

  • How to tackle the dataflow problem when Value Change event always triggers after another GUI event

    We know that Value change event always triggers after another GUI event. Eg, the user modifies string control, the user clicks on a boolean control. Then event boolean clicked is triggered before event string control value change.
    Now suppose somehow the GUI event that must happen to subsequently trigger the Value change event can potentially affect the data that Value change event is supposed to work on. How can we tackle this problem ?
    For example, in a mockup application that the grand purpose is to have user entered values in a textbox logged to a file (no missing information is accepted, and there is a boolean to determine how the information is logged).
    There are 2 controls, boolean A when clicked (mouse down) will load random number in text box B. Text box B is designed with event structure VALUE change which saves whatever values user enters into text box B to a log file.
    There are 3 problems when instead of clicking anywhere on the front panel after modifying text box B, the user ends up clicking on boolean control A.
    1. Event mouse down on Boolean control A will execute first, modifying text box B content before the user entered values in B get saved.
    2. The value of boolean A can potentially affect how textbox B is loggged.
    3. The value of boolean A affects how the file is logged and this is indeterminate. Somehow when running this VI with no Highlighting, the textbox B Value change event executes -before- boolean A value is updated (F to T). When running this VI with Highlighting, the boolean A value is updated (F to T) (because we click on it) -before- textbox B value change event occurs. Why is it like this ?
    Now the situation I made up seems non-sense, but I believe it resembles one way or another a problem that you might run into. How would you solve this problem elegantly ?
     

    You can set the string control to "update while typing".
    Are you sure appending the log to itself is reasonable? Wouldn't it grow without bounds if the users keeps entering strings or pressing the ingore button?
    Why isn't the "constant" a diagram constant instead of a control. Is the user allowed to change it?
    To reset just write empty strings or a false to local variables of the controls (renit to defaults" seems a bit heavy handed).
    All you probably need is a single event case for "ignore:value change" and "String" value changed", no need for the local variable..
    Also add a stop button and an event for it.
    You don't need the timeout event.
     

  • Block UI on Ajax4JSF event

    Dear Folks,
    i'm working on a large ui, where i have the need to implement something like
    a guided step-by-step procedure.
    Therefor there are several panels implemented, for example one for the sender, one the receiver and so on. The user should only be able to navigate from one panel to another one on define rulesets. So, till there , it's no problem.
    The problem is now, that for example, the user works in the sender panel, then all following panel should be "blocked". That means that the following panels should have an layer above them selve which is half transparent and ensures that nothing in the benieve layer could be processed (button clicks and so on).
    Could somebody help me on this??

    Hi Priya,
    You say
    According to my understanding the OnEnter event would get called when the cursor from the input field moves out of the input field
    but the onEnter event does triggered by pressing the enter key.
    Regards,
    Simon.

  • To remove the block created by TOP_OF_PAGE event in ALV

    hello All,
    i have added some code to modify the subtotal in ALV and that code has been added in the TOP_OF_PAGE event of the ALv . and in that case , a blank block is added on the top of the ALV that is consuming almost one third space of  the  screen.
    i dont have any information to pass to the Heading block.
    i need to remove that block.
    please suggest me how can i achieve that.
    Regards
    Geeta Gupta

    Hi Geetha,
         If you don't have any information to pass the Heading Block, then why you are using this event ?
         please comment/ remove that TOP_OF_PAGE code. and use subtotal code in field catalog block.
          you can use below code for subtotal. 
          FORM field_catalog .
                    gs_fcat-do_sum = &2.
              fcat : 'WRBTR' '15' 'X' ' ' ' ' 'WRBTR' 'Amount',
           ENDFORM.
           Regards,
           Kunjan

  • GUI event handling problems appear in 1.4.1 vs. 1.3.1?

    Hi,
    Has anyone else experienced strange event handling problems when migrating from 1.3.1 to 1.4.1? My GUI applications that make use of Swing's AbstractTableModel suddenly don't track mouse and selection events quickly anymore. Formerly zippy tables are now very unresponsive to user interactions.
    I've run the code through JProbe under both 1.3 and 1.4 and see no differences in the profiles, yet the 1.4.1 version is virtually unusable. I had hoped that JProbe would show me that some low-level event-handling related or drawing method was getting wailed on in 1.4, but that was not the case.
    My only guess is that the existing installation of 1.3.1 is interfering with the 1.4.1 installation is some way. Any thoughts on that before I trash the 1.3.1 installation (which I'm slightly reluctant to do)?
    My platform is Windows XP Pro on a 2GHz P4 with 1GB RAM.
    Here's my test case:
    import javax.swing.table.AbstractTableModel;
    import javax.swing.*;
    import java.awt.*;
    public class VerySimpleTableModel extends AbstractTableModel
    private int d_rows = 0;
    private int d_cols = 0;
    private String[][] d_data = null;
    public VerySimpleTableModel(int rows,int cols)
    System.err.println("Creating table of size [" + rows + "," + cols +
    d_rows = rows;
    d_cols = cols;
    d_data = new String[d_rows][d_cols];
    int r = 0;
    while (r < d_rows){
    int c = 0;
    while (c < d_cols){
    d_data[r][c] = new String("[" + r + "," + c + "]");
    c++;
    r++;
    System.err.println("Done.");
    public int getRowCount()
    return d_rows;
    public int getColumnCount()
    return d_cols;
    public Object getValueAt(int rowIndex, int columnIndex)
    return d_data[rowIndex][columnIndex];
    public static void main(String[] args)
    System.err.println( "1.4..." );
    JFrame window = new JFrame();
    window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JPanel panel = new JPanel();
    Dimension size = new Dimension(500,500);
    panel.setMinimumSize(size);
    panel.setMaximumSize(size);
    JTable table = new JTable(new VerySimpleTableModel(40,5));
    panel.add(table);
    window.getContentPane().add(panel);
    window.setSize(new Dimension(600,800));
    window.validate();
    window.setVisible(true);
    Thanks in advance!!
    - Dean

    Hi,
    I've fixed the problem by upgrading to 1.4.1_02. I was on 1.4.1_01.
    I did further narrow down the symptoms more. It seemed the further the distance from the previous mouse click, the longer it would take for the table row to highlight. So, clicking on row 1, then 2, was much faster than clicking on row 1, then row 40.
    If no one else has seen this problem -- good! I wouldn't wish the tremendous waste of time I've had on anyone!
    - Dean

  • Blocking GR till GI is not complete

    Dear PP Gurus,
    We are following the normal process of creating production orders and issuing the goods to the operations, confirming the operations and the doing the GR for the finished product. In this scenario, how can we block GR for a material being produced against a production order, till GI of all the raw materials is not complete/ till there exist reservations against the orders for which GI has not been done.
    Thanks
    Geravine

    Hi,
    Production order should not allow GR until GI
    1. Go to BS02, click new & specify the user status name, brief text & lang
    2. In status number specify 1, Status = Zst1, short text = test1, init status is tick, lowest 1, highest 2
    3. Click on object types & tick PP/PM: order header
    4. Double click on this & then in the next screen, add
    - Release - no influence & set
    - GR - forbidden & no action
    5. Add next status, 2 Status = Zst2, short text = test2, init status is blank, lowest 1, highest 2
    - Confirm Prodn. order - no influence & set
    - GR - allowed & no action
    Regards
    Jagadeesh K

  • Non-GUI events in Java

    I was wondering how I would have to go about writing an event handling mechanism on something that is not GUI-based (non-AWT/SWING)!
    Supposing one wanted to write an event listener that would tell them when a data structure is updated - e.g: in a typical producer-consumer model, where the consumer is to be notified of fresh entries whenever a producer writes integers to some data structure...
    Does Java have classes/methods to handle such non-GUI-based 'events'? Is this a commonly found scenario in Java programming?
    Thank you!

    What you're looking for is the Observer-interface. Check out http://java.sun.com/j2se/1.4/docs/api/java/util/Observer.html
    and
    http://java.sun.com/j2se/1.4/docs/api/java/util/Observable.html

  • GUI event handling of 1.4.1 vs. 1.3.1

    Hi,
    Has anyone else experienced strange event handling problems when migrating from 1.3.1 to 1.4.1? My GUI applications that make use of Swing's AbstractTableModel suddenly don't track mouse and selection events quickly anymore. Formerly zippy tables are now very unresponsive to user interactions.
    I've run the code through JProbe under both 1.3 and 1.4 and see no differences in the profiles, yet the 1.4.1 version is virtually unusable. I had hoped that JProbe would show me that some low-level event-handling related or drawing method was getting wailed on in 1.4, but that was not the case.
    My only guess is that the existing installation of 1.3.1 is interfering with the 1.4.1 installation is some way. Any thoughts on that before I trash the 1.3.1 installation (which I'm slightly reluctant to do)?
    Here's my test case:
    import javax.swing.table.AbstractTableModel;
    import javax.swing.*;
    import java.awt.*;
    public class VerySimpleTableModel extends AbstractTableModel
    private int d_rows = 0;
    private int d_cols = 0;
    private String[][] d_data = null;
    public VerySimpleTableModel(int rows,int cols)
    System.err.println("Creating table of size [" + rows + "," + cols +
    d_rows = rows;
    d_cols = cols;
    d_data = new String[d_rows][d_cols];
    int r = 0;
    while (r < d_rows){
    int c = 0;
    while (c < d_cols){
    d_data[r][c] = new String("[" + r + "," + c + "]");
    c++;
    r++;
    System.err.println("Done.");
    public int getRowCount()
    return d_rows;
    public int getColumnCount()
    return d_cols;
    public Object getValueAt(int rowIndex, int columnIndex)
    return d_data[rowIndex][columnIndex];
    public static void main(String[] args)
    System.err.println( "1.4..." );
    JFrame window = new JFrame();
    window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JPanel panel = new JPanel();
    Dimension size = new Dimension(500,500);
    panel.setMinimumSize(size);
    panel.setMaximumSize(size);
    JTable table = new JTable(new VerySimpleTableModel(40,5));
    panel.add(table);
    window.getContentPane().add(panel);
    window.setSize(new Dimension(600,800));
    window.validate();
    window.setVisible(true);
    Thanks in advance!!
    - Dean

    Hi,
    I've fixed the problem by upgrading to 1.4.1_02. I was on 1.4.1_01.
    I did further narrow down the symptoms more. It seemed the further the distance from the previous mouse click, the longer it would take for the table row to highlight. So, clicking on row 1, then 2, was much faster than clicking on row 1, then row 40.
    If no one else has seen this problem -- good! I wouldn't wish the tremendous waste of time I've had on anyone!
    - Dean

  • Sap Gui Events to WD4A - Consecuences of note 1409237

    Hi Guys!
    This is mi first post here, I hope I can solve with my question many same problems.
    I've got a problem applying this note in my WDA application. I've got an ABAP application with one CL_GUI_WDR_VIEWER control and within a WD4A component.
    In this note, you can see that the way of subscribing events from SAP GUI to WD4A have changed and now, SAP guides you to do it using the class IF_WD_PORTAL_INTEGRATION->SUBSCRIBE_EVENT, in the WD4A Component and firing the event using CL_GUI_WDR_VIEWER->fire_event.
    My code for subscribing the event is the following:
      CALL METHOD lo_portal_manager->SUBSCRIBE_EVENT
        EXPORTING
          PORTAL_EVENT_NAMESPACE = ''
          PORTAL_EVENT_NAME      = ''
          VIEW                   = LO_API_CONTROLLER
          ACTION                 = 'SHOW'
    My question is:
    Is it necessary to fill the PORTAL_EVENT* parameters ? I'm doing something wrong?
    Thanks a lot!

    Hi,
    finally I read that SAP is not allowing eventing from SAP GUI to WD embed applications no more, so I had to make my way to reach my objectives.  As I read, bad news from SAP..
    Thanks anyway.

  • GUI event handling

    I have created a class that gives employees a sick leave allowance and they can request sick leave days.I have made a GUI form template.Each employee has an ID and can request sick leave. My class is called SickLeave.Java and my GUI form is called SickGUI.java I have two text fields and three buttons. The first text field is where the employee submits their ID (which is a string) then a search for ID button searches for it. How would I start my class for this and add event handlers for an button that searches for an ID which has been entered into a text field.... I have tried and failed and keep coming up with errors.. even when I want to define the class.The class and GUI were easy, its just making my form work which is the trouble

    Have you tried adding FocusListeners to the text fields? Or ActionListeners to the buttons? The FLs could fire when you leave the TF and do a query. Likewise, the AL would initiate the button's actions.

  • Blocked thread with no events does not show up in Flight Recording

    When there is no event in a thread and the thread is blocked during the entire duration of a flight recording, the thread does not show up in the flight recording. How to check the state of such a thread from the flight recording?

    Hi,
    I am not sure I understand the question correctly, but events (like Java Blocked) are only saved to file when the thread is not longer blocked. So if you have an event that goes on during the whole recording it won't show up. It's a known limitation of flight recorder.
    If you are really desperate to find out the state of the thread you could look at the Method Profiling events that samples the thread.
    1) In the Event Types remove all the events that are checked.
    2) Check the Method Profiling Sample.
    3) Go to Events-> Threads. Select the thread you are interested in
    4) Right click and select Operative Set -> Set Selection
    5) Go to Events -> Log and check Show only Operative Set
    6) Click on an event in the log and look at Event Attributes below. There is a field called Thread State which will tell you the state thread.
    That's the best that you could do.
    Erik

  • GUI events

    I am currently working on an application that allows users to chat. On the client side i have two modules : one that handles the networking part of the app and another one for the GUI. My question is : what's the best way to interconnect these two modules? Is there some sort of event queue class that i can use so that
    when the networking module receives a message, it notifies the GUI module? I would also use this the other way : when the user wants to send a message it
    clicks a button on the GUI, the GUI module notifies the net module that it has to send a message. I was wondering if there is some way of making this in an
    event based fashion?
    Thanks in advance,
    Faur Andrei

    try moving dealNow() from start(), to after fillDeck() in init()
    (if the graphics you're waiting on are in fillDeck()?)

  • Non-GUI events

    Hi there.I'm looking for a good tutorial regarding how an object can 'throw' an event to be caught by another object which listens on the source object. If anyone knows where I can find one or how it's done, I'll thank him foe sharing the info.

    You can take a look at how it is done for Beans. There is a utility class in the API called PropertyChangeSupport that you may be able to use directly in your classes:
    http://java.sun.com/j2se/1.4.1/docs/api/java/beans/PropertyChangeSupport.html
    You should also try searching for "oberver observable pattern" on Google.

Maybe you are looking for

  • Printing: The outputs print on a printer other than that specified on the u

    We are using activity profile on the shipment to trigger outputs at different statuses set on the shipment document. In order to have the output trigger based on activity profile we need to have the timing for these output types set to “3”. Now the o

  • Windows 7 Bootcamp question

    Hello when i was trying to install it i did broke the dvd and now i cant install it but i got a copy in my usb device of the dvd , can someone tell me how to install via usb ? or i have to get a new dvd ??

  • No broadband light on hub, nearly 3 weeks...

    I have arrived at this forum as it seems to be the only place BT problems are resolved and I'm at the end of my patience. My broadband activation date was 16th April 2013 and as yet the broadband light has remained off. I've wasted time and money try

  • I Need  Matrix Report Template for XML

    can any one give me matrix report tample for XML Edited by: Kamran Riaz on Mar 21, 2009 12:13 AM

  • How to recover IDSM-2 password (without know any password)

    Hi, We have a IDSM-2 system card in 6500 system. Unfortunately, we lost tracking the login/password. I have read Cisco doc# 13837. It req to know either admin username/password or service username/password to do password recovery. I do not have those