JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Line 111. Shouldn't that be props.put("mail.smtp.host", host); ?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Assuming you are using Windows, the info you need is here:
http://download.oracle.com/javase/tutorial/getStarted/cupojava/win32.html
Linux is here:
http://download.oracle.com/javase/tutorial/getStarted/cupojava/unix.html

In addition you will need to download javax.mail from the Oracle Java website.
http://www.oracle.com/technetwork/java/javamail/index.html

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

No, the enums are great - try something like:

ArrayList<Card> pack = new ArrayList<Card>(52);
for (Suit s : Suit.values())
  for (Value v : Value.values())
    pack.add(new Card(v, s);

now you can draw a card realistically with something like

pack.remove(rand.nextInt(pack.size() - 1));
Bladtman242 commented: Solved my problem :) +3
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Using a null layout manager is usually a mistake - layout managers are there for good reasons (different system font sizes on different machines, different screen resolutions, user-resizable windows...). This trick is to chose the simplest layout manager that does what you need. That usually means BorderLayout, FlowLayout, BoxLayout, or GridLayout. Remember a Panel can have a different layout manager from the frame that its in.
Here's a good place to start:
http://download.oracle.com/javase/tu...ut/visual.html

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Final comment: I think your instincts re "efficient and logical" may be misleading you in this particular case. 8k is a small number on today's typical machine, with processor speed measured in GigaHz and memory in GigaBytes. Remember also that "load on demand" will carry its own overheads both in data structures, execution overheads, and code size, not to mention effort for coding debugging and maintenance. Clearly it's a trade-off, so before investing significant effort in the more complex solution you should be very sure that there is an actual problem with the simple solution.

ps: If you really want to try load on demand then you start by creating a class that implements TreeModel. In your implementations of getChildCount and getChild you need to keep track of whether the necessary info has been loaded, and load it if necessary. You will probably need some careful optimisation of the load code, as you may end up (eg) doing many small SQL select statements as opposed to one full-sized one.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Not a bad start. You may be missing one class because your Trade class represents both individual Trades (buy/sell), but also has the list of Users and Shares. Users and Shares belong to a StockMarket. In the StockMarket you can register and delete Users and Shares, and create many Trades. Every Trade represents on a given date, one User buying a quantity of a Share from another User for a given price. (Which is the same as selling when seen from the second User's viewpoint.)
Now have a second look at the atributes - eg a Share's bid and offer prices keep changing, and maybe they aren't important to this application, but every Trade is done at a definite price that never changes. eg a User may have made many Trades...

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

What Norm says is true. IMHO it's a no-brainer because approach (1) deals with the objects themselves, while approach(2), while it updates the image OK, doesn't address the question of what exactly was the thing you moved.

Just for fun I knocked up this little demo of approach 1 with draggable objects (sprites) and lines connecting them. Feel free to have fun with it.

import java.awt.*;
import java.awt.event.*;
import java.util.ArrayList;

import javax.swing.*;

public class Demo {

   public static void main(String[] args) {
      new Demo();
   }

   JFrame frame = new JFrame("drag demo");

   ArrayList<Sprite> sprites = new ArrayList<Sprite>();
   ArrayList<Line> lines = new ArrayList<Line>();

   Demo() {

      frame.setMinimumSize(new Dimension(400, 300));
      frame.setLocationRelativeTo(null);
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

      DrawPanel drawPanel = new DrawPanel();
      drawPanel.setLayout(null);
      frame.add(drawPanel);

      Sprite sprite = new Sprite("drag me");
      sprite.setBounds(10, 10, 50, 15);
      sprite.setForeground(Color.blue);
      drawPanel.add(sprite);
      sprites.add(sprite);

      sprite = new Sprite("and me");
      sprite.setBounds(100, 40, 50, 15);
      sprite.setForeground(Color.red);
      drawPanel.add(sprite);
      sprites.add(sprite);

      sprite = new Sprite("and me too");
      sprite.setBounds(300, 90, 65, 15);
      sprite.setForeground(Color.green);
      drawPanel.add(sprite);
      sprites.add(sprite);

      Line line = new Line(sprites.get(0), sprites.get(1));
      lines.add(line);
      line = new Line(sprites.get(1), sprites.get(2));
      lines.add(line);

      frame.setVisible(true);
   }

   class Sprite extends JLabel implements MouseListener, MouseMotionListener {
      
      // A sprite is a movable draggable object

      public Sprite(String text) {
         super(text);
         addMouseListener(this);
         addMouseMotionListener(this);
      }

      public Point getConnector() {
         // returns point where connecting line(s) should meet this sprite
         return new Point(getX() + getWidth() / 2, getY() + getHeight() / 2);
      }

      @Override
      public void paintComponent(Graphics g) {
         // can do custom drawing here...
         super.paintComponent(g);
      }

      int startDragX, startDragY;
      boolean inDrag = false;

      @Override
      public void mouseEntered(MouseEvent e) {
         // not …
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Have a look at the SimpleDateFormat class. You will find it has methods to convert (parse) Strings in various formats into Dates that you can add to your list.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

If you look at the correct solution you will notice that each pair consists of an element and a second element that comes later in the array, ie

for each element i in codesArray
  for each element j that appears after i in codesArray
    pairThese(i,j)
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

If you are a complete beginner with Java then going straight to netbeans (or eclipse etc) is not a good idea. (1) A full IDE has its own steep learning curve to add on top of the Java learning curve, (2) A full IDE's tools will fix problems for you without you ever getting to understand what the problem was or why the fix worked.
Much better to start with a decent programmer's editor and command line compile/test until you have built up some Java expertise, then look at Netbeans or Eclipse.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Line 196
It's the same mistake that has already been pointed out to you twice.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

You could easily separate the SQL part (around lines 52-68) into a method with the signature
public ResultSet getDataFor(String user, String password)
and that method could be in a different class. That would make the code easier to understand and maintain.

But ideally though it would be better to separate the GUI aspects from the SQL aspects completely. How this usually is done is by looking at the "meaning" of the data that is being returned - for example the result set may represent a number of Students, or CompactDisks, or Vehicles or whatever. In that case there will usually be a class that represents those things. Now you can have an SQL-based class that does the select and creates (eg) Student objects from the rows of the result set
public List<Student> getStudents(String userID, String password)
the GUI class can call that method, then populate the table with the data in those returned Student objects.
That way the SQL is kept entirely in one class, the GUI is kept entirely in another, and what links them is the Student class, which is independent of both the SQL and the GUI.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

you hv to take container class refernce
like contaner c; // before constructor
then c=getContentPane(); //in the starting of constructor
c.add(start); /*after the buttons setbounds
c.add(controls);
c.add(credit);

This code is obsolete.
The need to add things to the content pane, rather than just the JFrame, was an annoyance in early versions of Java, but this was fixed in Java 1.5. In 1.5 and later you just add components to the JFrame, and don't need to worry about the content pane.

(LevyDee had the right answer)

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Provided all your code is in one package you can use protected, or just leave the visibility blank - its the same (see the link I sent earlier). It will work for all your variables, so if it appears to be just x and y then there's something else wrong as well.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Remove the "private" and you will be able to access the superclass variables in the subclasses.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Yes, card is a LinkedList, and LinkedList overrides toString to return a comma-delimited string enclosed in {} and containing the results of calling toString on each of the elements in the list in turn. Very useful.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

print(anyObject) automatically calls anyObject.toString() to get a printable version. All objects inherit a version from the class Object, which shows the class name and a hex reference for the particular instance, eg "Deck@6612fc02".
You can override toString in your own classes to print something more useful.
You did this for Card, but not for Deck. And before you disagree with me, look again more closely at Deck line 23.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

If you don't get 3 better contributions, feel free to use this. You should be able to run it. I wrote it as a quick check for how CPU usage scaled with number of sprites. I removed the comments as requested, but feel free to ask questions.
J

ps: It was >250 before I removed the comments!

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

import java.lang.reflect.Field;
import java.util.ArrayList;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.Timer;

public class Animation extends JPanel implements ActionListener, KeyListener {

   private static final long serialVersionUID = 1L;
   final Timer timer;
   public final static int TIMER_MSEC = 50;

   Animation(int width, int height) {
      setPreferredSize(new Dimension(width, height));
      setFocusable(true);
      addKeyListener(this);
      timer = new Timer(TIMER_MSEC, this);
      timer.start();
   }

   @Override
   public void actionPerformed(ActionEvent arg0) {
      ArrayList<Sprite> temp = new ArrayList<Sprite>(Sprite.sprites);
      for (Sprite s : temp)
         s.update();
      repaint();
   }

   @Override
   public void paintComponent(Graphics g) {
      Graphics2D g2d = (Graphics2D) g;
      g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
            RenderingHints.VALUE_ANTIALIAS_ON);
      paintBackground(g2d);
      for (Sprite s : Sprite.sprites)
         s.draw(g2d);
   }

   void paintBackground(Graphics2D g2d) {
      g2d.setColor(Color.white);
      g2d.fillRect(0, 0, getWidth(), getHeight());
      g2d.setColor(Color.gray);
      g2d.drawString("type r,g, or b for new ball, p to pause", 10, 20);
   }

   @Override
   public void keyPressed(KeyEvent arg0) {
   }

   @Override
   public void keyReleased(KeyEvent arg0) {
   }

   @Override
   public void keyTyped(KeyEvent arg0) {
      // System.out.println("KeyTyped: " + arg0.getKeyChar());
      switch (arg0.getKeyChar()) {
      case 'p': { // toggle pause
         if (timer.isRunning()) timer.stop();
         else timer.start();
         break;
      }
      case 'r': {
         BouncingBall ball = new BouncingBall(this, 0, 100, 10, 0);
         ball.setColor(Color.red);
         ball.setPhysics(2, .02f); …
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

yes! It really is that easy!
Now you have to decide what you are going to do with that new Products instance.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Like I said, provided it's coded sensibly (esp. use buffered streams) it will be limited by your disk hardware read/write speed. The only way to improve beyond that would be a disk upgrade (SSD).
IMHO the "best" choice of language would be "the one you are most comfortable writing in". Performsnce/efficiency of the language won't be an issue.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

How big is "very large"? As long as it's under, say 100Meg, you could just read it into memory, update it there, write it back. As long as its under 2Gig you would have to read/write on the fly. Either way it's going to run as fast as your disk can read and write.

If this really is a big problem you should look at a better file structure, eg each line = 1 record, each record has a pointer to the next. Then you can update a line by writing the new version to the end of the file and updating the relevant pointer in place.

warlord902 commented: awesome answer :) +3
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

No, no need to do anything like that.
You have a perfectly good constructor already. You just have to call it from around line 52. Check out how to calla constructor to create a new instance of a class.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

By line 52 you have variables containing the id, name, category and price.
At line 18 you have a constructor that takes id, name, category and price and creates a Products instance.
So all you need to do is call the constructor passing the values.. easy peasy!

ps: Each instance of your class represents one Product, so your code will read better if you call it Product rather than Products.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Two ways:
1: Do some arithmetic using i and j
the first row is 1,2,3,4
The second is 5,6,7,8 which is also 4+1, 4+2, 4+3, 4+4
The third is ... 8+1, 8+2 etc see the pattern?
2: you have a nested loop that you can use to access all the array elements in order (see Majestic's post as well). You need to put 1 in the first, 2 in the second... 16 in the last. You can do this with a simple "counter" variable that starts at 1 and adds 1 each time you use it.

JeffGrigg commented: Excellent answer to homework question: Sends the student in the right direction without giving them the answer. +4
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

You can subclass JToolTip to create a custom appearance etc, then subclass the control in question to override its public JToolTip createToolTip() method (inherited from JComponent) to return an instance of your customised JToolTip subclass.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Check the API reference. A JToggleButton is "An implementation of a two-state button. The JRadioButton and JCheckBox classes are subclasses of this class"
A JButton is "An implementation of a "push" button."

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

In checkCourse you continue to loop and re-set "matched" after finding a match, so it will only return true if the string matches the very last element in the array. You need to exit the loop as soon as you find a match.
Assuming courseObjects[] is some kind of variable, there's no need for the courses[0].

ps
if (courses[0].checkCourse(tempCourse) == true)
is horribly redundant. What's wrong with
if (courses[0].checkCourse(tempCourse))

Java coding standards suggest methods that return a boolean should have a name that starts "is" to make their meaning absolutely clear.
Applying all the above you could write
if (isAValidCourseName(tempCourse))

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

That's an "enhanced for-each loop" - a new feature in Java 1.5
It uses and array or any other collection (eg List) of things, and iterates thru them one at a time.
In your case closest is an array of "P" objects, and the for loop is read as

for each P object "p" in the array closest...
... print p

Local variable p is set to the first element of closest, and the body of the loop is executed. p is them set to next element etc etc.
It's like

for (int i = 0; i < closest.length; i++) {
  P p = closest[i];
  System.out.println(p);
}

... or the equivalent for collections and lists.

It's generally considered to be an easier and clearer syntax, and it avoids the traps people sometimes fall into with iterators.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

I want to create a new variable with each run of this while loop ... like str1(for 1st run),str2(for 2nd run) and so on

Short answer: you can't create new variables names like that at runtime. That's what arrays are for - str[1]. str[2] etc. Why do you think you need to create new variable names?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

To open the appropriate registered application and open a file eg test1.java you can
(1) use processbuilder and explicitly specify the application or
(2) use Java 1.6's desktop integration to do it all for you
http://java.sun.com/developer/technicalArticles/J2SE/Desktop/javase6/desktop_api/
(the relevant bit is right at the bottom)

I recommend option (2)

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

I can't speak about the C++ side, but Java TCP/IP is just plain old vanilla TCP/IP. I've had no problems using it to communicate with TCP/IP-based embedded systems that certainly are not Java.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

What OS are you using? Under Windows that should be
echo %PATH%

ps: Have a look at the ProcessBuilder class in Java 1.5 and later - it's intended as a better replacement for Runtime.getRuntime().exec()

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Yes, the serial ID and runnable would be used in a real app- I left them out because they weren't essential to the demo point.
But, by removing the getContentPane on your line 21 you have broken it. It's now 150x150 including the frame. The whole point of this is that the OP wanted to specify the size of the content area, excluding the frame, which is what my code does.
J

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Didn't read all yuor code, but you cant do an implicit multiply with brackets, eg a(b+c) in Java. In Java that looks like a call to method a with parameter value b+c. You have to use an explicit multiply operator, a*(b+c)

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Override paintComponent, not paint. This restricts your (re)paint to the client area only. Do not override repaint, just call it when necessary.
Do not call super.paintComponent in your paintComponent, because that's where the old content is being cleared. Just go ahead and paint the new stuff.
For more details see the second half of this:
http://java.sun.com/products/jfc/tsc/articles/painting/

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Although the API doc is the essential definitive reference material, it's organised for retrieval rather than learning. Don't forget the Java tutorials, eg
http://download.oracle.com/javase/tutorial/uiswing/components/combobox.html

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Hi balajisathya88
Please be aware that there is a policy on this forum of not just giving people the code they need for their homework. People learn best if you point them in the right direction (eg a tutorial, or the name of the class/method they need), then let them practice doing their own research and developing their own code which they will fully understand. You would have helped the OP better by saying something like "check out the Random class and its nextInt() method"
ps Your code violates standard Java naming conventions by having a lower-case class name; not such a good example,

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

How could JLabel maintain a reference to an another object?

Through its client property map (just thought I'd mention it).

Ezzaral commented: Good suggestion too. I always forget about that. +15
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

You could extend JLabel to maintain a reference to the object, in which case the listener could retrieve it directly from the clicked label...

This would be the obvious strategy, but there's no need to extend JLabel to achieve it.
Every swing component has a "client property" map where you can put and get whatever objects you want relating to that JComponent.

// when creating the JLabels...
theJLabel.put("kortti object" , theRelevantKortti);

// in the event handler
Kortti theRelevantKortti = (Kortti) e.getSource.get("kortti object");

IMHO JComponent client properties are a good candidate for the "most valuable yet totally underused" feature in Swing.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

A statement like that needs to be inside a method (eg the constructor)*

* yes,there are other places, but they're not in the Java 101 syllabus.

JeffGrigg commented: Short. To the point. Helpful. +3
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Check out the Java Language Reference, chapter 10.
http://java.sun.com/docs/books/jls/third_edition/html/arrays.html
This is the ultimate source of answers to questions like that.
JC

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Stop thinking about 2d arrays. Java arrays are one-dimensional. It's just that the data type for a java array can itself be an array, so you can nest arrays within arrays (etc). It just so happens that a java array whose elements are arrays all of the same length looks like a 2D array, but really that's just a special case, not a starting point.
So you have an array, one element for each line of your file. Each of those elements is itself an array of the tokens from that line.
Now, with that in mind, the code goes like this:
1. Declare array of array of Strings String[][] data; 2. Get the number of lines in the file and use that to allocate the outer array data = new String[noOfLines][]; 3. Read each line and split it into an array of Strings - something like String[] tokens = inputLine.split(","); 4. Put that array into the outer array data[i] = tokens; Remember guys, Java is not C

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Hi, JC here again. Could you be referring to my prior post? If so. thank you.
In real life people use complex tools (UML modelling) to do this kind of thing, but for starters I would recommend keeping it simple and low-tech. I've used this technique many many times when mentoring teams on their first OO project:
1. Use the "underline the nouns" technique to get a candidate list of classes. Tidy up obvious duplicates etc, but don't try to get it perfect yet.
2. Get a load of cards or small sheets of paper, one per class, and write the name of one class at the top of each sheet.
3. Now use the "underline the verbs" technique to identify candidate methods and write those on the card for the class that seems most likely to be able to implement such a method.
4. Tidy up, but don't try to get it perfect yet.
5. (This is the fun bit). Look at the first scenario ("use case") as a whole. Spread all the cards out in front of you. Step through the use case identifying which methods in which classes need to get called by who to make it all happen.
You will immediately discover some missing classes, if only for the user interface. Write more cards for those. Eventually you should be able to step through a use case by following the complete trail of method calls through all the classes.

kvprajapati commented: :) +15
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Correct.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

The way you posted the code the classes were instance inner classes, so you couldn't instantiate them from static main without an instance of the outer class.
Anyway, this is the cleaned up version that worked for me:

public class Demo {

   public static void main(String[] args) {
      new Demo();
   }

   Demo() {
      superclass newobj;
      for (int x = 0; x <= 1; x++) {
         if (x == 0) {
            newobj = new class1();
            // newobj = (class1) newobj;
         } else {
            newobj = new class2();
            // 
            newobj = (class2) newobj;
         }
         newobj.testfunc();
      }
   }

   private class superclass {

      public void testfunc() {
         System.out.println("superclass");
      }
   }

   private class class1 extends superclass {

      int specialvariable;

      public void testfunc() {
         System.out.println("class1");
         specialvariable = 100;
      }
   }

   private class class2 extends superclass {

      int specialvariable2;

      public void testfunc() {
         System.out.println("class2");
         specialvariable2 = 100;
      }
   }
}

Main thing is that your final try was exactly on the right lines. I don't know why your actual code wasn't working

ps If your actual app already has those classes extending something else, you can define an interface with the common method name(s) and have them all implement that.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Here, just for fun, is runnable demo of just how easy it is to drag a JLabel around a container and log the final position. The trick is to remember that the mouse event coordinates are relative to the object being dragged, not the container, so you have to see how much the mouse has moved, and move the JLabel by the same amount.
I deliberately left out the comments to give everyone a learning opportunity ;-)

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class Demo implements MouseListener, MouseMotionListener {

   public static void main(String[] args) {
      new Demo();
   }

   JLabel sprite = new JLabel("drag me");

   Demo() {
      JFrame frame = new JFrame("drag demo");
      frame.setLayout(null);
      frame.setMinimumSize(new Dimension(400, 300));
      frame.setLocationRelativeTo(null);
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

      sprite.setBounds(10, 10, 80, 20);
      sprite.addMouseListener(this);
      sprite.addMouseMotionListener(this);
      frame.add(sprite);

      frame.setVisible(true);
   }

   int startDragX, startDragY;
   boolean inDrag = false;

   @Override
   public void mouseEntered(MouseEvent e) {
      // not interested
   }

   @Override
   public void mouseExited(MouseEvent e) {
      // not interested
   }

   @Override
   public void mousePressed(MouseEvent e) {
      startDragX = e.getX();
      startDragY = e.getY();
   }

   @Override
   public void mouseReleased(MouseEvent e) {
      if (inDrag) {
         System.out.println("Sprite dragged to " + sprite.getX() + ", " + sprite.getY());
         inDrag = false;
      }
   }

   @Override
   public void mouseClicked(MouseEvent e) {
      // not interested
   }

   @Override
   public void mouseDragged(MouseEvent e) {
      int newX = sprite.getX() + (e.getX() - startDragX);
      int newY = sprite.getY() + (e.getY() - startDragY);
      sprite.setLocation(newX, newY);
      inDrag = true;
   }

   @Override
   public void mouseMoved(MouseEvent arg0) {
      // not interested
   }

}
mKorbel commented: lots of fun +1 +9
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

If you can't be bothered to post your code properly formatted in code tags (as I requested before) and without any indication as to what your question might be... then I can't be bothered to read it.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Short version: set your own default renderer for that cell or column using a subclass of JButton.
Full version:
http://download.oracle.com/javase/tutorial/uiswing/components/table.html#renderer

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Can't you create the animation with flash then save it as a gif? eg:
http://www.ehow.com/how_2200108_publish-animated-gif-flash.html

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

My main aim is to provide a startup animation , so application before start produce a good effect on the user, like word, excel etc...

You should have said that earlier. It's easy. Java 6 has a "splash screen" capability that displays an image while your app is loading, and that image can be an animated gif.

http://download.oracle.com/javase/tutorial/uiswing/misc/splashscreen.html