Solved

Need to add an actionlistener to a frame that opens an url so that it closes when clicked

Posted on 2004-08-30
25
890 Views
Last Modified: 2008-01-09

I have a game class that opens up a webpage in a JEditorPane to dispaly my user instructions.  I would like to have it so that when it is clicked it will shut the JEditorPane down.  The webpage contains nothing but  JPEG that I will modify to say click to close on it.

Here is my code:::

import java.awt.* ;
import java.awt.event.* ;
import java.awt.image.* ;
import javax.imageio.* ;
import java.io.* ;
import javax.swing.* ;
import java.util.*;
import java.applet.AudioClip;
import java.applet.Applet;
import java.net.URL;

/**
 *   Main Game Frame window called JaySnake
 */

public class JaySnake extends JFrame implements ActionListener
{
  class Game extends JPanel implements Runnable
  {
    private BufferedImage backBuffer ;
    private Graphics myBackBuffer ;

/*The HashMap  class is roughly equivalent to Hashtable,
 *except that it is unsynchronized and permits nulls*/
    HashMap imageMap = new HashMap(4);
     public int waitTime = 75;

/*Method used to get text from background menu items and set background image from that*/
     public void setImage(String fileName) throws Exception
     {
          if (fileName.equals("backgrounds/default")) //Sets background to default image
          {
                    backgroundImage = ImageIO.read( new File( "backgrounds/default.jpg" ) );
         }
         else if (fileName.equals("Long grass")) //Sets background to longGrass image
         {
                   backgroundImage = ImageIO.read( new File( "backgrounds/longGrass.jpg" ) );
         }
         else if (fileName.equals("Yellow Sand"))//Sets background to sand image
         {
                  backgroundImage = ImageIO.read( new File( "backgrounds/sand.jpg" ) );
         }

         else if (fileName.equals("Blue Glass")) //Sets background to blueGrass image
         {
                  backgroundImage = ImageIO.read( new File( "backgrounds/blueGlass.jpg" ) );
         }
         else //Sets to default if none mathced
         {
                   backgroundImage = ImageIO.read( new File( "backgrounds/default.jpg" ) );
         }
     }

    public Game()
    {

  /******Try read in default backgroundImage file and catch any exception*/
      try //first read in default image
      {
            backgroundImage = ImageIO.read( new File( "backgrounds/default.jpg" ) );
            clip = Applet.newAudioClip(new URL("file:" + System.getProperty("user.dir") + "/sounds/music.au"));
            appleEaten = Applet.newAudioClip(new URL("file:" + System.getProperty("user.dir") + "/sounds/apple.au"));
      }
      catch( IOException e )
      {
        System.out.println(e) ;
      }

      backBuffer = new BufferedImage( DISPLAY_W, DISPLAY_H, BufferedImage.TYPE_INT_RGB ) ;
      myBackBuffer = backBuffer.getGraphics() ;

//set up the menubar
      menubar = new JMenuBar();
      setJMenuBar(menubar);

    }

    public void paintComponent( Graphics g )
    {
      g.drawImage( backBuffer, DISPLAY_X, DISPLAY_Y, null ) ;
    }

     public void paint( Graphics g )
    {
            super.paint(g);
        g.drawImage(backgroundImage,0,0,null);

          //Draw green scoreboard and black rects
        g.setColor(Color.black);
        g.fillRect(1,540,598,20);
        g.fillRect(1,34,598,6);
        g.setColor(Color.white);
        g.drawRoundRect(1,0,598,32,10,10);

          //Calls Snake paint method
          if (snake != null)
             snake.draw(g);

    }

    public void run()
    {
      //     1000/25 Frames Per Second = 40millisecond delay
      int delayTime = 1000 / 25 ;

      Thread thisThread = Thread.currentThread() ;
      while( running )
      {
        //startTime = System.currentTimeMillis() ;
        // render to back buffer now
        render( myBackBuffer ) ;

        repaint() ;
        //  handle frame rate
        //elapsedTime = System.currentTimeMillis() - startTime ;
        //waitTime = Math.max( delayTime - elapsedTime, 5 ) ;

        try
        {
               Thread.sleep( waitTime ) ;
        }
        catch( InterruptedException e )
        {}
      }
      System.out.println( "Program Exited" ) ;
    }


  }

  private Thread gamePlay ;
  private boolean running = true ;
  private Game game ;

  private final int DISPLAY_X ; // value assigned in constructor
  private final int DISPLAY_Y ; // value assigned in constructor

  private static final int DISPLAY_W = 610 ;
  private static final int DISPLAY_H = 610 ;

  int size, hsize = 0, score1 = 0, score2 = 0, highscore = 0 ;

  /****Creates JMenuBar */
  private JMenuBar menubar ;
 
  /****Creates JMenu to house items */
  private JMenu gameMenu = new JMenu( "Game" ) ;
  private JMenuItem gameStart = new JMenuItem( "Start" ) ;
  private JMenuItem gameQuit = new JMenuItem( "Quit" ) ;
 
  private JMenu bgMenu = new JMenu( "Backgrounds" ) ;
  private ButtonGroup bgGroup = new ButtonGroup() ;
  private JRadioButtonMenuItem bg1 = new JRadioButtonMenuItem( "Default" ) ;
  private JRadioButtonMenuItem bg2 = new JRadioButtonMenuItem( "Long grass" ) ;
  private JRadioButtonMenuItem bg3 = new JRadioButtonMenuItem( "Yellow Sand" ) ;
  private JRadioButtonMenuItem bg4 = new JRadioButtonMenuItem( "Blue Glass" ) ;

  private JMenu soundMenu = new JMenu( "Enable sounds" ) ;
  private JCheckBoxMenuItem soundMusic = new JCheckBoxMenuItem( "Music" ) ;
  private JCheckBoxMenuItem soundSound = new JCheckBoxMenuItem( "Sounds" ) ;

  private JMenu helpMenu = new JMenu( "Help" ) ;
  private JMenuItem userInstruct = new JMenuItem( "User Instructions" ) ;
  private JMenuItem helpAbout = new JMenuItem( "About" ) ;

  /******JaySnake constructor*/
  public JaySnake()
  {
    setResizable( false ) ;
    game = new Game();
    getContentPane().add( game, BorderLayout.CENTER ) ;
    this.setJMenuBar( menubar );
                  menubar.add( gameMenu ) ;
                  gameMenu.setIcon(new ImageIcon("menuicons/start.gif"));
    gameMenu.add( gameStart ) ;
    gameStart.setIcon(new ImageIcon("menuicons/play.gif"));
     // ActionListener to quit the game when quit is clicked
    gameStart.addActionListener( new ActionListener(){

          public void actionPerformed( ActionEvent e )
          {
             String name = new String();
             name = JOptionPane.showInputDialog(JaySnake.this,  "Please enter your name", "Player Name dialogue", JOptionPane.QUESTION_MESSAGE );
             snake = new Snake(JaySnake.this, name, (soundForApple ? appleEaten : null));
          }
     });

    gameMenu.add( gameQuit ) ;
    gameQuit.setIcon(new ImageIcon("menuicons/quit.gif"));
   
    // ActionListener to quit the game when quit is clicked
    gameQuit.addActionListener( new ActionListener(){
          public void actionPerformed( ActionEvent e )
         {
             System.exit( 0 );
          }
     });
   
/*Background selection menubar setup adding actionlisteners*/
    menubar.add( bgMenu ) ;
    bgMenu.setIcon(new ImageIcon("menuicons/backgrounds.gif"));
    bgMenu.add( bg1 ); bg1.addActionListener(this);
    bgMenu.add( bg2 ); bg2.addActionListener(this);
    bgMenu.add( bg3 ); bg3.addActionListener(this);
    bgMenu.add( bg4 ); bg4.addActionListener(this);
/* "bgGroup"  groups menu items for background together*/
         bgGroup.add( bg1 );      bgGroup.add( bg2 );
         bgGroup.add( bg3 );        bgGroup.add( bg4 );

     /*Sounds menubar selection with actionListeners*/
    menubar.add( soundMenu );
    soundMenu.setIcon(new ImageIcon("menuicons/speaker.gif"));
    soundMusic.setState(true);
    soundMenu.add( soundMusic );
    soundMenu.add( soundSound ) ;

    soundSound.setState(true);

     /* Listeners */
     soundMusic.addActionListener(new ActionListener(){
               public void actionPerformed(ActionEvent e)
                 {
                    try
                    {
                         JCheckBoxMenuItem source = (JCheckBoxMenuItem)(e.getSource());
                         System.out.println(source.getText());
                         if (source.getState())
                         {
                              clip.loop();
                         }
                         else
                         {
                              clip.stop();
                         }

                    }
                    catch (Exception ex)
                    {
                         System.out.println(ex);
                    }
                 }
          });

     soundSound.addActionListener(new ActionListener(){
               public void actionPerformed(ActionEvent e)
                 {
                    try
                    {
                         JCheckBoxMenuItem source = (JCheckBoxMenuItem)(e.getSource());
                         if (source.getState())
                         {
                                   soundForApple = true;
                                   snake.setAppleSound(appleEaten);
                         }
                         else
                         {
                                   soundForApple = false;
                                   snake.setAppleSound(null);
                         }
                    }
                    catch (Exception ex)
                    {
                         System.out.println(ex);
                    }
                 }
          });
     /* /Listeners */

    menubar.add( helpMenu ) ;
    helpMenu.setIcon(new ImageIcon("menuicons/helpmenu.gif"));
    helpMenu.add( userInstruct );
    userInstruct.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                System.out.println("Instructions button pressed");
                //Create new Jframe to view User instructions
                JFrame f = new JFrame();
                JEditorPane p = new JEditorPane("text/html", "");
                f.getContentPane().add(p); // was missing in the previous code snippet
                p.setEditable(false);
                URL instructions = getClass().getResource("instructions/index.html");
                try {
                    p.setPage(instructions);
                }
               
                catch (Exception ep) {
                   
                    System.out.println("Not Got index.html");
                }

                f.setSize(265, 540);
                f.setVisible(true);
               
               
            }                      
        });
       
       
    helpMenu.add( helpAbout );
    helpAbout.addActionListener( new ActionListener(){
             public void actionPerformed( ActionEvent e )
     {
//Create an instance of About class window
/*                   About dlg = new About( JaySnake.this );
                   Dimension dlgSize = dlg.getPreferredSize();
                   Dimension frmSize = getSize();
                   Point loc = getLocation();
                   dlg.setLocation((frmSize.width - dlgSize.width) / 2 + loc.x, (frmSize.height - dlgSize.height) / 2 + loc.y);
                   dlg.setModal(true);
                   dlg.pack();
                   dlg.show();
                   */
    }
     } ) ;

    addWindowListener( new WindowAdapter()
    {
      public void windowClosing( WindowEvent e )
      {
        dispose();
        System.exit( 0 ) ;
      }
    } ) ;

    Insets insets = getInsets() ;
    DISPLAY_X = insets.left ;
    DISPLAY_Y = insets.top ;
    resizeToInternalSize( DISPLAY_W, DISPLAY_H ) ;
   
    this.addKeyListener(new MyKeyListener());
  }

  public void actionPerformed(ActionEvent e)
  {
     try
     {
          JMenuItem source = (JMenuItem)(e.getSource());
          System.out.println(source.getText());
          game.setImage(source.getText());
     }
     catch (Exception ex)
     {
          System.out.println(ex);
     }
  }

  public void resizeToInternalSize( int internalWidth, int internalHeight )
  {
    Insets insets = getInsets() ;
    final int newWidth = internalWidth + insets.left + insets.right ;
    final int newHeight = internalHeight + insets.top + insets.bottom ;

    Runnable resize = new Runnable()
    {
      public void run()
      {
        setSize( newWidth, newHeight ) ;
      }
    } ;

    if( !SwingUtilities.isEventDispatchThread() )
    {
      try
      {
        SwingUtilities.invokeAndWait( resize ) ;
      }
      catch( Exception e )
      {}
    }
    else
      resize.run() ;

    validate() ;
  }

     public void playMusic()
     {
          clip.loop();

     }

  public void start()
  {
    gamePlay = new Thread( game ) ;
    gamePlay.start() ;
  }

//**************************Main method *************************************
       public static void main(String [] arguments)
     {
         System.out.println( "Starting JaySnake........" ) ;
         final JaySnake app = new JaySnake() ;

/*Sets the location of app central with all screen sizes*/
         app.setLocationRelativeTo(null);

         app.addKeyListener(new KeyAdapter() {
            public void keyPressed(KeyEvent keyevent) {
                //System.out.println("Test key press >>>>>>>>>>>>>>>>>>>>>>>>>>");
                app.snake.keyPressed(keyevent);
            }
        });
         app.setSize( DISPLAY_W, DISPLAY_H ) ;
         app.setTitle( "JaySnake Game" ) ;
         app.setVisible( true ) ;
         Splash splash = new Splash(app);

         new Thread(new Runnable()
              {
                   public void run()
                   {
                           try
                           {
                             app.playMusic();
                             Thread.sleep(200);
                        }
                        catch (InterruptedException e)
                        {
                             System.out.println(e);
                        }
                   }
              }).start();
    }


     
// *****************************************
    class MyKeyListener extends KeyAdapter {
        public void keyPressed(KeyEvent evt) {
             

            // Check for key characters.
            if (evt.getKeyChar() == 's' || evt.getKeyChar() == 'S') {
                System.out.println("s");
                JOptionPane.showMessageDialog(null, "Game start shortcut invoked");
                String name = new String();
                  name = JOptionPane.showInputDialog(JaySnake.this,  "Please enter your name", "Player name input box", JOptionPane.QUESTION_MESSAGE );
                  snake = new Snake(JaySnake.this, name, (soundForApple ? appleEaten : null));
                  gamePlay.resume();
            }
            else if (evt.getKeyChar() == 'p' || evt.getKeyChar() == 'P') {
                System.out.println("p");
                gamePlay.suspend();
                JOptionPane.showMessageDialog(null, "Press ok and an arrow key to resume!");
                /*
                try
                {
                     
                     //gamePlay.wait();
                }
                catch (InterruptedException ie)
                {
                     System.out.println(ie);
                }
                */
            }
              else if (evt.getKeyChar() == 'q' || evt.getKeyChar() == 'Q') {
                System.out.println("q");
                System.exit( 0 );
            }
            else
            {
                 gamePlay.resume();
            }
            /*
            // Check for key codes.
            if (evt.getKeyCode() == KeyEvent.VK_HOME) {
                System.out.println(evt.getKeyCode());
            }*/
        }
    }
// *****************************************

/*Render method for graphics content*/
    public void render( Graphics g )
    {
     if( backgroundImage != null )
        g.drawImage( backgroundImage, 0, 0, this ) ;

/*Draw scoreboard and player details, sets color for score and player
 *fills rectangle and text white and draws another rectangle that is used
 *to highlight the playing area*/
      g.setColor( Color.black ) ;      /*sets color to black*/
      g.fillRect( 0, 0, 598, 32 ) ; /*fillsRectangle for scoreboard*/
      g.setColor( Color.white ) ;   /*sets color to white for text*/
/*Draws text and uses score variables*/
      g.drawString( "Player 1 score: " + score1, 10, 13 ) ;
      //g.drawString( "Player 2 score: " + score2, 10, 27 ) ;
      g.drawString( "High score: " + highscore, 510, 15 ) ;


    }

  /******declared class variables/containers*/
  private Image backgroundImage ;
  private Snake snake = null;
/* The musicclip to be played.*/
  private AudioClip clip = null;
/* The sound of the applet when eaten.*/
  private AudioClip appleEaten = null;
// Indicate if we want sound for eating the apple (options = true/false)
  private boolean soundForApple = true;
}

many thnaks for all your helps!
0
Comment
Question by:pjcrooks2000
  • 12
  • 9
  • 2
  • +1
25 Comments
 
LVL 8

Author Comment

by:pjcrooks2000
Comment Utility
Sorry question says frame when it should say JEditorPane :)
0
 
LVL 92

Accepted Solution

by:
objects earned 250 total points
Comment Utility
If the html is only going to contain an image then you could use a JLabel instead of a JEditorPane.

To close it when clicked add a MouseListener to it.

comp.addMouseListener(new MouseAdapter()
{
   public void mousePressed(MouseEvent event)
   {
      frame.close();
   }
});
0
 
LVL 8

Author Comment

by:pjcrooks2000
Comment Utility
Objects the JEditorPane displays an Url that i have created, is there a way to do it with JEditorPane, any that you oknwo of that is...
0
 
LVL 8

Author Comment

by:pjcrooks2000
Comment Utility
The code snippet for it is here

userInstruct.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                System.out.println("Instructions button pressed");
                //Create new Jframe to view User instructions
                JFrame f = new JFrame();
                JEditorPane p = new JEditorPane("text/html", "");
                f.getContentPane().add(p); // was missing in the previous code snippet
                p.setEditable(false);
                URL instructions = getClass().getResource("instructions/index.html");
                try {
                    p.setPage(instructions);
                }
               
                catch (Exception ep) {
                   
                    System.out.println("Not Got index.html");
                }

                f.setSize(265, 540);
                f.setVisible(true);
               
               
            }                      
        });
0
 
LVL 3

Expert Comment

by:CI-Ia0s
Comment Utility
Add a MouseListener to p or f. You could then remove the JEditorPane from the frame or (if you don't need the frame) dispose the frame. I've shown both below:

f.addMouseListener(new MouseListener(){
public void MouseClicked(){
//To remove the JEP
f.remove(p);
f.validate();
//To dispose the frame
f.dispose();
}
});
0
 

Expert Comment

by:mohan_shenoy
Comment Utility
Make the image as a link. This should do it

final JFrame f = new JFrame();
JEditorPane p = new JEditorPane("text/html", "");
p.addHyperlinkListener(new HyperlinkListener() {
 
         public void hyperlinkUpdate(HyperlinkEvent e) {
                 if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
                   JEditorPane pane = (JEditorPane) e.getSource();
                   if (e instanceof HTMLFrameHyperlinkEvent) {
                       HTMLFrameHyperlinkEvent  evt = (HTMLFrameHyperlinkEvent)e;
                       HTMLDocument doc = (HTMLDocument)pane.getDocument();
                       doc.processHTMLFrameHyperlinkEvent(evt);
                   } else {
                       try {
                         f.dispose();
                       } catch (Throwable t) {
                         t.printStackTrace();
                       }
                   }
                 }
             }
     });
0
 
LVL 3

Assisted Solution

by:CI-Ia0s
CI-Ia0s earned 250 total points
Comment Utility
Whups. *berates self for going too quickly again...
The first line should be:
f.addMouseListener(new MouseAdapter(){

And objects is right, you can use a JLabel with an ImageIcon. i.e.:
ImageIcon instructionsIcon = new ImageIcon("picFileName.jpg");
JLabel instructionsLabel = new JLabel(instructionsIcon);
f.add(instructionsLabel);
0
 
LVL 92

Expert Comment

by:objects
Comment Utility
>  is there a way to do it with JEditorPane

the code I posted above will also work for a JEditorPane.
0
 
LVL 8

Author Comment

by:pjcrooks2000
Comment Utility
Looking  goodCI-Ia0s but one error on compile

I have this:::

userInstruct.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                System.out.println("Instructions button pressed");
                //Create new Jframe to view User instructions
                JFrame f = new JFrame();
                ImageIcon instructionsIcon = new ImageIcon("instructions/images/index.jpg");
                JLabel instructionsLabel = new JLabel(instructionsIcon);
                        f.add(instructionsLabel);
                        f.addMouseListener(new MouseAdapter()
                        {
                              f.dispose();
                              });
                   
            }});      

Error is:

JaySnake.java:283: <identifier> expected
                              f.dispose();
                                                 ^
1 error
0
 
LVL 3

Assisted Solution

by:CI-Ia0s
CI-Ia0s earned 250 total points
Comment Utility
You forgot "public void MouseClicked(){}". f.dispose() needs to be in a method ("public void MouseClicked()" to be specific). ;)

P.S. objects said pretty much the same thing, so he should get some credit too :P
0
 
LVL 8

Author Comment

by:pjcrooks2000
Comment Utility
Heh!  

Now i have:::


userInstruct.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                System.out.println("Instructions button pressed");
                //Create new Jframe to view User instructions
                final JFrame f = new JFrame();
                ImageIcon instructionsIcon = new ImageIcon("instructions/images/index.jpg");
                JLabel instructionsLabel = new JLabel(instructionsIcon);
                        f.add(instructionsLabel);
                        f.addMouseListener(new MouseAdapter(){
                              
                              public void MouseClicked(){
                              f.dispose();
                              }
                              
                              });
                   
            }});  

and my window is not opening---

Have i got a pack(); show(); missing or something ???
0
 
LVL 3

Expert Comment

by:CI-Ia0s
Comment Utility
Did you click the mouse at all? You could have disposed it too early... You might want to add a System.out.println("Disposed"); as a debug.
You didn't delete "f.setVisible(true);" did you? :P (Those are the only two things I can think of).
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 8

Author Comment

by:pjcrooks2000
Comment Utility
yep i deleted setVisible(true); and I need to set the size of it..... However it opens the window but the label does not show and it does not repond to being clicked

Heres the snippet updated with setVis and SetSize

userInstruct.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                System.out.println("Instructions button pressed");
                //Create new Jframe to view User instructions
                final JFrame f = new JFrame();
                f.setSize(300,300);
                      f.setVisible(true);
                ImageIcon instructionsIcon = new ImageIcon("instructions/index.gif");
                JLabel instructionsLabel = new JLabel(instructionsIcon);
                        f.add(instructionsLabel);
                        
                        
                        f.addMouseListener(new MouseAdapter(){
                              
                              public void MouseClicked(){
                              f.dispose();
                              }
                              
                              });
                   
            }});                      
             
0
 
LVL 3

Expert Comment

by:CI-Ia0s
Comment Utility
Set visible after you add the listener (preferable) or put in f.validate() after the listener (should do basically the same thing). Should work after that. :)
0
 
LVL 8

Author Comment

by:pjcrooks2000
Comment Utility
Just tried them in various locations, any ideas where exaclty I should put it?   Weird science!
0
 
LVL 3

Expert Comment

by:CI-Ia0s
Comment Utility
In between those two brackets at the end...
"}});" should be...

}
f.setVisible(true);
});

*crosses fingers*
0
 
LVL 8

Author Comment

by:pjcrooks2000
Comment Utility
Hmmm nope to that one!   Hmmmmmm
0
 
LVL 3

Expert Comment

by:CI-Ia0s
Comment Utility
Hrmmm... Quick question: if you put the f.setVisible(true) immediately after the JFrame, does it show up at all (even if it's blank)?

(Oh, and why is f final? That might have something to do with it, though I'm not sure... I know it's needed by "f.dispose()" but I think it would be better to declare it outside of a method than to make it final. It should probably be declared private static f = null; and then initialized f = new JFrame();).
0
 
LVL 8

Author Comment

by:pjcrooks2000
Comment Utility
Yes but does not show up if I put it lower down as you said before.   But its just a grey window no9 label or image in it.....
0
 
LVL 3

Expert Comment

by:CI-Ia0s
Comment Utility
Try making the changes to f I suggested and then putting it down low. It should work then...

If not, leave it up high where it was and put f.validate() down low.
0
 
LVL 8

Author Comment

by:pjcrooks2000
Comment Utility
Ok guys I am goinf to drop this one and use the original one i had working from an URL.  I won't be able to have it closing when it is clicked with the mouse.

I will split up the points and try to point to the most appropriate answer,  thank you all for your guidance it has been appreicated and we nearly got there with it.

I have to carry on with a report as it is due in tomorrow..... :)
0
 
LVL 8

Author Comment

by:pjcrooks2000
Comment Utility
I hope that is fair :)
0
 
LVL 3

Expert Comment

by:CI-Ia0s
Comment Utility
:( It should be working... but then again, you should see my thread about Java running 2 threads concurrently... *rolls eyes* I suppose Java isn't perfect (nor are we, for that matter).
0
 
LVL 8

Author Comment

by:pjcrooks2000
Comment Utility
yes good point. but I suppose we and Java still have to evolve yet!

Not to worry my friend, Its not a major issue just a little niggle to have to close it by pressing the x in the corner.   Big deal hey and if she complains about that I might just have to ...well sulk in the corner :)

Thanks for the help,  by the way please look at my question here i need to try and get that working I just need some help with it http://www.experts-exchange.com/Programming/Programming_Languages/Java/Q_21111604.html  After all I am still learning .....

cheers

pjcrooks2000
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now