Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Nothing really stands out as wrong with that code. I don't think you really need the fillRect(background) section, but that's unrelated. How large is your icon image? Perhaps you need to specify the width and height in your drawImage call to make sure it's stretched to the frame size?

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

What specific example of that constructor would you need? It's just setting the title and a few boolean variables. The API doc seems to explain it sufficiently.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

>Is there even a setBackgroundImage() method?
No, there is not and that is the entirety of the issue. She is trying to add that method through an anonymous class definition without providing an actual named class definition for the subclass. It cannot be done like that. You can override existing methods with such a declaration, but you cannot add new public methods.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

>Could someone please give me any idea on how to add a background image to JInternalFrame without subclassing.
Not really. You'll need to create your own subclass if you want to be able to add a method like that. You can't add methods though anonymous declarations like you have above and then expect to call them on an instance of the parent class.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Well. what have you tried? What have you thought about trying? You've been given suggestions that you need to write the data to a file and read it back when you set up the buttons, so have you tried doing that at all?

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Did you have some point in posting this other than demonstrating that you cannot properly use BB code tags?

Some question perhaps or an error message?

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You need to create a small class for your monsters that keeps track of their coordinates and bounding areas. A start would be something similar to this

class Monster {
  int x;
  int y;
  int width;
  int height;
  // of course, a Rectangle could be stored instead and it would save you the math
  // in contains()
  Image image;

  public void draw(Graphics g){
    g.drawImage(image,x,y,width,height,null);
  }

  public boolean contains(int x, int y){
    // does bounding area contain this point?
  }

  public void move(int dx, int dy){
    // move the monster by dx and dy units
  }
}

Keep the monster instances in a List and use them to move, render, and do hit testing.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

He means that you have to save the state somehow. These easiest way to do that is to write to and read from a file.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I have another idea: do your homework yourself.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Either Java or C# would be a good start. Both are widely in use right now.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Queensryche - "Operation: Mindcrime"

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You're going to need to expand on "just a huge mess". Post specific questions, error messages and stack traces, etc.

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

this represents the current object instance. Using it in an inner class would represent the instance of that inner class, so it must be qualified with the name of the enclosing class if you want to refer to the enclosing instance.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Yes, moving this to social media forum.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Moving to Mobile Dev, perhaps some in there would have suggestions.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Use the exec task as you would the command line with 7z. Arguments are specified with the <arg> element.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Just use a JLabel that spans the bottom of your frame or a panel with multiple labels if want several fields of info.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Define your frameToPrint variable at the class level in your PrintButtonHandler . Create a constructor for it that takes the Container as a parameter and sets frameToPrint to that reference. Then when you create the PrintButtonHandler up in your code, use new PrintButtonHandler(this); to pass the reference of your current OptionWindow frame to the handler constructor.

private class PrintButtonHandler implements ActionListener, Printable {
   Container frameToPrint;

   public PrintButtonHandler(Container frame){
      this.frameToPrint = frame;
   }
...

Since your handler is an inner class, you could also use OptionWindow.this to reference the current enclosing instance. The print call would just be OptionWindow.this.printAll(g);

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Ant has a built-in zip task that you could use, but if you want to use 7z instead then I would think you could do it pretty easily with exec.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Probably because you have not actually set "frameToPrint" to your frame. You could create a method to do that or you could pass a "this" reference to your print button handler constructor to set it.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Of course it can't find 'frame', unless you just happened to have a reference to your frame named 'frame' in your program. You can't simply paste their code into your program and expect it to work without bothering to understand what it's doing.

You need to call that method on a reference to the window you are wanting to print.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Empty method = that method is just a pair of braces, there is no code in it.

Try this tutorial:http://download.oracle.com/javase/tutorial/2d/printing/gui.html

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Well, yes, calling drawGraphics() won't do anything because it's an empty method.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I have no idea. I have not used Jasper Reports. You'll need to consult the documentation for that.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You only need an array if you are wanting to store more than one value. If you just want a single value for "memory" then all you need is a variable and just set memory=0 to "clear" it.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You have a typo in the command string. Take the space out of "/ c" in "cmd / c start https://google.com"

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

>Just replace simple types like int, long etc. by corresponding class types like Integer, Long etc. It really helps :-)
Why on Earth did you resurrect this old thread to post such nonsense?

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

^ Does that help wash down your pride?

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

What's wrong with just using

double memory;

All you have to do is store a number and that's all a variable does.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Make sure you have the Jasper report jars on your class path.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Take a look at the How To Use Icons tutorial. It addresses that issue.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

@vincentjohn:
That is just ridiculous. Please read up on the JVM and modern just-in-time compilers before you start tossing around nonsense like that.

The OP did not even supply enough information to begin to know why it is "slower" and how he can load his panes "fastly". My guess would be some recursive layout issues with how he is building the UI dynamically, but without code or more explanation, it's impossible to say.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Why on earth would he try notify()? This has nothing to do with a threading issue.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Please read our forum rules about showing effort if you expect help with homework. Also, do not use "chat speak". I'm sure you can manage to type all of the letters of the words.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Post what you have started with. Ask specific questions.

Demonstrate that you have made some effort at this yourself if you expect others to take their time to help you.

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

Use a different layout such as BorderLayout, BoxLayout, or GridLayout.
Lesson: Laying Out Components Within a Container

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Well, the issue is keeping track of the coordinates of the shape so you know when you have clicked on it. That is where the contains() method comes in handy because it does the math for you to determine if a point is within its bounds.

The "erasing" part is just a matter of not drawing the shape at all when you repaint.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You could start with this example.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

If you use Shape objects for rendering, you can use their contains() method to determine if they are under the mouse. So if you created an Ellipse2D for your ball and used draw(Shape) to draw it, you could later determine when it is clicked on with a mouse listener and "undraw" (probably delete) it.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

nm

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

It's a shame that we can't go their room and write garbage on their walls, which is essentially what they do to forums.

Such pathetically rude individuals.

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

Structurally like this

class GamePiece {
    Image image;

    public GamePiece(Image image) {
        this.image = image;
    }

    public void draw(Graphics g){
        g.drawImage(image, 0, 0, null);
    }
}
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You can leave the drawImage() call in paintComponent() and set an Image reference variable in the class either with the constructor or through a setImage() method you create on the class.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Sure, no need to start a new thread if they are still related to the original question.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

JApplet is different than Applet. It utilizes a content pane. Try

getContentPane().setBackground(new Color(random.nextInt(255), random.nextInt(255),random.nextInt(255)));
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

If I do not use a 2d array, is there a way I can check if a certain square in the chess board represented by (topleft_x, topleft_y, length, width) contains an Image variable or not?

No, not really because when you draw the image you are rendering those pixels onto some area in your graphics context. There is no reference back to where those pixels came from that you can refer to later - hence the need for the 2D reference array or a custom glyph object that keeps track of its own coordinates.

The 2D array is probably the easiest way to go. You could make a BoardTile component that extends JComponent and overrides paintComponent() to render either a chess piece or an empty background color depending on what is current at that spot in your grid.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You could use an EmptyCell object that renders itself in different colors under certain conditions, such as one color for mouse-over and another for "selected".