Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Painted, basically.
It depends on what you have put the icon on. It could be on a component or drawn directly to a graphics reference.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

JPanel does not have an addActionListener() method.

Perhaps you should use JButtons or use a MouseListener for your panel instead of ActionListener.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

That depends entirely on what you have rendered it on.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster
void actionPerformed(ActionEvent e) {
  JButton pressedButton = (JButton)e.getSource();
  int xPos = pressedButton.getX();
  ...
}
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

And hopefully learn valuable lessons from that failure.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

MouseOverExample is just the top level frame class and has nothing at all to do with the Glyphs. It's just a window for the PaintPanel. There is no need for the constructor you're created for it and no need to create additional instances of it in your code.

As far as the GradientPaint, you cannot simply replace the Rectangle instance inside the Glyph class with a GradientPaint and expect everything to work the same. Those are two completely different things. The Rectangle is a Shape, which you are drawing. The GradientPaint is the paint used to render that shape. Here is the Glyph class modified to use a GradientPaint to fill the rectangle.

class Glyph {
    private Rectangle bounds;
    private Color color;
    private Paint paint;
    private String label;
    private boolean showLabel = false;

    public Glyph(int x, int y, int width, int height, Color color, String label) {
        bounds = new Rectangle(x, y, width, height);
        this.color = color;
        // create GradientPaint that runs top to bottom from 'color' to white
        this.paint = new GradientPaint(x, y, color, x, y+height, Color.WHITE);
        this.label = label;
    }

    public void draw(Graphics g){
        Graphics2D g2 = (Graphics2D)g;
        //g2.setColor(color);  /** Use setPaint() instead */
        g2.setPaint(paint);
        //g2.draw(bounds); /** Use fill() instead */
        g2.fill(bounds);
        if (showLabel){
            g2.setColor(Color.BLACK);
            int labelWidth = g2.getFontMetrics().stringWidth(label);
            int fontHeight = g2.getFontMetrics().getHeight();
            g2.drawString( label, 
                (int)(bounds.getX() + (bounds.getWidth()-labelWidth) / 2), 
                (int)(bounds.getY() + (bounds.getHeight()+fontHeight/2) / 2d));
        }
    }

    public boolean contains(int x, int y){
        return bounds.contains(x,y);
    }

    public void showLabel(boolean show){
        showLabel = show;
    }
}
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

No, a statement is a single SQL statement. You can batch them into transactions and commit them as a unit if you wish, but each statement still needs to be executed individually. You could write a stored procedure and call it with a CallableStatement if you wanted to go that route.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

As I already posted, and so did javaAddict:
use executeUpdate().

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Use

Pattern.compile("(\\d{7,8}).txt");

and retrieve it with group(1).

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

For a quick all-in-one installation, I'd recommend WampServer or XAMPP.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Well, the first hint would be the exception itself, which you did not specify here.

I would recommend using executeUpdate() which returns the number of rows affected instead of executeQuery(), which return a result set.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

The Computer Science forum is for such discussions.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You may want to look into Regular Expressions as well.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Ok, here's a small example using a Glyph class that internally uses Rectangle to manage its bounds and shows a label when moused over:

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionListener;
import java.util.ArrayList;
import java.util.List;
import javax.swing.JFrame;
import javax.swing.JPanel;

public class RectangleMouseover extends JFrame {
    
    private JPanel paintPanel;

    public RectangleMouseover() {
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        setMinimumSize(new Dimension(300, 300));

        paintPanel = new  PaintPanel();
        getContentPane().add(paintPanel, BorderLayout.CENTER);
        pack();
    }

    class PaintPanel extends JPanel implements MouseMotionListener {
        private List<Glyph> glyphs;
        
        public PaintPanel(){
            super();
            addMouseMotionListener(this);

            glyphs = new ArrayList<Glyph>();
            glyphs.add(new Glyph(25, 15, 60, 30, Color.BLUE, "Blue node"));
            glyphs.add(new Glyph(75, 60, 50, 60, Color.ORANGE, "Orange node"));
        }
        
        public void paintComponent(Graphics g) {
            super.paintComponent(g);
            for (Glyph glyph : glyphs){
                glyph.draw(g);
            }
        }

        public void mouseDragged(MouseEvent e) {}

        public void mouseMoved(MouseEvent e) {
            for(Glyph g : glyphs){
                g.showLabel( g.contains(e.getX(), e.getY()) );
            }
            repaint();
        }
    }

    class Glyph {
        private Rectangle bounds;
        private Color color;
        private String label;
        private boolean showLabel = false;

        public Glyph(int x, int y, int width, int height, Color color, String label) {
            bounds = new Rectangle(x, y, width, height);
            this.color = color;
            this.label = label;
        }

        public void draw(Graphics g){
            Graphics2D g2 = (Graphics2D)g;
            g2.setColor(color);
            g2.draw(bounds);
            if (showLabel){
                g2.setColor(Color.BLACK);
                int labelWidth = g2.getFontMetrics().stringWidth(label);
                int fontHeight = g2.getFontMetrics().getHeight();
                g2.drawString( label, 
                   (int)(bounds.getX() + (bounds.getWidth()-labelWidth) / 2), 
                   (int)(bounds.getY() + (bounds.getHeight()+fontHeight/2) / 2d));
            }
        }

        public boolean contains(int x, int y){
            return bounds.contains(x,y);
        }

        public void showLabel(boolean show){
            showLabel = show;
        }
    }

    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable()
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I would highly recommend Code Complete, 2nd Edition. It covers a lot of stuff that you just don't find in tutorials or text books.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

He isn't referring to the space between the type and the variable name.

String name;

is just fine.
It is these

int item number;
    int number of units;
    int price per unit;

that are not allowed.
Generally they would instead be written

int itemNumber;
    int numberOfUnits;
    int pricePerUnit;
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Look for other unmatched double quotes :)
Those were the only two in the fragment you posted, but there may be others.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Ganymede was just the release bundle name for 3.4 as I understand it. You may not find a lot of information targeted specifically at 3.4, but other RCP tutorials should still be relevant on most of the basics I would think.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Looks to me like an extra " at the end of lines 12 and 13.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

So post back your thoughts on them for us when you're finished :)

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Set a breakpoint on the line you want to stop upon. Then use step over (F8), step into(F7), etc. to step though as needed. You'll need to running in debug mode for that of course ("Debug Main Project" or "Debug File")

It's all covered in the help file for your reading pleasure.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You may find a few different ways to accomplish it, but basically it's going to involve steps similar to that example.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Anything like that is going to be a custom header renderer - which as you noted is "hundreds of lines". It's not a trivial thing that you do in a couple of lines of code. I assume you ran across this implementation: http://www.esus.com/docs/GetQuestionPage.jsp?uid=1272

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

That is the online version of the same book linked above. It can also be downloaded as html or pdf. (http://java.sun.com/docs/books/jni/)

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Why do you need to "get rid of" the mouse click event? Do you mean that you do not want to allow editing or selection of certain parts?

If you only need 2 cells, why not just use two text fields? You need to give a little more info about what you're trying to achieve if you want specific suggestions.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You've defined your own Rectangle class, so you can't expect to use the java.awt.Rectangle method contains() for a hit test on that. You could change your class a little to keep a java.awt.Rectangle internally for it's bounds and use that for the hit testing and stuff.

For the tooltip behavior, I think you'd have an easier time just using JLabels for your rectangles, which already have a tool tip that you can just set directly, instead of your custom class. You can also set their size, location, text, and background color directly on JLabels and you inherit a ton of JComponent methods for handling other UI behaviors if you need them.

If you decide to stick with a class that uses a Rectangle and rendering it yourself, I would recommend moving the rendering code into the class itself by adding a draw(Graphics g) method and passing in the graphics reference. You can then draw the label string yourself if need be and your frame class doesn't have to keep track of all of the pieces. Your paintComponent() methods would just loop your List and call draw() on each of them.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

It really depends on how you want your application to behave. It's not always a bad choice to have multiple top-level windows. Sometimes it can be very desirable. Our particular application here has many components that open in separate frames and it's very convenient for our users. Each of these frames is a separate component working within the context of a particular data analysis project and can receive notifications from a central application controller for purposes of data stream navigation and coordination. The users all have multiple monitor set-ups and arrange the various components as they like for a particular task.

That said, I would agree that it's not a good choice to create and destroy the top-level windows for the purpose of switching screens in an app that is designed to operate in a single screen context and does not utilize multiple windows open at one time.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster
String time = String.format("%d:%02d", hours, minutes);
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

If you read further down and walk through their example, it becomes a little more clear what they mean and they demonstrate using the PropertyChangeSupport class as a helper. Basically, your methods that alter the bound properties need to also fire change events so that change listeners get notified, ie they have to announce "Hey, I changed this"

pcs.firePropertyChange( "title", old, title );

Your bean class also has to provide the methods to add/remove property change listeners

public void addPropertyChangeListener( PropertyChangeListener listener )
{...

as they show in their little demo class. The methods they show there just forward the listener reference along to the PropertyChangeSupport object that is managing all that for you.

There is a more detailed, step-by-step walkthrough of implementing this here.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You are using a format string that applies to a Calendar instance with int parameters. If you already have the hours and minutes as int, use String.format("%d:%d", hours, minutes); instead.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You probably have the default close operation set to EXIT_ON_CLOSE, which will indeed call System.exit(0). You can instead set that to DISPOSE_ON_CLOSE or another option of your choosing with the JFrame.setDefaultCloseOperation(int) method. The available constants are listed there in the API doc.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

There are also other text components depending upon the functionality you need. You can read more about them here: Using Text Components

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Well, sure, except for three things:
1) it's C and this is the Java forum
2) If you are going to hard-code the whole pattern, why would you bother to use 1 and 0 to encode it just so you can translate it back with if() statements to the '*' you want to print? You may as well just put the asterisks in an array and print it in that case.
3) I would assume figuring out the loop logic is a goal of the assignment.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Post your initial code that is drawing the rectangles. As a general suggestion, keep a List containing java.awt.Rectangle objects for each entry you have to draw. Your mouseMoved and mouseClicked method implementations can easily test against those Rectangle objects by their contains() methods.

Alternately you could use a null layout and JLabels or a small JComponent class for your rectangles, which would manage some of the mouseover handling for you.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Just change it to extend JPanel and drop the calls to getContentPane() when you add your components. They are added directly with add(). Your main() code will need to create a JFrame to display the panel of course.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I'll point you to the prominent announcement at the top of the forum: http://www.daniweb.com/forums/announcement9-2.html

Simply posting your assignment with "Urgent help needed" doesn't show a lot of effort and sounds identical to "Do my homework for me!" and that's just not how things work around here.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You're off to a great start here: two posts pleading for help with absolutely no demonstrated effort to solve the problems.

You do realize you're going to have to actually think about these problems, yes? Post the code you have. Post intelligent questions about the parts that are confusing you.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

First, you need to realize that Java != Javascript. There is a separate forum for Javascript. I've requested that one of the mods for this section move it there for you.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

There are plenty of tutorials to be found on simple animation. Here's one to get you started: http://www.krhs.net/computerscience/java/sanimat1.htm

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

...

User: Nah, you're Ashamed.

Cleverbot: I am Nive Cleverbot.

User: You are Ashamed.

Cleverbot: I'm not! I'm Nick.

User: Just making things up now, eh?

Cleverbot: You will not be lonely if you are talking with me.

User: I'm not lonely.

Cleverbot: You're overworked.

User: No, I don't think so.

Cleverbot: I have to go to bed.

User: Baloney, you aren't going anywhere.

Cleverbot: Yes I am.

User: Oh? Where?

Cleverbot: To a store.

User: What happened to bed then?

Cleverbot: I'm not sure.

User: You should drink more whiskey then.

Cleverbot: I do not like MIller.

User: Me either. It's nasty stuff.

Cleverbot: Why?

User: Who knows?

Cleverbot: Are you happy?

User: Would you be happy if I were happy?

Cleverbot: No. I'd be glad.

User: Glad makes sandwich bags.

Cleverbot: I wish I had things to distract myself from thinking about love.

User: Think about sandwich bags.

Cleverbot: Ok, but Monday is... Tomorrow.

User: But tomorrow it will be Today.

Cleverbot: Then what shall we do tomorrow?

User: I won't be doing anything with you.

Cleverbot: How so?

User: So how>.

Cleverbot: Sow ho?

User: Oh Wos!

Cleverbot: What is your name?

User: You are Ashamed.

Cleverbot: No.

User: You keep denying that.

Cleverbot: I have to now.

User: No, you can admit it.

Cleverbot: How about you?

User: How about me?

Cleverbot: What about you?

User: Why about you?

Cleverbot: So?

User: Because?

Cleverbot: Because you're crazy!

User: And you're Ashamed.

Cleverbot: You found it.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You could use Scanner if you wish, but I think splitting on one or more whitespace characters would be easier: split("\\s+")

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

My bad, you would want to use Float.parseFloat(String) for that particular comparison.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

String.split() would work just fine. You can use a basic structure like so

BufferedReader reader = new BufferedReader(new FileReader("someFile.txt"));
String line = null;
while ( (line=reader.readLine()) != null){
    // Splitting the read line on a single space, 
    // if it's tab delmited, use "\t" instead
    String[] columns = line.split(" ");

    // Check the value of fourth column
    if (Float.valueOf(columns[3]) > 0.9f){
        // do something with third column data, columns[2]
    }
}
reader.close();

(Exception handling, etc. left out for brevity)

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

There is a link at the bottom of the thread to "Mark as Solved". I've marked this one for you :)

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

It seems that there is another pattern operating here: methods that access a private field which will never be set from outside the class are simply named after the field.
Has anyone seen this documented? Is there some other explanation?

Well, the JLS makes the following recommendation on method names

6.8.3 Method Names
Method names should be verbs or verb phrases, in mixed case, with the first letter lowercase and the first letter of any subsequent words capitalized. Here are some additional specific conventions for method names:

* Methods to get and set an attribute that might be thought of as a variable V should be named getV and setV. An example is the methods getPriority and setPriority of class Thread.
* A method that returns the length of something should be named length, as in class String.
* A method that tests a boolean condition V about an object should be named isV. An example is the method isInterrupted of class Thread.
* A method that converts its object to a particular format F should be named toF. Examples are the method toString of class Object and the methods toLocaleString and toGMTString of class java.util.Date.

Whenever possible and appropriate, basing the names of methods in a new class on names in an existing class that is similar, especially a class from the Java Application Programming Interface classes, will make it easier to use.

That does explain length() and size(), but I'm not …

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Have you read through the documentation on the SQLite site and the SQLite Wiki FAQ? What other questions do you have about it? The DB itself is just a set of files. How you interface with the database will depend on what language you are using for your application.

Edit: I guess you found what you needed while I was posting :)

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Give me an A; give me a S; give me another S; a H-O-L-E.
Now, say it all together. SCRU!

Lame. Very lame. You could have left out the name-calling.

I put this in a real post just for you.

jephthah commented: <-- this is an arbitrary yellow dot -2
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Moved to PHP.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

That would be an issue for the instructor to deal with, not forum moderators here.