Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

> can nay on etell me tht why if i am moving a ball thn my hurdl also moving .
Why should anyone waste their time replying to this lazy gibberish? Perhaps you should take the extra 10 seconds to type a legible question if you want others to take it seriously.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Are you accessing the images as local files or through a relative directory within your web site root? If you are trying to show files from your local hard drive (like 'c:/myPictures/pic1.jpg') I could see it being a bit cranky.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Have you created a new JFrame/JPanel/etc through the New file menu?

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

URLS changed to "example.com" to be generic and still preserve the question.

wonderland commented: Helped me with a topic editing (outside of forums options) :) +0
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Yes, I'd agree that it's somewhat hidden up there at the top. I think it's previous location just below the last post is probably the best place for it if we're to have any chance of new posters using it.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I didn't see a reference implying create=true as part of the DB url. I'm not sure where

you are seeing this.

Listing here: http://publib.boulder.ibm.com/infocenter/cscv/v10r1/topic/com.ibm.cloudscape.doc/cdevdvlp51654.html

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Well, you could create your own custom dialog, but I wouldn't say that is easier than using the array for your options with showOptionDialog().

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Yes.
'this' refers to the current object - whatever that object is. It could be anything.
'content' refers to whatever you defined it as. Most likely it's a Container ref obtained from getContentPane() somewhere in your program.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

127.0.0.1

You don't need anything more than local tools while you're just learning.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Create a class to hold that data. Return an instance of that class.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Well, that really depends on how you decide to provide that access. Your menu bar can disable items by using their setEnabled() method if that's what you're wanting to do. The only way to actually remove an item is to remove it from its parent menu, but if your classes are removing a lot of menu items you really need to stop and ask yourself why you're trying to share one menu bar and hack it up as needed. Perhaps each screen or state of your application may need its own menu.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You'll be able to access those methods if you have declared the variable to be of your "MenuBar" type. If you're using a JMenuBar reference, those won't be visible.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You need to override the isCellEditable(int,int) method in your table model to return false

public boolean isCellEditable(int row, int column) {
        return false;
    }
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Unsigned applets cannot access the local file system: http://java.sun.com/docs/books/tutorial/deployment/applet/security.html

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

e.getSource() returns the component that generated the event, which in your case is the combo box. You cannot cast that JComboBox reference to a JTextField.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

The basics of Comparable really come down to returning a negative value if "this" is less than the object passed, a positive value if "this" is greater, or zero if they're equal

class SomeClass implements Comparable<SomeClass> {
    public int compareTo(SomeClass other) {
        // If this < other, return -1 
        // If this > other, return 1
        // If they're equal, return zero.
        return 0;
    }
}

Now all you need to do is code in the "if" statements to compare them.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You forgot to mention the exact problem.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

It looks like you're having trouble with your iterator. To access the next object you need

while( iterator.hasNext() )
{
    YourObjectType nextObj = (YourObjectType)iterator.next();
    if( nextObj.string3.equals( stringA ) )
    {
                
    }
}

Where "YourObjectType" is of course whatever object you're using that contained the strings.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Looks to be ProStores markup.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I'm running 64-bit Java 6u18 on Windows7 and it runs great. No performance issues at all that I have seen, and our app is extremely computationally intensive.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Dumb question, but I've searched everywhere and found nothing specific: is it possible for HSB values to translate directly into a colour (eg. a hue of zero equals red) instead of passing them through an RBG conversion?

See Color.getHSBColor(float,float,float)

Also, dumber: I'm not understanding the arrrays people are using, for example here and here.

Some of the methods take a three or four element array for the component values (rgb, rgba, hsb, etc) such as this one Color.RGBtoHSB(int,int,int,float[]) Read the API docs for the details on the parameter and return values for the methods you are wanting to use. The array sizes and ordering area specified.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

isCellEditable() gets called by the table when you double click a cell to see whether or not to the editor should be invoked. If you want to respond to a data change immediately, you'll need to use a TableModelListener most likely.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You would probably have a much easier time with GridBagLayout instead.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

This version uses an offscreen buffer image to draw on. Erasing is trivial with this one, but you don't have the easy shape management like the other one. Hold down 'shift' to erase

class ScratchPanel2 extends JPanel implements MouseMotionListener, MouseListener{

    BufferedImage image;

    public ScratchPanel2(){
        addMouseListener(this);
        addMouseMotionListener(this);
        addComponentListener(new java.awt.event.ComponentAdapter() {
            public void componentResized(java.awt.event.ComponentEvent evt) {
                panelResized(evt);
            }
        });
    }

    @Override
    protected void paintComponent(Graphics g) {
        super.paintComponent(g);
        Graphics2D g2 = (Graphics2D)g;
        g2.drawImage(image, 0, 0, this);
    }

    private void panelResized(ComponentEvent evt) {
        if (getWidth()>0 && getHeight()>0){
            // create new temp image
            BufferedImage tempImage = (BufferedImage)createImage(getWidth(),getHeight());
            // draw old image to the new one
            Graphics2D g2 = (Graphics2D)tempImage.getGraphics();
            g2.drawImage(image, 0, 0, this);
            // swap
            image = tempImage;
        }
    }

    public void mouseDragged(MouseEvent e) {
        Graphics2D g2 = (Graphics2D)image.getGraphics();
        g2.setColor(e.isShiftDown() ? getBackground() : Color.BLUE);
        g2.fillRect(e.getX(), e.getY(), 2, 2);
        g2.dispose();
        repaint();
    }

    public void mouseMoved(MouseEvent e) {}

    public void mouseClicked(MouseEvent e) {}

    public void mousePressed(MouseEvent e) {
        mouseDragged(e);
    }

    public void mouseReleased(MouseEvent e) {}
    public void mouseEntered(MouseEvent e) {}
    public void mouseExited(MouseEvent e) {}
}
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Ah, I thought you wanted to erase the whole shape. Determining if a path contains a point is very easy, but like you mentioned, I don't see any direct way of removing a point from that path. You may be right that drawing a new shape with the background color might be the easiest way to accomplish an "eraser" mode.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You were creating a new GeneralPath with each point in mouseDragged and adding it to your vector. You really only need one for each "shape" since the path is just a series of connected points.

Path2D.Float is just the more recent incarnation of GeneralPath. GeneralPath is an older legacy class.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Okay, this may work a little better for you. It keep a list of the shapes, so erase should be pretty easy for you to implement. If you need to check a shape for a point, there is a contains() method on Path2D.Float.

class ScratchPanel extends JPanel implements MouseMotionListener, MouseListener{

    List<Shape> shapeList = new ArrayList<Shape>();
    Path2D.Float currentShape=null;

    public ScratchPanel(){
        addMouseListener(this);
        addMouseMotionListener(this);
    }

    @Override
    protected void paintComponent(Graphics g) {
        super.paintComponent(g);
        Graphics2D g2 = (Graphics2D)g;
        for(Shape s : shapeList){
            g2.draw(s);
        }
    }

    public void mouseDragged(MouseEvent e) {
        currentShape.lineTo(e.getX(), e.getY());
        repaint();
    }

    public void mouseMoved(MouseEvent e) {}

    public void mouseClicked(MouseEvent e) {}

    public void mousePressed(MouseEvent e) {
        currentShape = new Path2D.Float();
        currentShape.moveTo(e.getX(), e.getY());
        shapeList.add(currentShape);
    }

    public void mouseReleased(MouseEvent e) {}
    public void mouseEntered(MouseEvent e) {}
    public void mouseExited(MouseEvent e) {}
}
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

If you're still having a lag problem, post your revised code and I'll take a look.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Just adding a point to a path and repainting shouldn't really be causing a noticeable lag.

shape.lineTo(e.getX(), e.getY());
repaint();
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Your other option is to use an offscreen buffer image to draw on and then render that in paintComponent(). That adds a couple of additional issues with resizing and clearing, but it's another option if you don't want to save shapes.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Yes, otherwise how does it know how to redraw it on repaint? You can use a GeneralPath for that.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You'll need to save the line coordinates if you want to draw more.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Thanks for all your reply

So, just glancing at your sig, I wonder if you feel this thread is solved?

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

At line 87, you're setting prev coords equal to the current coords each repaint. You don't want to do that. Leave the prev values where they are at.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Most of the drawing code itself needs to go into paintComponent(). paintComponent() will be called from the paint() method, so you can still use that with your image.

Update the rendering data in your UI methods and call repaint() to refresh the screen. Let paintComponent() handle the actual drawing of that data onto the graphics reference. You can see an example of that in this post: http://www.daniweb.com/forums/post1146173.html#post1146173 The data is being altered through a Timer, but the concept is still the same when using mouse events.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

There is most likely your problem then: you should be rendering what the user has drawn by overriding the paintComponent() method on the JPanel.

Your save method is handing a graphics context from the image object you created to the panel to paint on. Unfortunately, that paint operation doesn't include what you've drawn onto the previous (and now invalid) graphics reference that you obtained earlier with getGraphics().

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I haven't been able to get it to respond to POST requests. Are you certain that the php page is written to use them? It might only be coded for GET requests like the link you posted.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Have you tried adding "client.php?" to the string you're sending? I used the following code fragment and pulled back the id just fine

try {
            // Create a URL for the desired page
            URL url = new URL("http://interactivo.mensajito.com/interactivo555/client.php?orden=1&nick=Niche");

            // Read all the text returned by the server
            BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
            String str;
            while ((str = in.readLine()) != null) {
                // str is one line of text; readLine() strips the newline character(s)
                System.out.println(str);
                Matcher m = Pattern.compile("session=(\\d+)").matcher(str);
                if (m.matches()){
                    System.out.println(">> captured id: "+m.group(1));
                }
            }
            in.close();
        } catch (MalformedURLException e) {
        } catch (IOException e) {
        }
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Are you saying that you don't know how to parse the value you are getting? Or that you aren't able to capture the response at all?

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

He stated that they are all in the same directory. It's not a classpath issue. His error message is exactly what you get when you try to execute the ".java" file instead of the class. The "." is interpreted as a package separator, hence the "Creature/java" result.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Don't try to execute "Creature.java" - execute "Creature" after you have compiled to a class file.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Are you sure that your panel has width and height when you create the BufferedImage? How you are rendering what the user has drawn? What you have there should basically work.

edit: cross-post with BJSJC

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

So you randomly decided to rename some of your own classes from code you wrote that was working just fine previously and you don't understand variable declaration well enough to use the new class names where needed? Seems a little odd to me, but hey, what do I know.

As I already said - getting it to a point it will compile is a good place to start. Then you can approach adding/removing from the array.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Getting it to a state that it would even compile would help. You have all of your type declarations mangled up.

Did you write any of this code to begin with? If I were to guess, you're in the process of trying to rename variables and modify someone else's code and you don't understand it.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

JLabels would work as well. I agree with BJSC, it would be a lot easier to draw an image one time in an editor for each symbol than to render them from primitive ops with Graphics2D.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You still have to render that doubleBufferImage to your component graphics context in your paintComponent(Graphics) method.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Well, the tooltip for the down-vote arrow merely says "This post is unclear", so the down-voters may have simply thought it was a poorly structured question or that he should have been more specific about what he was having trouble with.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

SimpleDateFormat can be used if you want to parse a Date from a String:
http://www.exampledepot.com/egs/java.text/FormatDateDef.html

If you want to set a date programmatically, use a Calendar:
http://www.exampledepot.com/egs/java.util/GetDateFromCalendar.html

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

If you have further HTML/CSS questions to work through, I'd recommend starting a new thread over in that forum. This one is getting rather long and covering multiple questions. Limiting threads to one topic and making sure they're in the correct forum makes it easier for both the helpers and the helpees. :)

And please mark this one solved if the original issue has been resolved.