Example of WAIT and CONTINUE using checkBox and thread and getTreeLock()

I had so much trouble with this that I descided to
post if incase it helps someone else
// Swing Applet example of WAIT and CONTINUE using checkBox and thread and getTreeLock()
// Runs form dos window
// When START button is pressed program increments x and displys it as a JLabel
// When checkBox WAIT is ticked program waits.
// When checkBox WAIT is unticked program continues.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.*;
import java.io.*;
public class Wc extends JApplet {
Display canvas;//drawing surface is displayed.
Box buttonPanel;
Box msgArea;
public static JButton button[] = new JButton [2];
public static JCheckBox checkBox[] = new JCheckBox[2];
public static JLabel msg[] = new JLabel [2];
String[] buttonDesc ={"Start","Quit"};
public static final int buttonStart = 0;
public static final int buttonQuit = 1;
String[] checkBoxDesc ={"Wait"};     
public static final int checkBoxWait = 0;
public boolean wait;
public Graphics g;
//================================================================
public static void main(String[] args){
Frame f = new Frame();
JApplet a = new Wc();
f.add(a, "Center"); // Add applet to window
a.init(); // Initialize the applet
f.setSize(300,100); // Set the size of the window
f.show(); // Make the window visible
f.addWindowListener(
new WindowAdapter(){
public void windowClosing(WindowEvent e){System.exit(0);}
}// end main
//===================================================
public void init() {
canvas = new Display();
setBackground(Color.black);
getContentPane().setLayout(new BorderLayout(3,3));
getContentPane().add(canvas, BorderLayout.CENTER);
buttonPanel = Box.createHorizontalBox();
getContentPane().add(buttonPanel, BorderLayout.NORTH);
int sbZ;
// add button
button[0] = new JButton(buttonDesc[0]);
button[0].addActionListener(canvas);
buttonPanel.add(button[0]);
button[1] = new JButton(buttonDesc[1]);
button[1].addActionListener(canvas);
buttonPanel.add(button[1]);
// add checkBox
sbZ=0;
checkBox[sbZ]=new JCheckBox(checkBoxDesc[sbZ]);
checkBox[sbZ].setBackground(Color.white);
checkBox[sbZ].setOpaque(true);
checkBox[sbZ].addActionListener(canvas);
buttonPanel.add(checkBox[sbZ]);
msgArea = Box.createVerticalBox(); // add message
sbZ=0;
msg[sbZ]=new JLabel("1",JLabel.LEFT);
msg[sbZ].setOpaque(true);
msg[sbZ].setBackground(Color.black);
msg[sbZ].setForeground(Color.red);
msgArea.add(msg[sbZ]);
getContentPane().add(msgArea, BorderLayout.SOUTH);
} // end init();
//===================================================
public void stop(){canvas.stopRunning();}
//===================================================
// The following nested class represents the drawing surface
// of the applet and also does all the work.
class Display extends JPanel implements ActionListener, Runnable {
Image OSI;
Graphics OSG; // A graphics context for drawing on OSI.
Thread runner; // A thread to do the computation.
boolean running; // Set to true when the thread is running.
public void paintComponent(Graphics g) {
if (OSI == null) {
g.setColor(Color.black);
g.fillRect(0,0,getWidth(),getHeight());
else {g.drawImage(OSI,0,0,null);}
}//paintComponent
public void actionPerformed(ActionEvent evt) {
String command = evt.getActionCommand();
if (command.equals(buttonDesc[buttonStart])) {
startRunning();
if (command.equals(buttonDesc[buttonQuit])) {
stopRunning();
if (command.equals(checkBoxDesc[checkBoxWait])){
System.out.println("cb");
if (checkBox[checkBoxWait].isSelected() ) {
wait = true;
System.out.println("cb selected twait "+wait);
return;
wait = false;
synchronized(getTreeLock()) {getTreeLock().notifyAll();}
System.out.println("cb selected fwait "+wait);
} // end command.equal cb wait
} //end action performed
// A method that starts the thread unless it is already running.
void startRunning() {
if (running)return;
// Create a thread that will execute run() in this Display class.
runner = new Thread(this);
running = true;
runner.start();
} //end startRunning
void stopRunning() {running = false;System.exit(0);}
public void run() {
button[buttonStart].setEnabled(false);
int x;
x=1;
while(x>0 && running){
x = x + 1;
msg[0].setText(""+x);
try{SwingUtilities.invokeAndWait(painter);}catch(Exception e){}
//importand dont put this in actionPerformed
if (wait) {
System.out.println("run "+wait);
synchronized(getTreeLock()) {
while(wait) {
System.out.println("while "+wait);
try {getTreeLock().wait();} catch(Exception e){break;}
} //end while(wait)
} // end sync
} // end if(wait)
} // endwhile(x>0)
stopRunning();
} // end run()
Runnable painter = new Runnable() {
public void run() {
Dimension dim = msg[0].getSize();
msg[0].paintImmediately(0,0,dim.width,dim.height);
Thread.yield();
}//end run in painter
} ; //end painter
} //end nested class Display
} //end class Wc

I just encountered a similar issue.  I bought a new iPhone5s and sent my iPhone4s for recycling as it was in great shape, no scratches, no breaks, perfect condition.  I expected $200 and received an email that I would only receive $24.12.  The explanation was as follows:  Phone does not power on - Power Supply Error.   Attempts to discuss don't seem to get past a customer service rep that can only "escalate" my concern.  They said I would receive a response, but by email.  After 4 days no response.  There is something seriously wrong with the technical ability of those in the recycling center.

Similar Messages

  • When I use dynamic link how do I continue using it after closing and reopening a project?

    Hi
    Im very new to AF
    I cant seem to find the answer to this in any tutorials.
    When I using dynamic link, how do I continue using it after closing and reopening a perm pro project?
    Thanks
    Philip

    Hi Kevin
    Thank you very much for such a quick reply.
    I actually figured it out. As usual it was fairly obvious solution.
    I opened both project at the same time.
    Thanks again and sorry for waisting your time.
    R
    Philip

  • Turn off phone capability of iPhone and continue using cps and cellular data?

    Can I turn off phone capability of any iPhone and continue using cps and cellular data, practically using the device as iPad? Is this going to be possible with iOS8 or iPhone 6 Plus?

    This could be what you are looking for:
    Using an iPhone without a wireless service plan

  • My Macbook Pro (early 2011) has 4 gig of memory and is using all of it and running slow.

    My (early 2011) MacBook Pro has 4 gig of memory and is using all of it and running slow.  I am planning to double memory, but any ideas about why it's using all that memory?  (Yosemite 10.10.2). 

    When you see a beachball cursor or the slowness is especially bad, note the exact time: hour, minute, second.  
    These instructions must be carried out as an administrator. If you have only one user account, you are the administrator.
    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 and start typing the name.
    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.
    Each message in the log begins with the date and time when it was entered. Scroll back to the time you noted above.
    Select the messages entered from then until the end of the episode, or until they start to repeat, whichever comes first.
    Copy the messages 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 it useless for 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.

  • Have tried to install icloud 4.0 for windows and again it does not allow syncing with outlook 2013 calendar and contact using windows 8.1 and IOS 8.02 (unexpected error)? I thought itunes 12.0 and icloud 4.0 would solve issue but still same result.

    I have tried to install icloud 4.0 for windows and again is does not allow syncing with outlook 2013 calendar and contact, using windows 8.1 and IOS 8.02 (get - unexpected error)?

    Having same issues. had been syncing every few days with outlook 2007 contacts and calendar but since updated to 4.0.2 and latest itunes I get an error that it is unable to sync. I can't seem to find any solution.

  • Hey plz help me out!!  i am using macbook pro 10.5.8..... and was using photobooth...and then after some time i opened it and there was no green light on cam, and it displayed nothing! plz tell me how to fix it! i want to see my face again!!! plz help me

    hey plz help me out!!  i am using macbook pro 10.5.8..... and was using photobooth...and then after some time i opened it and there was no green light on cam, and it displayed nothing! plz tell me how to fix it! i want to see my face again!!! plz help me

    iSight troubleshooting
    http://support.apple.com/kb/HT2090

  • I own an ipod touch 5th gen ios 7.1 and while using it suddenly black and white vertical stripes appeared on the screen and now it wont turn on!!!what should i do?

    i own an ipod touch 5th gen ios 7.1 and while using it suddenly black and white vertical stripes appeared on the screen and now it wont turn on!!!what should i do?

    Try:                                               
    - iOS: Not responding or does not turn on           
    - Also try DFU mode after try recovery mode
    How to put iPod touch / iPhone into DFU mode « Karthik's scribblings
    - If not successful and you can't fully turn the iOS device fully off, let the battery fully drain. After charging for an least an hour try the above again.
    - Try another cable       
    - Try on another computer                                                       
    - If still not successful that usually indicates a hardware problem and an appointment at the Genius Bar of an Apple store is in order.
      Apple Retail Store - Genius Bar                              

  • I will combine Win 8.1 and Mac system in Creative Cloud program. Is that possible in same license. Start the work in Mac and continue with Win 8.1 and do presentation on Ipad ???

    I will combine Win 8.1 and Mac system in Creative Cloud program. Is that possible in same license. Start the work in Mac and continue with Win 8.1 and do presentation on Ipad ???

    Cloud License allows 2 activations http://www.adobe.com/legal/licenses-terms.html
    -Install on a 2nd computer http://forums.adobe.com/thread/1452292?tstart=0
    -Windows or Mac does not matter... 2 on the same operating system, or 1 on each
    Check this link to see what is available for an ipad
    -http://www.adobe.com/products/catalog/mobile._sl_id-contentfilter_sl_catalog_sl_mobiledevi ces.html

  • IPad 2 continually using wifi when sleeping and on.

    How can I find the program using the wifi when the iPad 2 is sleeping or on? I have closed all apps and restarted the ipad. iCloud is off. Soon as you turn it on it will connect to wifi and start using the internet connection. (uploading or download)

    Artplumb wrote:
    Soon as you turn it on it will connect to wifi and start using the internet connection. (uploading or download)
    It's supposed to do that. You can turn off WiFi if you don't want it to do that.

  • Need help getting handoff and continuity working on iPhone 6 and iPAd

    I currentky have a first gen iPad mini and iPhone 6 Plus on the verizon network. I have been wanting to use the handoff features but don't have some of the options in the settings menu. First, do you have to have a Mac to use continuity? If not, the option to turn on continuity under messages in the settings menu isn't listed for me, so I cant generate the code to type into my iPad. Same goes for calling. I don't have the option in the phone settings to turn continuity on. Looking for some advice, thank you.

    Hi there Jfalzon82,
    Welcome to Apple Support Communities.
    It sounds like you’re running into an issue setting up Continuity with your iPhone 6 Plus and iPad mini, and you’re wondering if you need a Mac to setup them up properly. You don’t need a Mac. Take a look at the article linked below which will walk you through the process of setting up Continuity on your devices.
    Connect your iPhone, iPad, iPod touch, and Mac using Continuity - Apple Support
    Phone calls
    With Continuity, you can make and receive cellular phone calls from your iPad, iPod touch, or Mac when your iPhone is on the same Wi-Fi network.
    To make and receive phone calls, here's what you need:
    Sign in to the same iCloud account on all your devices, including your Mac.
    Your iPhone and your iPad or iPod touch need to use iOS 8 or later. Your Mac needs to use OS X Yosemite.
    All devices must be on the same Wi-Fi network.
    All devices must be signed in to FaceTime using the same iCloud account. This means any device that shares your Apple ID will get your phone calls. Look below for instructions on how to turn off iPhone cellular calls.
    Wi-Fi Calling needs to be off. Go to Settings > Phone. If you see Wi-Fi Calling, turn it off.
    To use Continuity for SMS and MMS with your iPhone and your Mac, iPad or iPod touch
    Your iPhone, iPad, and iPod touch need to use iOS 8.1, and your Mac needs to use OS X Yosemite.
    Sign in to iMessage on your iPhone, your other iOS devices, and your Mac using the same Apple ID.
    On your iPhone:
    Go to Settings > Messages > Send & Receive > You Can Be Reached By, and add a check to both your phone number and email address.
    Go to Messages > Text Message Forwarding, and enable the device(s) you would like to forward messages to.
    Your Mac, iPad, or iPod touch will display a code. Enter this code on your iPhone to verify the SMS feature.
    So long,
    -Jason

  • I changed my main email on my apple ID and now it doesn't work and still uses my old one and with my new and old email my password doesn't work

    I changed my main email on my apple ID now when I try sign in with the new email it doesn't work and neither does my old one so I don't know what happened, any help?... I made a new apple ID and on my iPod it tries to use my old one and I can't change it to my new apple ID I've gone on to settings and iTunes and App Store and changed it to my new apple Id yet when I buy apps or try update them it uses my old apple ID I don't know what to do any help??

    - Apps are locked to the account that purchased them.
    - To update apps you have to sign into the account that purchased the apps. If you have apps that need updating purchased from more than one account you have to update them one at a time until the remaining apps were purchased from one account.
    If you can't log into Settings>iTunes and App stores with your new ID them mean there is a problem. Try restting the password and try to sign in again.
    iTunes Store: Retrieving and changing passwords (Apple ID)
    Can you sign in with the new ID on your computer?
    Last, contact iTunes.
    Apple - Support - iTunes - Contact Us

  • Apache 1.3.27 with plugin WL7  and concurrent use of WLS5.1 and WLS7.0 SP1 cluster server

    We plan to use WLS 5.1 and WLS 7.0 for different applications (and
    clusters), but with the same Apache Webservers.
    The installation of the Apache HTTP Server Plug-In is documented in
    http://e-docs.bea.com/wls/docs70/plugins/apache.html, but I could not
    find information about downward compatibility from the mod_wl.so. Can we
    upgrade the Plugin to 7.0 to serve both, the WLS 5.1 and WLS 7.0 ?

    You are in unchartered territory. But check the common "gotcha" and
    make sure that all the Oracle environment variables are set in the
    shell that starts Apache. Load the script <?php phpinfo(); ?> in a
    browser and see that whatever variables you need are set in the
    Environment section. See the section "Oracle Environment Variables
    for Connections" in Underground PHP and Oracle Manual
    I suspect it would be beneficial to migrate the PHP code to oci8.
    Check table 16-1 in Underground PHP and Oracle Manual for the mapping
    between 'oracle' and 'oci8' functions.
    -- cj

  • Customizing FD01 and FB70 using SAP PS Class and Characteristics

    Hello SAP Experts
    I have the following issue:
    My client has a requirement where we need to customize the Customer Master  (FD01) screen and the Invoice Posting Screen (FB70). A few additional fields have to be added by creating a separate tab. I was intending to take Abaper's help and do this using user exits but I have been suggested by the cleint to use SAP PS Class and Characteristics feature to do this. Can someone please throw some light on this feature and how can i create custom fields on FD01 and FB70 screens. Is there a way we could customize these screens using PS characteristics. Your opinions would be much appreciated.
    Please kindly chip in your ideas
    Regards,
    Nik

    Joao Paulo,
    Thank you for the response. I have tried to obtain some info from OSS but no luck. Tried all means but there is limited information available.
    Nik

  • My wife has ALS and no use of her hands and virtually no voice.

    My wife has no use of her hands and virtually no voice, she can turn on her iPhone 3G with a Bluetooth device that has a large button connected to it that she can touch with her arm to turn on the phone ready to redial the last number typed in......however she cannot activate the "Swipe to Unlock" feature?     Is there an App or any way I can get rid of the Swipe to Unlock button or replace it with a Large Button she can hit,  we have tried the Security code method with no sucess.
    Any suggestions from the experts out there very welcome.    ( There's an app called Nose Dial with two large buttons in the German iTunes store but I cannot get it easily from Canada)  Dave

    Sorry to hear of your wife's issues with using an iPad
    I can't help specifically but have you seen this help
    http://support.apple.com/kb/HT5018
    You may find something here you could use
    You could also consider calling Apple in Canada to see if they can link you to an accessibility team in Apple
    Good luck

  • HT4993 I used and have used my yahoo email and that email address for my calendar and suddenly dates are disappearing why?

    Dates in my calendar have disappeared?

    The path may be long and tedious, grasshopper.
    Actually, the download of Office 2011 for Mac probably was not legal and may have contained bugs or other things meant to make it unstable, or invite a host of issues. The usual path would be Office 2011 for Mac on DVD so you could reinstall it and add the extras from the disc as needed; or fix the installation later on. The updates for security were downloads from Microsoft servers. You'd need a legitmate version with pass code.
    Options for Mac and office-like application suites include Libre Office, NeoOffice, and these run free. The latter supports up to Mavericks. 10.9.1 now. They have a word, excel, and other parts a lot like the real office.
    If you have a working clone of the system prior to installing the Office 2011 for Mac download and any subsequent and perhaps unseen extras, you could revert to it simply by restarting the computer from the clone, where it resides in externally enclosed self-powered hard disk drive, of a type known to support OS X clones... With ports to help work with most modern Macs. FireWire + USB. Then, clone it back w/ carbon copy cloner.
    Short of that, perhaps someone will see your post and offer some indepth method of hunting down bugs via use of Console logs; and maybe booting into Terminal utility to use unix code. It can be rather involved. Maybe Linc Davis will offer some detailed reply that will invite you to read carefully and try it.
    I've given up using computers long ago.
    A pet raven has been taught to write this.
    Good luck & happy computing!

Maybe you are looking for

  • ?ipod no longer turns off by pressing and holding play/pause on click whee

    ipod had turned off before, but now cannot turn it off. It continues to stay on. I've tried to use hold switch to see if that helps, but ipod still won't turn off, and it uses up my battery. hold play/pause button doesn't seem to work?

  • Forms 6i

    i have following queries- 1. i have made forms using forms . i want to test these forms on clients site using forms .fmx files only.how can i do this 2.to call forms using call_form how can i avoid hard coding so that the software can be easily deplo

  • Lenovo U410 Intel SRT technology

    Good day. More recently became the proud owner Ultrabook Lenovo U410 core i3. Out of the box I was a Windows 8 64-bit. Technology Intel Smart Response (hybrid drive) has not been implemented. I decided to unleash the full potential of the laptop. To

  • Hairline cracks near the power button :-(

    Hello everyone!!  this is my first post here... so sad that it has to be a negative one.  i dont know if someone else has posted this topic, but i dont really have time at this precise moment to check. i have a small hairline fracture just about the

  • CF Hash and SQL Server

    Hi, Basically,  I receive a hash of a pk and would like to compare that hash value a pk in SQL Server.  There is no stored hash value in that table.  So I have to use CF function Compare to compare while looping the whole table.  As a result, it's sl