Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

That would depend on the language you're working in - VB.NET? C#?

If you'll tell us, we can move this post to the appropriate forum where the experts can help out. :)

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

This is a duplicate of the following question: http://www.daniweb.com/forums/post1458941.html#post1458941

Please direct any further discussion to that thread. Closing this one.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I think Nick may have thought you were referring to your other thread, which had the domain scattered throughout the code and on many replies.

Nick Evan commented: I did indeed. +0
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

The package declaration needs to match the directory structure of classes.

If you had a base directory called src , a class in a child directory src/ui , you would need a package declaration package ui; . A class in src/ui/main would be declare package ui.main; So depending on the directory structure of your source code base, you may need to add or adjust the package declarations.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Here is a small tutorial on transparency using the AlphaComposite class: http://javaboutique.internet.com/tutorials/Java2D/page04.html

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You should not have to unzip the jar. Have you added it to the Compile libraries in your Project Properties > Libraries tab?

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Unfortunately it is a reality of the internet that you cannot always "undo" what you decide to share on it. The posts in question have already been public information for over 8 months.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Well, that looks just fine to me. Nothing really stands out that would cause the button problem. When I said sharing the button, I meant that perhaps you were unintentionally reassigning a single button reference to multiple mine objects. Or perhaps a single listener instance being shared across the buttons.

The behavior you're getting is what one would expect if you were repeatedly updating a single reference with new values in your loop. When it's done, it reflects whatever you set in the last iteration. That is why I wanted to see more of the code involved with the creation of the buttons and listeners.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

As I already posted above:
Are you sure that you aren't accidentally adding the same JButton to multiple Mine instances? That would produce the behavior you're describing.

That applies to your current question as well. You should not have to send the x and y coordinates separately in the constructor. The fact that all actions seem to only be affecting that last button really does sound like you may be re-assigning the same button reference to multiple mines.

If you can post the code that creates the JButtons for the mines, that might help.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

> Eyal's second question was not specific to game dev.
Yes, I know. I was referring to the original question.

It is difficult to entice a population that is not present.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

> which i found in some book
That book being your course book and the problem being homework. Why not just say that?

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

From what I can tell, we don't really have much expertise in the Game Development section to draw upon. Matt Evans used to provide a lot of good answers in there, but lately it looks pretty dead.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Do you have multiple Panel elements defined under the root?

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

It's backwards. Your root element is the very first top-level element in a document. In the above, <Panel> is the root. You need the Panel elements to be children of the root, so there needs to be one more level above Panel. I just threw out Project or Locations as possibilities. You can call it whatever you want.

<someRoot>
  <Panel>
    ..
  </Panel>
</someRoot>
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

The original DOM builder code was fine. It was just a slight issue with the document structure.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Ok, in the XML fragment you posted above, <Panel> is actually your root element rather than a child. If you add another element level above <Panel> called <Locations> or <Project> or whatever, your getChildren() code should work fine.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Perhaps you should offer your own thoughts on your quiz questions as a starting point?

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Without seeing the XML file structure it's impossible to say. Are you certain that there are <Panel> elements as direct children of the root?

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

> try list.length()
Why would she want to try a method that doesn't exist? That doesn't seem very useful to me.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You haven't really posted enough code to determine the cause. I don't see any immediate problem with your last bit, but there are other things that could be occurring.

Are you sure that you aren't accidentally adding the same JButton to multiple Mine instances? That would produce the behavior you're describing.

Perhaps your Mine class should just implement MouseListener and respond to the click itself?

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Nothing really stands out as a problem with that, but your code would be a little cleaner to read if you altered it just a bit

for(xCounter = 0;xCounter < 10;xCounter++){
			for(yCounter = 0;yCounter < 10; yCounter++){
				Mine mine = new Mine(xCounter, yCounter);
                                mine.getButton().addMouseListener(new MineListener(mine));
				frame.add(mine.getButton());
				frame.add(mine.getNumber());
				
				array[xCounter][yCounter] = mine;
			}
			yCounter = 0;
		}
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You have to add the listener directly to the JButton with addMouseListener(), so wherever you are creating the button for the mine object, you need to create and add the listener to it.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Listeners are added to the buttons though. There is no reason to keep a separate array of them.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I'm not sure what listener[][] array is for. Are you not just adding the listener to the JButton? You don't really need an array of listener objects, but then I don't know the full context behind that code fragment.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Define your mouse listener to accept a Mine reference in it's constructor and give it the mine object reference when you add the listener to the button

class MineListener extends MouseAdapter {
    Mine mine;

    public MineListener(Mine mine) {
        this.mine = mine;
    }

    @Override
    public void mouseClicked(MouseEvent e) {
        // do whatever you want with mine
    }
}

Or just implement mouse listener on your Mine class and pass it the directly to the button.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You could read the help files or perhaps take a look through this screencast: http://netbeans.org/kb/docs/java/java-editor-screencast.html

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

>Is there any symbol like && || ..?
No, there isn't any special symbol or keyword. You have to check both bounds

(x>=10 && x<=100)
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

So now it's a pharmacy? What about your previous thread(s) about creating a database for a dentist office? Please make up your mind and quit wasting peoples' time begging them to hand you a complete design for a project database.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Ok, I have merged this mess of 4 separate thread for a single issue here. If anyone wonders why there is some repetition, that's why.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

This is not really a Java question at this point. It's a database design question so I will move it to that forum.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Ok, so now write down the data associated with each of those. Only you know how much data you want the program to manage.

You have the slightest beginning, so now start filling it out.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Read the docs for JCreator I suppose. I've never used it myself. Look for info on adding third-party libraries.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Have you learned anything about what entities and relationships are? if so, then start designing them and ask specific questions when you have trouble.

If you haven't yet learned about them, there isn't any point in asking about them now.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Here's an implementation of the rectangle click and drag. Determining what is within the box is up to you.

import java.awt.BorderLayout;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import javax.swing.JPanel;

public class SelectionDemo extends javax.swing.JFrame {

    public SelectionDemo() {
        initComponents();
        add(new DrawingPanel(),BorderLayout.CENTER);
        setSize(500,500);
    }

    class DrawingPanel extends JPanel implements MouseMotionListener, MouseListener{

        Rectangle selection;
        Point anchor;

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

        @Override
        protected void paintComponent(Graphics g) {
            super.paintComponent(g);
            if (selection!=null){
                Graphics2D g2d = (Graphics2D)g;
                g2d.draw(selection);
            }
        }

        public void mousePressed(MouseEvent e) {
            anchor = e.getPoint();
            selection = new Rectangle(anchor);
        }

        public void mouseDragged(MouseEvent e) {
            selection.setBounds( (int)Math.min(anchor.x,e.getX()), (int)Math.min(anchor.y,e.getY()),
                    (int)Math.abs(e.getX()-anchor.x), (int)Math.abs(e.getY()-anchor.y));
            repaint();
        }

        public void mouseReleased(MouseEvent e) {
            selection = null;
            repaint();
        }

        // unused
        public void mouseMoved(MouseEvent e) {}
        public void mouseClicked(MouseEvent e) {}
        public void mouseEntered(MouseEvent e) {}
        public void mouseExited(MouseEvent e) {}
    }

    private void initComponents() {
        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        pack();
    }

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

Why are you asking people to explain how to make your database before you take your class? Isn't that why you are taking the class at all?

Come back when you can demonstrate the slightest bit of effort on this and an initial idea of the design.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Yes, you could easily use XML to store the information about the currently open pictures/labels. JDOM is a very easy to work with DOM parser, which you can use to work with the XML doc.

Your doc structure could be as simple as

<panel x='10' y='35 name='Whatever' />

or as complex as you like.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Have you added the Java3D jar file(s) to your project class path?

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

@irfan_iba: What language in VS?

You have hijacked someone else's thread in the wrong forum, demonstrated no effort at solving the issue on your own, and you haven't even indicated which language you're working with.

Quite a roll there.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

>any suggestions toward making my game better are welcome!
Use an ArrayList of objects for the monsters. It would condense all of that condition checking tremendously.

If you plan on using Java any further, you really need to learn to use classes.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster
for (File file : fileList){
    System.out.println(file.getName());
}

As for your second question, you can do anything you want with the list of files. It's just a collection of file references.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

If the "Main-Class" attribute is specified in the jar manifest, then you shouldn't have any trouble double-clicking it to run.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Yes, you need to add some method by which your buttons can set which plot should be shown. For the plotting itself, you could create a Plot interface with a draw(Graphics) method that would draw the plot onto the supplied Graphics context and create small plot classes for each of the function types.

If that's too complex, you could also just use an Enum for the plot type and have branches for each type in your paintComponent().

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You would need to move your PlottingPanel variable out of the constructor and up to class level. You can add a method like setPlot() to PlottingPanel to indicate which function is to be drawn and your painting method will need reference whatever info you set to know which function to draw. Your button handlers will call plottingPanel.setPlot() to change the type.

On a side note, you should override paintComponent() instead of paint() in your panel class.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

i think he heard the first time

Server has been hiccuping and causing multiple posts. I doubt he meant to post it three times :)

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

And does your teacher have better suggestions for collision detection?

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You could use the Date object itself to determine those hour ranges instead of converting the dates to strings for the comparison.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I don't get such a border with my own test code here, so I'm not sure what else to suggest.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Have you tried g.drawImage(img, 0, 0, getWidth(), getHeight(), this); It may also be a layout issue. Try setting the contentpane layout to border layout and adding your panel at BorderLayout.CENTER.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I looked up JInternalFrame and I'd say akill10 was on the mark about using a panel to render the image. JInternalFrame does use a content pane to hold it's components, so that is what you would need to be drawing on and I don't think you can easily override that.

You should be able to just switch that class to extend JPanel instead and add that to your JInternal frame.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

No, there isn't a build-in mechanism for that. You will need to get the list of files in the directory with list() or listFiles() and then check lastModified() on them to determine the most recent.