How can I stop a program until a button will be clicked

I have a class that create a JTable and in this class I have two columns, the first culumns has the name of the variables an the second column has a checkbox to select the correponding variable.this JTable is created from a vector originating in other class. I need obtain a vector of integers with the number of the variable selected after the JButton will be clicked. For this i create a method called EspererSeleccion. This is the class
import javax.swing.table.AbstractTableModel;
import java.awt.*;
import java.awt.event.*;
import javax.swing.table.TableColumn;
import javax.swing.border.Border;
import java.util.*;
import javax.swing.*;
import java.lang.Integer;
public class MiTabla extends JFrame implements ActionListener
//Variables de Instancia
private boolean DEBUG = true;
public boolean TERMINA=false;
public Vector Valores=new Vector(1,1);
//Constructor de objetos de la clase MiTabla
public MiTabla()
super("Variables");
Border empty;
MiModelodeTabla myModel = new MiModelodeTabla();
JTable table = new JTable(myModel);
table.setPreferredScrollableViewportSize(new Dimension(300, 200));
TableColumn column=null;
column = table.getColumnModel().getColumn(0);
column.setPreferredWidth(220);
column = table.getColumnModel().getColumn(1);
column.setPreferredWidth(80);
//Crea el scroll pane y agrega la tabla en el.
JScrollPane scrollPane = new JScrollPane(table);
empty= BorderFactory.createEmptyBorder();
JButton boton=new JButton("Aceptar Seleccion");
boton.setBorder(empty);
boton.addActionListener(this);
getContentPane().setLayout(new BorderLayout(100,0));
getContentPane().add(scrollPane, BorderLayout.CENTER);
getContentPane().add(boton, BorderLayout.SOUTH);
addWindowListener(new WindowAdapter()
public void windowClosing(WindowEvent e)
setDefaultCloseOperation(HIDE_ON_CLOSE);
dispose();
//System.exit(0);
//clase MiModelodetabla
class MiModelodeTabla extends AbstractTableModel
MiVector v=llamaVector();
int numElementos=v.size();
private int i,j;
public final Object[][] data=new Object[numElementos][2];
final String[] columnNames = {"Variable",
"Seleccion"};
public MiModelodeTabla()
CreaListas();
public void CreaListas()
for (i=0; i<numElementos; i++)
data[0]=v.elementAt(i);
for (j=0; j<numElementos; j++)
data[j][1]=new Boolean(false);
public MiVector llamaVector()
MiVector V1=new MiVector();
v=V1.addElementos();
return(v);
public int getColumnCount()
return columnNames.length;
public int getRowCount()
return data.length;
public String getColumnName(int col)
return columnNames[col];
public Object getValueAt(int row, int col)
return data[row][col];
public Class getColumnClass(int c)
return getValueAt(0, c).getClass();
public boolean isCellEditable(int row, int col)
if (col < 1)
return false;
else
return true;
public void setValueAt(Object value, int row, int col)
data[row][col] = value;
fireTableCellUpdated(row, col);
if (DEBUG)
String s=new String("true");
Integer I=new Integer(row);
String S=value.toString();
if(s.equals(S))
Valores.addElement(I);
else
Valores.remove(I);
value=(Object)value;
public void EsperarSeleccion()
while (TERMINA==false)
int i=0;
TERMINA=false;
public void actionPerformed(ActionEvent e)
TERMINA=true;
dispose();
and this is the method that create the JTable but when i call the method EsperarSeleccion the program fail and the JTable is not visible only the frame that contains It.
How can I do to stop the program or the actions until the JButton will be clicked using and other method diferent from the EsperarSelection method
Vector leeVariablesRelevantes ()
System.out.println ("Variables relevantes");
MiTabla frame = new MiTabla();
frame.pack();
frame.setVisible(true);System.out.println("El vector tiene "+frame.Valores.size()+" elementos");
int i;
for (i=0; i<frame.Valores.size(); i++)
System.out.println("El elemento "+i+" de el Vector es: "+frame.Valores.elementAt(i));
System.out.println();
return frame.Valores;

Say,Class A contains JTable and in Class B you wish to acess the vector which contains the things required by you.
First you have to get the reference of Class B in Class A.
It can be done in the following way.
In Class B ,you create a static method like this.
public static ClassB getObject()
  return this;
}Now you can get the Class B's object easily via this method.
Again in Class B , you write a method which will handle your requirment.(Let this method name be doThings( Vector vector))
Now in Class A's actionPerformed() ,when the buton is pressed ,just call doThings() and pass the vector.

Similar Messages

  • PSE remains active in background after exit. How can I stop the program completely?

    PSE remains active in background after exit. How can I stop the program completely?
    Is there any command line option to force PSE to stop completely after exiting the GUI?
    Opening the Windows Task Manager and killing the PSE process is not a solution!
    (Context: I want to start PhotoshopElementsEditor.exe from another program with an image filename as command line argument. This other program waits in background until PhotoshopElementsEditor.exe has finished and pops up again after that. Since PhotoshopElementsEditor.exe continues to run silently in background, the other program will never come back.)

    Hi - having the same problem with PSE process not ending on exit. Have you had any luck in resolving the issue?
    Any advice would be appreciated. TIA

  • In Lion, running on an i MAC (late 2006), how can I stop certain programs from automatically starting up when I start my MAC?

    In Lion, running on an I MAC, (late 2006), how can I stop certain programs (iTunes, Word) from automatically starting up when I start the computer?

    Any application that is open when you shut down will re-open when you restart unless you deselect this when shutting down/restarting:
    Also check System Preferences>Users & Groups>Login items tab and make sure there's nothing listed there that you don't want launched.

  • How can I stop the program from going through all of the text previously put in.  It is making the process very slow.

    How can I stop the program from going through all of the text previously put in.  It is making the process very slow. 

    while True:
    and just indent everything else under it
    Ends when you press ^C.
    if you wish to have a way to break out of the loop, say, when you press enter at the VPC number without entering anything, add the following after your vpc input:
    if not vpc:
    break
    which will break out of the while loop and end your program.
    Last edited by buttons (2007-12-14 22:03:06)

  • How can i stop open new tab on safari when i click  on link or anything ??

    how can i stop open new tab on safari when i click  on link or anything ??

    Check the links below for options to remove the Adware.
    The Easy, safe, effective method:
    http://www.adwaremedic.com/index.php
    If you are comfortable doing manual file removals use the somewhat more difficult method:
    http://support.apple.com/en-us/HT203987
    Also read the articles below to be more prepared for the next time there is an issue on your computer.
    https://discussions.apple.com/docs/DOC-7471
    https://discussions.apple.com/docs/DOC-8071

  • How can i stop reopening program files ?

    When my Vectorworks 2011 stops (from a bug) and i want to restart it, Lion opens all the previous drawings !
    The Imac can't restore all that amount of info and simply stops the program
    I just want to start over again with an empty page ! IS IT THAT STRANGE ???
    Please help me out.

    restart from your applemenu.
    You will get a window in wich you can restart or not.
    Undo the marker for open windows again when logging in again.
    Maby it helps.
    succes with it.

  • Teaching Myself Python. How Can I Stop The Program From Closing :)

    I wrote a program today that will log into a router here at work and check if the line protocols are up and if i can see thir mac address.  If i run it from the IDLE program it works fine.  When i run it as just crosnet.py it runs fine but closes before i can see the output.  I imagine there is some simple line that will have run and just sit?  Or even better, loop back to the beginning and wait for me to give it a new number to then telnet with.
    #import getpass
    import sys
    import telnetlib
    HOST = "111.111.111.111"
    password = "password"
    vpc = raw_input("Enter The VPC Number: ")
    #password = getpass.getpass()
    tn = telnetlib.Telnet(HOST)
    #tn.read_until("login: ")
    #tn.write(user + "\n")
    #if password:
    tn.read_until("Password: ")
    tn.write(password + "\n")
    #tn.write("sh int atm6/0.vpc\n")
    tn.write("sh int atm6/0." + str(vpc) + "\n")
    tn.write("sh arp | in " + str(vpc) + "\n")
    #tn.write("exit\n")
    print tn.read_all()
    Sorry the code is bad, dont know python and i was shown a outline of how to telnet and adjusted it to my needs.

    while True:
    and just indent everything else under it
    Ends when you press ^C.
    if you wish to have a way to break out of the loop, say, when you press enter at the VPC number without entering anything, add the following after your vpc input:
    if not vpc:
    break
    which will break out of the while loop and end your program.
    Last edited by buttons (2007-12-14 22:03:06)

  • How can I stop laptop freeze/spinning wheel every time I click or type etc?

    I sporadically get momentary freeze and or spinning wheel when I try to do anything on the laptop. Sometimes it works fine but the majority of the time it stops on every click. The problem has been persistant for a week or two, possibly related to a mavericks update.
    The dock sometimes doesn't work either - it is unresponsive, an appl will bounce but not open.
    This occurs enough to be very frustrating and gets in the way of my work.
    Model Name:          MacBook Pro
      Model Identifier:          MacBookPro9,2
      Processor Name:          Intel Core i7
      Processor Speed:          2.9 GHz
      Number of Processors:          1
      Total Number of Cores:          2
      L2 Cache (per Core):          256 KB
      L3 Cache:          4 MB
      Memory:          8 GB
      Boot ROM Version:          MBP91.00D3.B08
      SMC Version (system):          2.2f44
      Serial Number (system):          C0******TY4
      Hardware UUID:          ******************
      Sudden Motion Sensor:
      State:          Enabled
    I backed up all my files, emptied the hard drive and uninstalled/reinstalled Mavericks.
    This created another problem - the laptop would not boot up and I got a flashing question mark in a folder on the screen. Eventually I was able to reinstall Lion which then fixed that problem. For a short while there were no problems of latency either (maybe 20 minutes).
    I have done disc scans/repairs and there were no problems there. I did an extensive hardware scan as well and no problems were detected.
    I don't know much about Apple computers - I've only had this for just under two years and I have had no problems so I'm quite illiterate regarding how to repair it or scan for problems. Any pointers in the right direction would be appreciated.
    <Edited by Host>
    Incidentally I have had no freezes since starting to write this post - Lion seems to be more stable than Mavericks was.

    Launch the Console application in any of the following ways:
    ☞ Enter the first few letters of its name into a Spotlight search. Select it in the results (it should be at the top.)
    ☞ In the Finder, select Go ▹ Utilities from the menu bar, or press the key combination shift-command-U. The application is in the folder that opens.
    ☞ Open LaunchPad. Click Utilities, then Console in the icon grid.
    The title of the Console window should be All Messages. If it isn't, select
    SYSTEM LOG QUERIES ▹ All Messages
    from the log list on the left. If you don't see that list, select
    View ▹ Show Log List
    from the menu bar at the top of the screen.
    Click the Clear Display icon in the toolbar. Then try the action that you're having trouble with again. Select any messages that appear in the Console window. Copy them to the Clipboard by pressing the key combination command-C. Paste into a reply to this message by pressing command-V.
    ☞ The log contains a vast amount of information, almost all of which is irrelevant to solving any particular problem. When posting a log extract, be selective. A few dozen lines are almost always more than enough.
    Please don't indiscriminately dump thousands of lines from the log into this discussion.
    Please don't post screenshots of log messages—post the text.
    ☞ Some private information, such as your name, may appear in the log. Anonymize before posting.

  • How can I stop the sales calls?

    A little over a week ago, Verizon called me to ask me to upgrade my DSL to FiOS.  I told them I'd review it and contact them if I wanted to proceed.
    Saturday morning, they called me to ask me to upgrade my DSL to FiOS.  I told them I wasn't interested.
    Saturday afternoon, they called me to ask me to upgrade my DSL to FiOS.  I told them again I wasn't interested.
    Saturday afternoon, they called me AGAIN (yes, 3 sales calls in one day) to ask me to upgrade my DSL to FiOS.  I told them AGAIN I wasn't interested, and that they'd called me three times that day.
    I emailed a complaint, got a non-response with an invalid link asking for more information.
    This morning, they called me yet again asking me to upgrade my DSL to FiOS.  The sales rep said he could not connect me to customer service, and I kind of went off on him.
    At this point, the only thing I can think of is to see if I can get my phone and DSL services thorugh another company,  Verizon seems to have been bought out by a consortium of Nigerian bankers.

    beatio wrote:
    how can I stop the program from resizing, zooming in and out, of my photos? I want it to create stop action.
    in the Project Properties (command-j), you can tell iM how to handle the initial photo placement method on import. out-of-the-box, iM is set to Ken Burns, but 'fit' should be your setting.
    keep in mind:
    iMovie doesn't allow a clip-length of 1-frame, which is needed for smooth action for stop-motion.
    specialized tools as Boinx' iStopMotion (AppStore, 40$) or the free FrameByFrame do perhaps a (much) better job

  • How do I stop running programs.

    I am using my Imac for recording purpose so I would like to stop the programs which are not needed.that may be running in the background.On my pc I go to the tak manager & find what is running.Is there a task manager type thing where I can go & stop running programs that use up CPU & cuase clicks & noises during recording.

    You can use the Activity Monitor located at the Applications/Utilities.  You can also access this by simultaneous pressing on your keyboard the following keys: Command Option and Esc.  That would prompt you to a window called Force Quit.  There you would see  applications that are running.
    Another option is like what is stated above, that you can see in your Dock what applications are running.  You would see a little blue shining circle/oval below the open applications.  Just left click for 1-2 sec the icon of the program you want to close and click on Quit.
    Hope this would help you and good luck with your recording!

  • TS3899 I am getting 144+ emails a day from mail administrator. I do not recognize  these names nor did I send them an email. How can I stop these???

    I am getting 144+ emails a day from mail administrator. I do not recognize  these names nor did I send them an email. How can I stop these???

    We will need more information to be able to assist you.
    These message yoy are receiving are probably just a particular type of spam.  However it is also possible (unlikely) that your email account is being used to send spam, and that these are the bounce messages.
    To tell the difference, you need to look at the email headers.  Open the message, then go to the View menu and select Message -> All Headers.
    Select the text and post it back here (remembering to obscure your own email address first).
    Cheers,
    Rodney

  • How can I stop iMovie from making thumbnails of clips from past projects when opening the program to digitize new clips for new project. i have looked in the preferences and couldn't figure out what to disable.

    How can I stop iMovie from making thumbnails of clips from past projects when first opening the program to digitize new clips for a new project. It takes forever for it and is very annoying. I have looked in the preferences and couldn't figure out what would disable this problem.

    You do not need to move your cursor much when pressing the mouse button to cause the tab to tear-off/tear-away into a new tab. No "sensitivity" setting that I am aware of. The tab in the new window can be dragged back to the original window.
    To disable the feature, install this: https://addons.mozilla.org/en-US/firefox/addon/bug489729-disable-detach-and-t/
    *Read the information on the above page
    *Set options for the add-on: Add-ons > Extensions, click Options next to the specific Extension (the 2 options are defined/explained in the above page).
    '''If this reply solves your problem, please click "Solved It" next to this reply when <u>signed-in</u> to the forum.'''

  • Better privecy does not work with windows vista home prem. what other program removes LSO'S AND HOW can I stop trackers?

    Question
    better privacy does not work with windows vista home prem. what other program removes LSO'S AND HOW can I stop trackers? edit
    Details

    As a temporary workaround, I believe this Adobe management page allows you to clear your "Flash cookies": [http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager07.html Adobe - Flash Player : Settings Manager - Website Storage Settings panel] (hosted on macromedia.com -- Macromedia was the original developer of Flash).
    Regarding the script error, if I'm reading the script correctly, it is related to accessing your Flash cookies directory. It seems the publisher's support forum is not currently available for searching, but that might be a good next step.
    In the meantime, could you check whether the script has the correct location for your Flash cookies directory? If you can't access Tool > BetterPrivacy, you could check here:
    (1) In a new tab, type or paste '''about:config''' in the address bar and press Enter. Click the button promising to be careful.
    (2) In the filter box, type or paste '''bpr''' and pause while the list is filtered
    (3) There should be a bolded setting named '''extensions.bprivacy.DataDir''' which looks approximately like the following:
    C:\Users\''yourWindowsUsername''\AppData\Roaming\Macromedia
    Do you have a similar value? If you paste the path used by BetterPrivacy into a Windows Explorer window, does it open? Also, click a couple levels in the folder, can you see:
    Flash Player \ #SharedObjects
    If the value is wrong, right-click the wrong value and choose Reset. BetterPrivacy should update the value the next time you try to access it.
    If the value is blank, you could try inserting a sensible value and see whether that helps.
    Any luck?

  • What does this mean, and how can I stop this message from coming up constantly in my e-mail program? "Alert: Firefox doesn't know how to open this address, because the protocol (htpixel.adsafeprotectedtp) isn't associated with any program."

    This just started last night, and it seems to be affecting the functioning of my e-mail program (Yahoo mail). How can I stop it?

    Perform the suggestions mentioned in the following articles:
    * [https://support.mozilla.com/en-US/kb/Template:clearCookiesCache/ Clear Cookies & Cache]
    * [[Troubleshooting extensions and themes]]
    Check and tell if its working.
    May not be related to your problem but some of your Firefox Plugins are out-dated
    * Update All your Firefox Plugins -> https://www.mozilla.org/en-US/plugincheck/
    * '''NOTE: When Downloading Plugins Update setup files, Remove Checkmark from Downloading other Optional Softwares with your Plugins (e.g. Toolbars, McAfee, Google Chrome, etc.)'''

  • HT1349 At Start up on OS Lion 10.7 it opens a lot of program windows. How can I stop this happening?

    At Start up on OS Lion 10.7 it opens a lot of program windows How can I stop this happening?

    Not sure what your question has to do with the AirPort Express, AirPort Extreme, or Time Capsule.
    But, to try to help....
    Choose Shut Down on your Mac from the Apple icon
    Remove the check mark from the box
    Click Shut Down
    e
    For any additional questions.....please post in the correct Mac OS X v10.7 Lion support area.

Maybe you are looking for