Why won't this slide show run it compiles

import java.awt.*;
import java.applet.*;
import java.net.*;
public class SlideShow extends Applet {
  private Image[] images;
  private String[] text;
  private Label captions;
  private volatile int curFrame;
  private Thread timerThread;
  private volatile boolean noStopRequested;
  private boolean paused;
  private final Object pauseLock = new Object();
  public static void main( String[] args )
     new SlideShow();     
  private void printThreadName(String prefix) {
    String name = Thread.currentThread().getName();
    System.out.println(prefix + name);
  public void init() {
    images = new Image[3];
    text = new String[3];
    captions = new Label();
    setLayout(new BorderLayout());
    add(BorderLayout.SOUTH, captions);
    Label name = new Label("by Claude Monet");
    name.setAlignment(Label.CENTER);
    add(BorderLayout.EAST, name);
    URL fig = null;
    try {
      fig = new URL("http://developer.java.sun.com:8080/" +
                   "developer/technicalArticles/Threads/applet/");
    } catch (java.net.MalformedURLException ex) {
      System.out.println("Bad URL");
      return;
    images[0] = getImage(fig, "bordighera.jpg");
    images[1] = getImage(fig, "etretat.jpg");
    images[2] = getImage(fig, "leyden.jpg");
    text[0] = "Garden in Bordighera";
    text[1] = "Rock Arch West of Etretat";
    text[2] = "Bulbfield and Windmill near Leyden";
    printThreadName("init is ");
    startThread();
   private void startThread() {
     paused = true;
     noStopRequested = true;
     // Use this inner class to hide the public run method
     Runnable r = new Runnable() {
       public void run() {
         runWork();
     timerThread = new Thread(r, "Timer");
     timerThread.start();
     printThreadName("startThread is ");
  private void stopThread() {
    noStopRequested = false;
    timerThread.interrupt();
    printThreadName("stopThread is ");
  private void runWork() { // note that this is private
    printThreadName("run is ");
    curFrame = 0;
    try {
        while ( noStopRequested ) {
        waitWhilePaused();
        curFrame = ( curFrame + 1 ) % images.length;
        repaint();
        Thread.sleep(3000);
    } catch ( InterruptedException x ) {
      // reassert interrupt
     Thread.currentThread().interrupt();
     System.out.println("interrupt and return from run");
  private void setPaused(boolean newPauseState) {
    synchronized ( pauseLock ) {
      if ( paused != newPauseState ) {
        paused = newPauseState;
        pauseLock.notifyAll();
  private void waitWhilePaused() throws InterruptedException {
    synchronized ( pauseLock ) {
      while ( paused ) {
        pauseLock.wait();
  public void paint(Graphics g) {
    update(g);
    printThreadName("paint is ");
  public void update(Graphics g) {
    g.drawImage(images[curFrame], 0, 0, this);
    captions.setText(text[curFrame]);
    printThreadName("update is ");
  public void start() {
    setPaused(false);
    printThreadName("start is ");
  public void stop() {
    setPaused(true);
    printThreadName("stop is ");
  public void destroy() {
    stopThread();
    for (int i = 0; i < images.length; i++) {
       images.flush();
images[i] = null;
text[i] = null;
images = null;
text = null;
printThreadName("destroy is ");

w.r.t. the title of your topic: the set C of compilable programs is much
larger than the set R of programs that run correctly: |C| > |R|. This
is implies that at most n == |C|-|R| programs need some debugging.
The easiest form of debugging (oftenly overlooked) is System.out.println
which, when applied strategically, can do wonders: when two of those
printlns are inserted at point X and Y, and if at point X everything seems
to be correct while at point Y (later in time) everything seems to be rotten
to the bone, inserting another println at point (X+Y)/2 narrows down the
exact location of where the ugly bug hides from you.
kind regards,
Jos

Similar Messages

  • Why won't Firefox automatically show new Hotmail emails or easilly down load attachments when it was working a week ago?

    Why won't Firefox automatically show new Hotmail emails or easily down load attachments when it was working a week ago?

    Hotmail has been having a few hiccups lately I'm afraid.
    If you don't see any emails when you log in, or nothing appears after some time, click in the middle of the grey bar on the left which has the word "'''Inbox'''" in it. This usually causes them to magically appear for some strange reason.
    I've read on on a few blogs that Microsoft is working on the problem, but don't hold your breath.<br><br>
    If this suggestion resolves the problem for you, please click the '''Solved it''' button next to this post after you log in into the forum. This will help others searching for a solution to the same problem.
    Thanks.

  • Functions in a For Loop defining objects from an Array. . .Why Won't This Work?!

    I'm trying to put these functions into a Loop to conserve
    space. Why won't this work?
    .

    Yeah, sly one is right. You can not have the "i" inside the
    onRollOver function, what you have to do is: As the movieClip class
    is dynamic you can create a property of the movieClip which stores
    the value if the "i". And then, inside the onRollOver function, you
    have to make reference to that property.
    for (i=0; i<2; i++) {
    this.regArray
    .iterator = i;
    this.regArray.onRollOver = function () {
    showRegion(regArray[this.iterator]);
    this.regArray
    .onRollOut = function () {
    hideRegion(regArray[this.iterator]);

  • Help...Why won't this compile?

    Why won't this compile?
    Here is my code:
    import java.util.Calendar;
    import javax.swing.JOptionPane;
    public class GetAge{
    public static void main(String[] args){
    int month=Integer.parseInt(JOptionPane.showInputDialog
    (null,"Enter what month(MM) you were born:"));
    int day=Integer.parseInt(JOptionPane.showInputDialog
    (null,"Enter what day(dd) you were born:"));
    int year=Integer.parseInt(JOptionPane.showInputDialog
    (null,"Enter what year(yyyy) you were born:"));
    Calendar rightNow = Calendar.getInstance();
    int year2 = rightNow.get(Calendar.YEAR);
    int day2 = rightNow.get(Calendar.DATE);
    int month2 = rightNow.get(Calendar.MONTH)+1;
    int years = year2-year-1;
    int months = month2-month+12;
    if(day2 >= day)
       int days = day2-day;
    else
       days = day-day2+8;
    JOptionPane.showMessageDialog(null,"You are: " + years
    + " years " + months + " months and " + days + " days old.");
    }

    What you're doing is using days after the if statement; without curly braces only a valid statement is allowed.
    But if you add curly braces, days will be available only in the if block.
    So what you should do is:
    import java.util.Calendar;
    import javax.swing.JOptionPane;
    public class GetAge{
    public static void main(String[] args){
    int month=Integer.parseInt(JOptionPane.showInputDialog
    (null,"Enter what month(MM) you were born:"));
    int day=Integer.parseInt(JOptionPane.showInputDialog
    (null,"Enter what day(dd) you were born:"));
    int year=Integer.parseInt(JOptionPane.showInputDialog
    (null,"Enter what year(yyyy) you were born:"));
    Calendar rightNow = Calendar.getInstance();
    int year2 = rightNow.get(Calendar.YEAR);
    int day2 = rightNow.get(Calendar.DATE);
    int month2 = rightNow.get(Calendar.MONTH)+1;
    int years = year2-year-1;
    int months = month2-month+12;
    int days = 0;      //declare here
    if(day2 >= day)
       days = day2-day;  //...and use here
    else
       days = day-day2+8;   //..and here
    JOptionPane.showMessageDialog(null,"You are: " + years
    + " years " + months + " months and " + days + " days old.");
    }

  • Why won't adobe flash player run on my computer, even though it tlles me it has installed correctly

    Why won't adobe flash player run on my computer, even though it tlles me it has installed correctly?
    Regards, bricky3

    Thought for Today: “It may be that our prime purpose in life is simply to be kind to others.” – Source unknown.
    Hi Pat,
    Thank you for your advice – I had not tuned in to the “public forum” implications.
    Much appreciated.
    Best Regards,
    Ray Bricknell
    <mailto:[email protected]> [email protected]

  • Why won't my apps show on my main screens? The only way I can access them is by going back to the App Store and clicking open.

    Why won't my apps show on my main screens? The only way I can access them is by going back to the App Store and clicking open.

    So there are no apps at all on your home screens? Try a reset. Hold the sleep/wake and home buttons together until you see the Apple logo and then release. The phone will reboot. If you don't see anything after that, take a look at all of your home screens and folders to see if something is hidden. It that doesn't work, you can go to Settings>General>Reset>Reset Home Screen Layout.

  • Why won't my macbook show app store

    Why won't my macbook show the App Store ? I have uninstalled itunes completely at least 3 times....

    Try downloading and rerunning the 12.6.7 combo update http://support.apple.com/kb/DL1361

  • I purchased the new gen 7 ipod nano and needed to update itunes to 10.7 but my current software says its up to date and won't download 10.6.8 Currently I have 10.5.8 Why won't this update?

    I purchased the new gen 7 ipod nano and needed to update itunes to 10.7 but my current software says its up to date and won't download 10.6.8 Currently I have 10.5.8 Why won't this update?

    The first generation Intel-based Mac's were released in January 2006.
    Snow Leopard requires an Intel processor:
    General requirements
    Mac computer with an Intel processor
    1GB of memory
    5GB of available disk space
    DVD drive for installation
    Some features require a compatible Internet service provider; fees may apply.
    If you go to the Apple menu & "About this Mac" this will tell you what type of processor you have:

  • Why won't this song play even after I authorized the computer? It says that I need to authorize the computer, then I enter my username and password and it says the computer is already authorized. But then the song still won't play. What do I do?

    Why won't this song play even after I authorized the computer? It says that I need to authorize the computer, then I enter my username and password and it says the computer is already authorized. But then the song still won't play. What do I do?

    Use the Apple ID support -> http://www.apple.com/support/appleid/ - click through the contact information and select the iTunes, etc., hot button. You can have Apple call you or email them.
    Clinton

  • Why won't this script run in task scheduler properly?

    Hello,
    I've created a script find all opened windows applications on the local computer.  The script creates an html outfile to report the opened windows and who is logged in. 
    When I run this script from the Powershell ISE or from Powershell command line it works fine.  When I schedule this script to run in windows Task Scheduler (either in Windows 7 or on Windows Server 2008) and I use 'Run only when user is logged in' the
    script again runs fine and reports in the html file the opened windows.
    But when I am logged into the server and I schedule this script to run in windows Task Scheduler (either in Windows 7 or on Windows Server 2008) and I use 'Run whether user is logged in or not' the script will run without error, it creates the html report,
    but it does not list the opened windows applications  That part of the report is missing.
    Why would this happen?  Do I need to change something in my script to make this script work whether or not someone is logged in?
    Here is the script:
    $a = "<style>"
    $a = $a + "BODY{background-color:peachpuff;}"
    $a = $a + "TABLE{border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;}"
    $a = $a + "TH{border-width: 1px;padding: 0px;border-style: solid;border-color: black;background-color:thistle}"
    $a = $a + "TD{border-width: 1px;padding: 0px;border-style: solid;border-color: black;background-color:PaleGoldenrod}"
    $a = $a + "</style>"
    get-wmiobject Win32_ComputerSystem | ConvertTo-HTML -head $a -body "<H2>Logged in UserID</H2>" -property username | Out-File C:\Powershell_Scripts\Test.htm ; Get-Process |where {$_.mainWindowTItle} |Select-Object name,mainwindowtitle | ConvertTo-HTML -head $a -body "<H2>Open Applications</H2>" | Out-File C:\Powershell_Scripts\Test.htm -Append
    Thank you.

    Its hard to get a full grasp of the errors from task scheduler.  Try rewriting the Action portion of the Scheduled Task in a cmd prompt (with or without the elevated credentials). When the cmd line runs, the cmd host will convert to a black
    powershell host and you will be able to read the errors.
    C:\> powershell.exe -command { update-help }
    or
    C:\> powershell.exe -noprofile -file c:\scripts\dosomething.ps1
    I solved a similar problem this week.  When I ran my script from within powershell, all the required modules are normally present and the script ran fine.  It was pretty clear which module I forgot to load at the beginning of the script once I could
    watch it from start to finish
    or, your script could dump the Error logs to a text file.
    $Error | select * | out-file c:\errors.txt
    Not the point.  Look at the task scheduler history first.  If the history is not enabled enable it. If it shows no error code then the script ran successfully but had an internal error.
    There is only one place that an error can occur. This will trap it and set the exit code which will be visible in the event history:
    $a=@'
    <style>
    BODY{
    background-color:peachpuff;
    TABLE{
    border-width: 1px;
    border-style: solid;
    border-color: black;
    border-collapse: collapse;
    TH{
    border-width: 1px;
    padding: 0px;
    border-style: solid;
    border-color: black;
    background-color:thistle;
    TD{
    border-width: 1px;
    padding: 0px;
    border-style: solid;
    border-color: black;
    background-color:PaleGoldenrod
    </style>
    Try{
    $username=get-wmiobject Win32_ComputerSystem |%{$_.username}
    $precontent="<H2>Logged in User: $username</H2><br/><H2>Open Applications</H2><br/>"
    $html=Get-Process |where {$_.mainWindowTItle} -ErorAction Stop|
    Select-Object name,mainwindowtitle |
    ConvertTo-HTML -cssuri c:\scripts\style.css -preContent $precontent -body "<body bgcolor='peachpuff'/>"
    $html | Out-File C:\Scripts\Test.htm -ErrorAction Stop
    Catch{
    exit 99
    This is really an exercise in how to manage background tasks.
    Using an error log is good assuming it is not the file system that you are having an issue with
    ¯\_(ツ)_/¯

  • Why won't this code work?

    All I want to do is resize the select panel to the same size as east panel. Why won't it work?
    Space.java_____________________________________________
    import javax.sound.sampled.*;
    import java.awt.*;
    import javax.sound.midi.*;
    import javax.swing.*;
    import java.util.*;
    import java.awt.event.*;
    import java.io.*;
    public class Space extends JFrame implements ActionListener, Runnable{
         //Sound
         Sequence currentSound;
         Sequencer player;
         Thread soundCheck;
         boolean check = true;
         public void start(){
              soundCheck = new Thread();
              soundCheck.start();
         public void run(){
              try{
                   File bgsound = new File("Sounds" + File.separator + "Space.mid");
                   currentSound = MidiSystem.getSequence(bgsound);
                   player = MidiSystem.getSequencer();
                   player.open();
                   player.setSequence(currentSound);
                   player.start();
                   checkSound();
              } catch (Exception exc){}
         public void checkSound(){
              while(check){
                   if(!player.isRunning()){
                     run();
                   try{
                        soundCheck.sleep((player.getMicrosecondLength() / 1000)-player.getMicrosecondPosition()); // sleep for the length of the track
                   }catch (InterruptedException IE){}
         //Screen Variables:
         Dimension SCREEN = Toolkit.getDefaultToolkit().getScreenSize();
         final int SCREENWIDTH = SCREEN.width;
         final int SCREENHEIGHT = SCREEN.height;
         //Panels:
         JPanel select, main, north, south, east;
        //Buttons:
         JButton instructB, cheatB, playB, exit, about;
         //Labels:
         JLabel open, cheat1, cheat2, cheatInstruct, i1, i2 , i3, aboutLabel;
         //The container and frame:
         static Space jframe;
         Container content;
         //The Constructor:
         public Space(){
              super("Space");
              //set  container attributes:
              content = getContentPane();
              content.setLayout(new BorderLayout());
              //init panels:
              main   = new JPanel();
              select = new JPanel();
              north  = new JPanel();
              east   = new JPanel();
              south  = new JPanel();
              //set panel attributes:
              select.setLayout(new GridLayout(3,0,10,10));     
              select.setBackground(Color.black);
              main.setBackground(Color.black);
              north.setBackground(Color.black);
              //add panels:
              content.add("West", select);
              content.add("Center", main);
              content.add("North", north);
              content.add("East", east);
              //Image Icons:
              Icon exit1 = new ImageIcon("Images" + File.separator + "exit1.gif");
              Icon exit2 = new ImageIcon("Images" + File.separator + "exit2.gif");
              Icon about1 = new ImageIcon("Images" + File.separator + "about1.gif");
              Icon about2 = new ImageIcon("Images" + File.separator + "about2.gif");
              //init buttons, add their listeners, and set their attributes:
              instructB = new JButton("Instructions", new ImageIcon("Images" + File.separator + "ship.gif"));
              instructB.setContentAreaFilled(false);
              instructB.setForeground(Color.yellow);
              instructB.addActionListener(this);
              select.add(instructB);
              cheatB = new JButton("Cheats", new ImageIcon("Images" + File.separator + "cheat.gif"));
              cheatB.setContentAreaFilled(false);
              cheatB.setForeground(Color.yellow);
              cheatB.addActionListener(this);
              select.add(cheatB);
              playB = new JButton("Play", new ImageIcon("Images" + File.separator + "ship2.gif"));
              playB.setContentAreaFilled(false);
              playB.setForeground(Color.yellow);
              playB.addActionListener(this);
              select.add(playB);          
              exit = new JButton();
              exit.setRolloverEnabled(true);
              exit.setIcon(exit1);
              exit.setRolloverIcon(exit2);
              exit.setBorderPainted(false);
              exit.setContentAreaFilled(false);
              exit.addActionListener(this);
              north.add(exit);
              about = new JButton();
              about.setRolloverEnabled(true);
              about.setIcon(about1);
              about.setRolloverIcon(about2);
              about.setBorderPainted(false);
              about.setContentAreaFilled(false);
              about.addActionListener(this);
             north.add(about);
             //Labels:
             open = new JLabel("", new ImageIcon("Images" + File.separator + "open.gif"), JLabel.CENTER);
              main.add(open);
              cheat1 = new JLabel("<html><h1>tport</h1></html>");
              cheat1.setForeground(Color.red);
              cheat2 = new JLabel("<html><h1>zap</h1></html>");
              cheat2.setForeground(Color.green);
              cheatInstruct = new JLabel("<html><h1>Type a cheat at any time during a game, and press the \"Enter\" key.</html></h1>");
              cheatInstruct.setForeground(Color.blue);     
              i1 = new JLabel("<html><h1>The arrow keys move your ship.</h1></html>");
              i1.setForeground(Color.red);
              i2 = new JLabel("<html><h1>The space-bar fires the gun.</h1></html>");
              i2.setForeground(Color.green);
              i3 = new JLabel("<html><h1>The red circles give upgrades.</html></h1>");
              i3.setForeground(Color.blue);
              aboutLabel    = new JLabel("", new ImageIcon("Images" + File.separator + "aboutImage.gif"), JLabel.CENTER);
              //centerPanel();     
         private void centerPanel(final int width, final int height){
              try{
                   Runnable setPanelSize = new Runnable(){
                        public void run(){
                             east.setPreferredSize(new Dimension(width, height));                    
                   SwingUtilities.invokeAndWait(setPanelSize);
              } catch (Exception e){}
         public void actionPerformed(ActionEvent e){
              //if the play button was pressed do:
              if(e.getSource() == playB){
                  //do something
             //else if the cheat button was pressed do:
              else if(e.getSource() == cheatB){
                   //remove and add components
                   main.removeAll();
                   main.setLayout(new GridLayout(3,0,0,0));
                   main.add(cheat1);
                   main.add(cheat2);
                   main.add(cheatInstruct);
                   main.repaint();
                   main.validate();          
              else if(e.getSource() == instructB){
                   //remove and add components
                   main.removeAll();
                   main.setLayout(new GridLayout(3,0,0,0));
                   main.add(i1);
                   main.add(i2);
                   main.add(i3);
                   main.repaint();
                   main.validate();          
              else if(e.getSource() == exit){
                   jframe.setVisible(false);
                   showCredits();          
              else if(e.getSource() == about){
                   main.removeAll();
                   main.setLayout(new FlowLayout());
                   main.add(aboutLabel);                         
                   main.repaint();
                   main.validate();
         public void showCredits(){
              try{
                   String[] args = {};
                   Credits.main(args);
              }catch (Exception e){}
         public static void main(String args[]){
              jframe = new Space();
              jframe.setUndecorated(true);
              jframe.setBounds(0, 0, jframe.SCREENWIDTH, jframe.SCREENHEIGHT);
              jframe.setVisible(true);
            jframe.show();     
            jframe.setResizable(false);
               jframe.setDefaultCloseOperation(EXIT_ON_CLOSE);
             jframe.centerPanel(jframe.select.getWidth(), jframe.select.getHeight());
             jframe.run(); //start music

    The reason it wasn't working was because you were calling the method after you had set the frame visible, so you saw no change. On top of that, jframe.select.getWidth() only works after the frame is visible in this case. So it's best to set a fixed size for one of them, then use getWidth, or as I did... it's the same thing. I also changed the centerPanel method, I'm not sure if all that's exactly needed, but you can change it back if you think you'll need it.
    import javax.sound.sampled.*;
    import java.awt.*;
    import javax.sound.midi.*;
    import javax.swing.*;
    import java.util.*;
    import java.awt.event.*;
    import java.io.*;
    public class Space extends JFrame implements ActionListener, Runnable{
    //Sound
    Sequence currentSound;
    Sequencer player;
    Thread soundCheck;
    boolean check = true;
    public void start(){
    soundCheck = new Thread();
    soundCheck.start();
    public void run(){
    try{
    File bgsound = new File("Sounds" + File.separator + "Space.mid");
    currentSound = MidiSystem.getSequence(bgsound);
    player = MidiSystem.getSequencer();
    player.open();
    player.setSequence(currentSound);
    player.start();
    checkSound();
    } catch (Exception exc){}
    public void checkSound(){
    while(check){
    if(!player.isRunning()){
                run();
    try{
    soundCheck.sleep((player.getMicrosecondLength() / 1000)-player.getMicrosecondPosition()); // sleep for the length of the track
    }catch (InterruptedException IE){}
    //Screen Variables:
    Dimension SCREEN = Toolkit.getDefaultToolkit().getScreenSize();
    final int SCREENWIDTH = SCREEN.width;
    final int SCREENHEIGHT = SCREEN.height;
    //Panels:
    JPanel select, main, north, south, east;
        //Buttons:
    JButton instructB, cheatB, playB, exit, about;
    //Labels:
    JLabel open, cheat1, cheat2, cheatInstruct, i1, i2 , i3, aboutLabel;
    //The container and frame:
    static Space jframe;
    Container content;
    //The Constructor:
    public Space(){
    super("Space");
    //set  container attributes:
    content = getContentPane();
    content.setLayout(new BorderLayout());
    //init panels:
    main   = new JPanel();
    select = new JPanel();
    north  = new JPanel();
    east   = new JPanel();
    south  = new JPanel();
    //set panel attributes:
    select.setLayout(new GridLayout(3,0,10,10));
    select.setBackground(Color.black);
    main.setBackground(Color.black);
    north.setBackground(Color.black);
    //add panels:
    content.add("West", select);
    content.add("Center", main);
    content.add("North", north);
    content.add("East", east);
    //Image Icons:
    Icon exit1 = new ImageIcon("Images" + File.separator + "exit1.gif");
    Icon exit2 = new ImageIcon("Images" + File.separator + "exit2.gif");
    Icon about1 = new ImageIcon("Images" + File.separator + "about1.gif");
    Icon about2 = new ImageIcon("Images" + File.separator + "about2.gif");
    //init buttons, add their listeners, and set their attributes:
    instructB = new JButton("Instructions", new ImageIcon("Images" + File.separator + "ship.gif"));
    instructB.setContentAreaFilled(false);
    instructB.setForeground(Color.yellow);
    instructB.addActionListener(this);
    select.add(instructB);
    cheatB = new JButton("Cheats", new ImageIcon("Images" + File.separator + "cheat.gif"));
    cheatB.setContentAreaFilled(false);
    cheatB.setForeground(Color.yellow);
    cheatB.addActionListener(this);
    select.add(cheatB);
    playB = new JButton("Play", new ImageIcon("Images" + File.separator + "ship2.gif"));
    playB.setContentAreaFilled(false);
    playB.setForeground(Color.yellow);
    playB.addActionListener(this);
    select.add(playB);
    exit = new JButton();
    exit.setRolloverEnabled(true);
    exit.setIcon(exit1);
    exit.setRolloverIcon(exit2);
    exit.setBorderPainted(false);
    exit.setContentAreaFilled(false);
    exit.addActionListener(this);
    north.add(exit);
    about = new JButton();
    about.setRolloverEnabled(true);
    about.setIcon(about1);
    about.setRolloverIcon(about2);
    about.setBorderPainted(false);
    about.setContentAreaFilled(false);
    about.addActionListener(this);
        north.add(about);
        //Labels:
        open = new JLabel("", new ImageIcon("Images" + File.separator + "open.gif"), JLabel.CENTER);
    main.add(open);
    cheat1 = new JLabel("<html><h1>tport</h1></html>");
    cheat1.setForeground(Color.red);
    cheat2 = new JLabel("<html><h1>zap</h1></html>");
    cheat2.setForeground(Color.green);
    cheatInstruct = new JLabel("<html><h1>Type a cheat at any time during a game, and press the \"Enter\" key.</html></h1>");
    cheatInstruct.setForeground(Color.blue);
    i1 = new JLabel("<html><h1>The arrow keys move your ship.</h1></html>");
    i1.setForeground(Color.red);
    i2 = new JLabel("<html><h1>The space-bar fires the gun.</h1></html>");
    i2.setForeground(Color.green);
    i3 = new JLabel("<html><h1>The red circles give upgrades.</html></h1>");
    i3.setForeground(Color.blue);
    aboutLabel    = new JLabel("", new ImageIcon("Images" + File.separator + "aboutImage.gif"), JLabel.CENTER);
    east.setPreferredSize(new Dimension(125, SCREEN.width));
    //centerPanel();
    /*private void centerPanel(final int width, final int height){
    try{
    Runnable setPanelSize = new Runnable(){
    public void run(){
    east.setPreferredSize(new Dimension(width, height));
    SwingUtilities.invokeAndWait(setPanelSize);
    } catch (Exception e){}
    private void centerPanel(final int width, final int height)
         east.setPreferredSize(new Dimension(width, height));
    public void actionPerformed(ActionEvent e){
    //if the play button was pressed do:
    if(e.getSource() == playB){
        //do something
        //else if the cheat button was pressed do:
    else if(e.getSource() == cheatB){
    //remove and add components
    main.removeAll();
    main.setLayout(new GridLayout(3,0,0,0));
    main.add(cheat1);
    main.add(cheat2);
    main.add(cheatInstruct);
    main.repaint();
    main.validate();
    else if(e.getSource() == instructB){
    //remove and add components
    main.removeAll();
    main.setLayout(new GridLayout(3,0,0,0));
    main.add(i1);
    main.add(i2);
    main.add(i3);
    main.repaint();
    main.validate();
    else if(e.getSource() == exit){
    jframe.setVisible(false);
    //showCredits();
    else if(e.getSource() == about){
    main.removeAll();
    main.setLayout(new FlowLayout());
    main.add(aboutLabel);
    main.repaint();
    main.validate();
    /*public void showCredits(){
    try{
    String[] args = {};
    Credits.main(args);
    }catch (Exception e){}
    public static void main(String args[]){
    jframe = new Space();
    //jframe.centerPanel(500, jframe.select.getHeight());
    jframe.setUndecorated(true);
    jframe.setBounds(0, 0, jframe.SCREENWIDTH, jframe.SCREENHEIGHT);
    jframe.setVisible(true);
            jframe.show();
            jframe.setResizable(false);
          jframe.setDefaultCloseOperation(EXIT_ON_CLOSE);
        //jframe.centerPanel(jframe.select.getWidth(), jframe.select.getHeight());
        jframe.run(); //start music
    }Sorry I lost all the indenting :) I guess you can take a look at the few lines I changed and copy those lines.

  • Why won't my Buttons show?

    Why arent my button arrays showing in the class reinforcements?
    import java.awt.*;
    import java.awt.event.*;
    public class reinforcements implements ActionListener{
            basicFrame frame;
            Button playerGuess[] [] = new Button[9] [9];
            Button playerField[] [] = new Button[9] [9];
            Panel pGC, pFC, actionPanel; //playerGuessContainer, playerFieldContaioner
            Button start;
            Label started;
            GridBagLayout gbl = new GridBagLayout();
            GridBagConstraints constraints;
            CardLayout cardLayout;
            public reinforcements() {
                    frame = new basicFrame("Battleship", 500, 300, true, gbl);
                    constraints = new GridBagConstraints();
                    pGC = new Panel();
                    pFC = new Panel();
                    pGC.setLayout(new GridLayout(10, 10));
                    pFC.setLayout(new GridLayout(10, 10));
                    for (int row=0; row>10; ++row) {
                            for (int col=0; col>10; ++col) {
                                    System.out.println(row);
                                    System.out.println(col);
                                    playerGuess[row] [col] = new Button("?");
                                    playerField[row] [col] = new Button("?");
                                    pGC.add(playerGuess[row] [col]);
                                    pFC.add(playerField[row] [col]);
                    cardLayout = new CardLayout();
                    actionPanel = new Panel();
                    actionPanel.setLayout(cardLayout);
                    start = new Button("Start Game");
                    start.addActionListener(this);
                    started = new Label("It started");
                    actionPanel.add("C1", start);
                    actionPanel.add("C2", started);
                    constraints.gridwidth = 2;
                    gbl.setConstraints(actionPanel, constraints);
                    frame.add(actionPanel);
                    constraints.gridx = 0;
                    constraints.gridy = 1;
                    gbl.setConstraints(pGC, constraints);
                    frame.add(pGC);
                    constraints.gridx = constraints.RELATIVE;
                    gbl.setConstraints(pFC, constraints);
                    frame.add(pFC);
                    frame.setVisible(true);
            public static void main(String args[]) {
                    reinforcements r = new reinforcements();
            public void actionPerformed(ActionEvent e) {
                    cardLayout.next(actionPanel);
            }The basicFrame class is:
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.Frame;
    import java.awt.Color;
    public final class basicFrame extends Frame implements WindowListener, ActionListener {
            private static byte count = 0;
            public static final byte FILE = 1;
            public static final byte HELP = 2;
            public static final byte STATUS = 3;
            private MenuBar mb;
            private Menu file, help, status;
            private MenuItem exit, print, current, about;
            public basicFrame() {
                    this(" ", 400, 400, false, new FlowLayout(), Color.lightGray, Color.black);
            public basicFrame(String title) {
                    this(title, 400, 400, false, new FlowLayout(), Color.lightGray, Color.black);
            public basicFrame(int x, int y) {
                    this(" ", x, y, false, new FlowLayout(), Color.lightGray, Color.black);
            public basicFrame(boolean resize) {
                    this(" ", 400, 400, resize, new FlowLayout(), Color.lightGray, Color.black);
            public basicFrame(LayoutManager layout) {
                    this(" ", 400, 400, false, layout, Color.lightGray, Color.black);
            public basicFrame(Color back, Color front) {
                    this(" ", 400, 400, false, new FlowLayout(), back, front);
            public basicFrame(String title, int x, int y) {
                    this(title, x, y, false, new FlowLayout(), Color.lightGray, Color.black);
            public basicFrame(String title, boolean resize) {
                    this(title, 400, 400, resize, new FlowLayout(), Color.lightGray, Color.black);
            public basicFrame(String title, LayoutManager layout) {
                    this(title, 400, 400, false, layout, Color.lightGray, Color.black);
            public basicFrame(String title, Color back, Color front) {
                    this(title, 400, 400, false, new FlowLayout(), back, front);
            public basicFrame(int x, int y, boolean resize) {
                    this(" ", x, y, resize, new FlowLayout(), Color.lightGray, Color.black);
            public basicFrame(int x, int y, LayoutManager layout) {
                    this(" ", x, y, false, layout, Color.lightGray, Color.black);
            public basicFrame(int x, int y, Color back, Color front) {
                    this(" ", x, y, false, new FlowLayout(), back, front);
            public basicFrame(boolean resize, LayoutManager layout) {
                    this(" ", 400, 400, resize, layout, Color.lightGray, Color.black);
            public basicFrame(boolean resize, Color back, Color front) {
                    this(" ", 400, 400, resize, new FlowLayout(), back, front);
            public basicFrame(LayoutManager layout, Color back, Color front) {
                    this(" ", 400, 400, false, layout, back, front);
            public basicFrame(String title, int x, int y, boolean resize) {
                    this(title, x, y, resize, new FlowLayout(), Color.lightGray, Color.black);
            public basicFrame(String title, int x, int y, LayoutManager layout) {
                    this(title, x, y, false, layout, Color.lightGray, Color.black);
            public basicFrame(String title, int x, int y, Color back, Color front) {
                    this(title, x, y, false, new FlowLayout(), back, front);
            public basicFrame(String title, boolean resize, LayoutManager layout) {
                    this(title, 400, 400, resize, layout, Color.lightGray, Color.black);
            public basicFrame(String title, boolean resize, Color back, Color front) {
                    this(title, 400, 400, resize, new FlowLayout(), back, front);
            public basicFrame(String title, LayoutManager layout, Color back, Color front) {
                    this(title, 400, 400, false, layout, back, front);
            public basicFrame(int x, int y, boolean resize, LayoutManager layout) {
                    this(" ", x, y, resize, layout, Color.lightGray, Color.black);
            public basicFrame(int x, int y, boolean resize, Color back, Color front) {
                    this(" ", x, y, resize, new FlowLayout(), back, front);
            public basicFrame(int x, int y, LayoutManager layout, Color back, Color front) {
                    this(" ", x, y, false, layout, back, front);
            public basicFrame(boolean resize, LayoutManager layout, Color back, Color front) {
                    this(" ", 400, 400, resize, layout, back, front);
            public basicFrame(String title, int x, int y, boolean resize, LayoutManager layout) {
                    this(title, x, y, resize, layout, Color.lightGray, Color.black);
            public basicFrame(String title, int x, int y, boolean resize, Color back, Color front) {
                    this(title, x, y, resize, new FlowLayout(), back, front);
            public basicFrame(String title, int x, int y, LayoutManager layout, Color back, Color front) {
                    this(title, x, y, false, layout, back, front);
            public basicFrame(String title, boolean resize, LayoutManager layout, Color back, Color front) {
                    this(title, 400, 400, resize, layout, back, front);
            public basicFrame(int x, int y, boolean resize, LayoutManager layout, Color back, Color front) {
                    this(" ", x, y, resize, layout, back, front);
            public basicFrame(String title, int x, int y, boolean resize, LayoutManager layout, Color back, Color front) {
                    super(title);
                    count++;
                    setSize(x, y);
                    setResizable(resize);
                    setLayout(layout);
                    setBackground(back);
                    setForeground(front);
                    addWindowListener(this);
                    mb = new MenuBar();
                    file = new Menu("File");
                    help = new Menu("Help");
                    status = new Menu("Status");
                    exit = new MenuItem("Exit");
                    about = new MenuItem("About");
                    print = new MenuItem("Print to Command Prompt");
                    current = new MenuItem("Current Status");
                    exit.addActionListener(this);
                    file.add(exit);
                    about.addActionListener(this);
                    print.addActionListener(this);
                    current.addActionListener(this);
                    status.add(print);
                    status.add(current);
                    help.add(about);
                    help.add(status);
                    mb.add(file);
                    mb.add(help);
                    setMenuBar(mb);
            public void setVisible(boolean visible) {
                    if (visible) {
                            Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
                            setLocation((d.width-getWidth())/2, (d.height-getHeight())/2);
                    super.setVisible(visible);
            public void addMenuItem(MenuItem item, byte where) {
                    if (where == FILE)
                            file.add(item);
                    if (where == HELP)
                            help.add(item);
                    if (where == STATUS)
                            status.add(item);
            public void addMenu(Menu menu) {
                    mb.add(menu);
            public void addMenu(Menu menu, byte where) {
                    if (where == FILE)
                            file.add(menu);
                    if (where == HELP)
                            help.add(menu);
                    if (where == STATUS)
                            status.add(menu);
            public void windowClosing(WindowEvent e) {
                    count--;
                    if (count == 0) {
                            dispose();
                            System.exit(0);
                    else {
                            super.setVisible(false);
            public void windowActivated(WindowEvent e) {}
            public void windowClosed(WindowEvent e) {}
            public void windowIconified(WindowEvent e) {}
            public void windowDeiconified(WindowEvent e) {}
            public void windowDeactivated(WindowEvent e) {}
            public void windowOpened(WindowEvent e) {}
            public void actionPerformed(ActionEvent e) {
                    if (e.getSource() == exit) {
                            count--;
                            if (count == 0) {
                                    dispose();
                                    System.exit(0);
                            else {
                                    super.setVisible(false);
                    if (e.getSource() == about) {
                            basicFrame ab = new basicFrame(250, 150, new GridLayout(3, 1));
                            Label name = new Label("Author: Nicholas La Pietra");
                            Label version = new Label("Version: 1.0");
                            Label lastUpdated = new Label("Last Updated: 2/26/2005");
                            ab.add(name);
                            ab.add(version);
                            ab.add(lastUpdated);
                            ab.setVisible(true);
                    if (e.getSource() == print) {
                            System.out.println("Current Number of Frames: " + count);
                    if (e.getSource() == current) {
                            basicFrame cr = new basicFrame(250, 100, new GridLayout(1, 1));
                            Label numOfFrames = new Label("Current Number of Frames: " + count, Label.CENTER);
                            cr.add(numOfFrames);
                            cr.setVisible(true);
            }  

    for (int row=0; row>10; ++row) {It's hard for row to be >10 if it starts at 0; probably you meant "row < 10" ...?

  • Why won't this form submit?

    Why won't the form on this page submit?
    www.milesmemorials.com/contact.html
    Php for this form is-
    <?php
    $name = $_POST['name'];
    $visitor_email = $_POST['email'];
    $message = $_POST['message'];
    //Validate first
    if(empty($name)||empty($visitor_email))
        echo "Name and email are mandatory!";
        exit;
    if(IsInjected($visitor_email))
        echo "Bad email value!";
        exit;
    $email_from = "milesmemorials.com";//<== update the email address
    $email_subject = "Message from Miles Memorial contact form";
    $email_body = "Visitors name: $name.\n".
         "Message:\n $message".
    $to = "[email protected]";//<== update the email address
    $headers = 'From: '.$visitor_email."\r\n";
    $headers .='Reply-To:'.$visitor_email."\r\n";
    //Send the email!
    mail($to,$email_subject,$email_body,$headers);
    //done. redirect to thank-you page.
    header('Location: thankyou.html');
    // Function to validate against any email injection attempts
    function IsInjected($str)
      $injections = array('(\n+)',
                  '(\r+)',
                  '(\t+)',
                  '(%0A+)',
                  '(%0D+)',
                  '(%08+)',
                  '(%09+)'
      $inject = join('|', $injections);
      $inject = "/$inject/i";
      if(preg_match($inject,$str))
        return true;
      else
        return false;
    ?>

    >I do apologise if i seem slow, i am still very new to dreamweaver
    Just to be clear, this is not an issue with learning dreamweaver. This is just a lack of understanding of HTML and PHP. You need to learn those first before trying to learn DW.
    You have a form field named 'donorName' but are checking for a field named 'name'.
    $name = $_POST['name'];
    <input name="donerName" type="text"
    You need to rename one or the other.

  • New cd players won't play slide show made on Elements 9?

    I can make a slide show on Elements 9 and burn it to cd-r, however, none of the newer players will read it or play it.  I can play it on an older machine, but I need to get a smaller, new cd player.  Can you help? 

    The best advice I can give you is don't throw good money at this. VCD is a dying format and it's increasingly hard to find anything that bothers to support it. Better to output as WMV and use something like windows movie maker or whatever software came with your dvd burner to make a real dvd. The quality is vastly superior, too.

  • Consolidate Library - why won't this work?

    Hi there,
    I've been using iTunes and my iPod on several iMacs successfully for years - I've just changed to a PC and now I feel like a beginner!
    I can't seem to get iTunes for Windows to seek out all my MP3s and put them in iTunes. The only way I can get iTunes to put them in it's library is to play them - then iTunes recognises then and remebers them. I have tried clicking on consolidate library - nothing. I have tried downloading my new music directly into the iTunes music folder - nothing. I can maunally add the file I download music into, but I don't want to have to do that all the time.
    Why won't iTunes just find my music for me? It does on my iMac!

    I dont know!
    In what way is it not working?

Maybe you are looking for