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

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

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

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

>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

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

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

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

And does your teacher have better suggestions for collision detection?

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

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

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

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

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

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

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

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

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

He could just as easily extend JPanel and plug those into whatever top-level frames he wants to use for the OS.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Correct.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Short answer: you can't.

There is a 30 minute window to edit posts and after that they are part of the great public archive that is the internet.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

The DefaultRowSorter is blowing up when it tries to determine the column class in your model, because you are using the value of the first element to determine the class here

@Override
  public Class getColumnClass(int col) {
    return getValueAt(0, col).getClass();
  }

That's all fine and well when there is an element at index 0 to examine - not so much when the vector is empty.

You could try to return either a null or Object.class in that case. I'm not sure which one will may the default row sorter happy. You'll have to experiment or dig into its code.

@Override
  public Class getColumnClass(int col) {
    return cache.size()>0 ? getValueAt(0, col).getClass() : null;
  }
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Well, you didn't post the relevant part of your QueryTableModel class: tableModel.setQuery() , but it looks like your default row sorter isn't very happy about an empty data vector.

I don't think you're handling an empty result set quite right in your model.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Look at your declaration of the panel

JPanel Guess = new JPanel();

You have declared a plain JPanel here named "Guess" and added it to your frame. You actually need to declare an instance of your "Guess" class and add that to the frame

Guess guessPanel = new Guess();
myFrame.add(guessPanel);
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Perhaps where instr(email, '=') > 0

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

How about you post your own observations and others can comment on them.

Otherwise, this reads as "Do my assignment for me and send the results".

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Retrieve the file locally and use Desktop.open() would probably be the easiest option.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Your first version of makeCheckBox was pretty close. You want to add the checkboxes to 'checkPanel' and then add 'checkPanel' to the frame. So for a single check box

JCheckBox firstCheck = new JCheckBox(this.firstCheck);

        JPanel checkPanel = new JPanel (new GridLayout(0, 1));
        checkPanel.add(firstCheck);

        frame.add(checkPanel);
        frame.pack();
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

GridLayout or GridBagLayout

GridLayout is much simpler, but not nearly as functional as GridBagLayout. It just depends on your needs.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You didn't really rearrange - just just dropped the JPanel portion. Re-read what I posted and try to actually perform those steps.
Make checkbox >> make panel >> put panel in frame.