Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Interfaces do not have any code themselves. They are a set of method declarations that are required by a class that implements that interface. The interface is a guarantee that those methods are available on any class that implements it. The code for those methods goes in the class that is implementing it.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You need to demonstrate more effort on these questions that you are posting. Simply posting the assignment is not sufficient and no one is going to just complete these for you.

Post what code you have. Ask specific questions about concepts you are struggling with.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

So, which part are you having trouble with?

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

So you would just need to "group by" table and use another aggregate function to sum them up. I bet you can find that function pretty easily.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

It works just fine in the loop I ran here. Since you didn't trouble to post your code, no one can tell you exactly why yours is not working.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Moved to it's own thread.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

This increment will work

t += (count%3==0 ? 0.3 : 0.1);

but you'll have to figure out the loop to go around it. It's not a complex one.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Welcome.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Welcome. You'll find plenty who share your passion here.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Welcome.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster
img = ImageIO.read(new File("C:\\Users\\General Use\\Pictures\\0118080951"));

should work fine.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Here's another option as well, using ImageIcon and JLabel:
http://java.sun.com/docs/books/tutorial/uiswing/components/icon.html

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

>so essentially two threads are trying to paint the same window at once, resulting in glitches?
Somewhat, yes. I don't have a concrete answer to the "what exactly?" of why the glitches could occur. It would depend entirely on the various UI toolkit code that renders the components and state inconsistencies they may be vulnerable to under certain multiple thread access conditions. I was just speaking generally to the fact that Swing is a single-threaded model and multiple threads attempting to alter the visible state of the components could produce erratic behavior due to inconsistent memory states since they weren't designed for multi-threaded access.

This pdf may be of interest: http://today.java.net/today/2005/04/19/desktop.pdf

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

>How could a paint request possibly occur though. . it can't occur programmatically (before setVisible returns)
It can if the setVisible call is being processed on a thread other than the EDT. Consider that things like moving your mouse over a component, dragging another window across a component, resizing, etc. all generate repaint requests on the EDT. If you're building your GUI on some other thread, the EDT is perfectly free to pop in with a paint request before it's fully constructed.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

The 'unsafe' part would be a chance that some portion of the components might still be in an inconsistent state that would produce errors or graphical "glitches" if a paint request happened to be processed. Essentially it's still "under construction" and may exhibit inconsistent behavior if accessed by another thread.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Example method

private void showPanel(JPanel panel){
        Container contentPane = getContentPane();
        contentPane.removeAll();
        contentPane.add(panel);
        pack();        
    }
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You would find those things much easier with a DOM parser, if that is an option. Otherwise, you have to keep track of the overall structure yourself.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Start a thread on it if you wish to have such a discussion. Posting it on the tail end of someone else's thread on Bluetooth won't attract much participation.

Salem commented: Well said +29
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You'll need to come up with own format for that, since it's your editor.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Oh one last thing for clearing the on-screen display for an applet is their another method commonly used rather that getting the dimension size and background colour and simply drawing an applet sized rectangle over the top?

Well, you can just not paint anything else after the call to super.paint()
:)

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Correct. The drawing code needs to either be moved into the paint() method or called from it with a reference to the Graphics object. See comments in edited code:

package wk8exercise3;

import java.applet.Applet;
import java.awt.*;
import java.awt.Graphics;
import java.awt.event.*;

/**
 *
 * @author Rob
 */
public class wk8Exercise3 extends Applet implements ItemListener {

    Choice myChoice;

    int rectX;
    int rectY;
    int rectWidth ;
    int rectHeight;
    String shape;
    int Selection;  // moved this up here

    public void init()
    {
        // Create the choice and add some choices
        myChoice = new Choice();
        myChoice.addItem("Pick a shape to draw");
        myChoice.addItem("Draw a rectangle");
        myChoice.addItem("Draw a Line");
        myChoice.addItem("Draw an Oval");
        add(myChoice);
        myChoice.addItemListener(this);
    }

 public void itemStateChanged (ItemEvent e)
    {
         // set new selection index
         Selection = myChoice.getSelectedIndex();
         repaint();
    }

 public void paint(Graphics g)
	{
         super.paint(g);

         if (Selection == 1)
         {  
             // you can call these methods directly here
             g.drawRect(50,50,100,100);
         }
         if (Selection == 2)
         {
             g.drawLine(50,50,200,50);
         }
         if (Selection == 3)
         {
             // or you can pass the Graphics reference as a parameter
             drawAnOval(50,50,200,50,g);
         }
	}

  // added Graphics as a parameter here
 public void drawAnOval(int ovalX, int ovalY, int ovalWidth, int ovalHeight, Graphics g)
  {
    g.drawOval(ovalX, ovalY, ovalWidth, ovalHeight);
  }

}
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You can save yourself some typing if you want to list all of the properties available through System.getProperties()

System.getProperties().list(System.out);
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

For some ideas, I would recommend looking into the A* pathing algorithm.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Five Finger Death Punch - "Never Enough"
http://www.youtube.com/watch?v=Nfr_nWsXOBg&feature=related

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

That one marks all forums as read, not just the current one.

I can still go up a level and double-click the folder to mark a single forum read, so it's not really a big deal. I was just curious about it. I didn't see any other way to mark a single forum as read.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

One thing I noticed missing on the forum listing pages is the "Mark as read" function. Have I missed its new location or is that still "in progress" or is it gone for good?

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

This line location: interface org.w3c.dom.Node would indicate it's returning a Node object but he's probably expecting an Element object.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Any help offered here is a completely voluntary effort. As such, your own attitude is going to determine the extent and nature of that help. The attitude demonstrated above is certainly not going to encourage much assistance in the future.

Good luck with your efforts.

(You should also know that most posters never mark their questions as solved. Many don't even trouble themselves to say thanks or come back at all after their issue is resolved. Using that as a metric of "helpfulness" is useless.)

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Posting an email address still isn't going to get this code written for you.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Here's a short tutorial that covers some of those concepts mentioned above: http://zetcode.com/tutorials/java2dtutorial/hitmove/

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

To be able to move, resize, and interact with an object, you'll need to create a class to represent it. It should keep track of things like its current bounds, "grabby points", color, etc. and be able to render itself to a supplied graphics object. Your painting canvas needs to maintain a collection of those objects and mouse listeners will have to check those objects and react accordingly.

There are several classes you can use directly or extend that implement Shape and have some methods that make this easier.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Yes. You want to see if either dimension is smaller than the box you already found.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You still need to add the criteria to check if box is smaller than foundBox.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

It's kind of hard to say from a general standpoint, since it does depend on what you've coded after all, but keep in mind that repaintings of the top level container (Applet, JFrame, etc) are heavyweight AWT operations that use native code to redraw the top level window in the OS. Swing calls however (like contained JPanels) are lightweight internal repainting operations that are much more finely controlled for you through a repaint manager with double-buffering, incremental "dirty-region" repainting, etc.
You can read more about these differences in this article if you like: http://java.sun.com/products/jfc/tsc/articles/painting/

Intrade commented: Always helpful =) +1
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Well, it's hard to say because you haven't posted any updated code in awhile. You could get more specific answers about why your method is behaving in a certain manner if you would post it. We can't see over your shoulder from where we are sitting :P

As you loop through the boxes, the logic of your if() checks should be:
1) Is this box big enough for each parameter?
2) If so, is it smaller than the last box I found that was big enough or is this the first box I've found that's large enough (this is the null case)?
3) If so, then save the reference to this box.

So after this has checked all the boxes, you should be left with the smallest box that fits the height and width parameters or a null variable if none of them are big enough.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Are you trying to call that method on an object that extends JComponent? You can't just import JComponent and use that method.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

And are you comparing that box against the smallest foundBox so far? You still need to compare the Box against the current "foundBox" to keep the smaller of the two. so you also need

// pseudocode: inside the if() statement mentioned above
if (foundBox==null || thisBox is smaller than foundBox){
  foundBox = thisBox
}
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Ah, sorry, I only glanced over the assignment and missed that requirement. You could change your if() criteria to check that the box is big enough to hold the item. If it's big enough, check against the one you have already found to see if the current box is smaller (or if foundBox is null). If it is, set 'foundBox' to the current box. When you're done, 'foundBox' should contain the smallest box that will accommodate the dimensions you specified.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

The hosts file is just a text file: http://vlaurie.com/computers2/Articles/hosts.htm

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

:(

:)

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You'll need add some code to separate that piece then. You could do that with:
a) regular expressions, which I posted a link about above
b) String.split() on spaces and step through the resulting array to identify the parts that you want to keep
c) step through the line of text with more calls to indexOf() to find the substring of interest

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Ok, so in regards to my (edited) post up above, why not alter what you have written to accept both parameters, height and width, and return the Box that is found (or Boxes in your case, but I would recommend renaming that to just Box because that more accurately reflects what it is - you don't have a single instance of a "Boxes"). The code that is searching for a particular box doesn't care what its index is in some arbitrary inventory list is - it needs a Box, so return that. Here is your method changed to return the Box(es) object. I'll leave it to you to add the parameter to also pass in a width and check that in your if() statement.

public Boxes findBox(int height)
{
  Boxes foundBox = null;
  for(Boxes box : inventory)
  {
    if (box.getHeight() == height)
    {
      foundBox = box;
      break; // you found it, no point in looking any further
    }
  }
  return foundBox;
}

Keep in mind, this method will return null if it doesn't find a matching box, so the code that calls this method needs to check that the return is not null before it attempts to do anything with that Box.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

In the future, try to put all of the relevant info in a single post rather than composing it across many. It's rather difficult to answer a question that is actually only an incomplete portion of a question.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You haven't given enough info to answer that. It depends upon how you have stored those objects and their data. The part about "choosing" the method is odd as well.

edit: Okay, you added another post while I was typing. Why not take both height and width and compare both values in your loop, then return the Box object that matches?

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

As JamesCherrill mentioned above, don't pass 'memAd' to your table model constuctor, pass the Adult[] array.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You don't need to create an exe for that. Just package it in a jar file: http://java.sun.com/docs/books/tutorial/deployment/jar/index.html

Most Windows users already have a JVM installed, but if they don't it's a simple matter for them to install from the web.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

And after you've managed the open/read operations mentioned above, read through this tutorial on regular expressions for the data extraction: http://java.sun.com/docs/books/tutorial/essential/regex/index.html

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

If Main.class is declared in a package named "sort2" and in a folder of that same name, then from the root directory (the one containing the sorts directory), you invoke the class as "sort2.Main". The package is part of locating the class.
This tutorial may be helpful: http://java.sun.com/docs/books/tutorial/java/package/index.html

lllllIllIlllI commented: Couldnt have been a better post +2
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Is your Main class in a folder called "sort2" and does it have a "package sort2;" declaration?

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Your description is a little bit difficult to understand, but I think you are saying the extra spaces are causing you trouble in the split() result? You can make it ignore those by altering your pattern to allow for one or more occurrences of those characters. Try this "[-.!? ,\n]+" for your split pattern.