JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

EVen more bizarre! I get the same bad result (no visible fields or button) from using the appletviewer as well (JDK 1.7.0_03 Win 64).

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

That's bizzare. I just copied the code. pasted it into eclipse and ran as applet, and got the expected bad result which is no visible text fields. and no visible button until the appropriate area is clicked. adding super.paint(g); fixed it.
Are you saying that you see the button and entry fields?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

If you have "n" tickets each with "m" numbers on it, you can represent that as a 2D array [n][m] ...
The Collections class has methods you can use to sort a list of numbers into order...

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

You have overidden JApplet's paint method, which is the method responsible for ensuring the contents are painted. That's why they don't get painted. Add a call to super.paint(g) as the first line of your paint mathod. This will ensure that everything in the applet gets painted before you draw your line.
Read this for more info, including the use of paintComponent rather than paint:
http://java.sun.com/products/jfc/tsc/articles/painting/#callbacks

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

I'm going to disagree with the previous advice (sorry guys).
Initialising word to some arbitrary value will make the compile error go away, but it won't help your program to work properly.
Looking at the code, it looks like you want word to contain the text that the user typed into JTextField wordTF. So forget about initialising, and use the text from wordTF to set word before you try to parse it on 58.

And PCResolver: JavaScript???

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

I agree with your reasons for wanting it to be static. Apparently there was a plan to introduce static methods in interfaces in Java 7.1, but that it has been abandoned beacuse of "technical difficulties". Because static methods can't be overridden (just masked) and are resolved at compile time yu would have a real problem knwoing which class name to use to invoke it anyway.
IMHO the best of an unsatisfactory set of options is to declare it exactly like you would if it were static, and not care which instance is used to invoke it.
Maybe ~s.o.s~ can help here - he understands the subtle details of Java better than anyone else I know.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

How about just not declaring it static?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

It's really not complex, once you wrap your brain around the concept of recursion. Here's a generic variable nested loop (using n and m as in your example)

   void recursiveNestedLoop(int depth) { // make first call with depth=0
      if (depth > m) return;
      for (int i = 0; i < n; i++) {
         recursiveNestedLoop(depth + 1);
      }
   }

... and here's an example that keeps a listing of how it has recursed and prints the combinations that it is processing

   private void loop(int depth, String soFar) {
      // soFar builds up a displayable stack of the recursive calls
      if (depth > m) {
         // only executed "inside" the inner-most loop
         System.out.println(soFar);
         return;
      }
      for (int i = 0; i < n; i++) {
         loop(depth+1, soFar + " " + i);
      }
   }

... you can call that with something like

      int n=4;
      int m=3;
      loop(0, "");
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Is this solved, or would you like more help with the recursive solution?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
  1. You can combine multiple tests in one if, in this case ORing them together, as in
    if ( site.next(1) == null || site.next(2) == null ...

  2. The contents of the if must be a boolean expression, so you don't need an if to turn that into a booelan result, eg
    return ! ( site.next(1) == null || site.next(2) == null

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Instead of an ActionListener you need a ListSelectionListener, which will be called whenever the user selects a city in the list.
list.addListSelectionListener(new MyListSelectionListener())
Check out the API JavaDoc for details of the ListSelectionListener interface and the ListSelectionEvent that it uses.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Sure. Suppose I had an array of Car objects, I could find the Fords with something like

for (Car c : myArrayOfCars) {
   if (c.getManufacturer().equals("Ford") ...
}
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Its essential that you fix the I/O formats in both directions before worrying about the factorial calculation.
Your algorithm overflows an int value with 54 as the input, and actually results in a zero result. You print '0', then read it as a byte - which is ASCII 48.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

In this case i sent msg=6 but no is having 54 value.

That's what I was trying to explain. You print the value 6, which sends the character '6' to the output stream as an ASCII character. The ASCII code for '6' is the numeric value 54. At the other end you read a single binary byte from the stream, which gives you the numeric value 54.
Of couse that doesn't explain why your claculation seems to be wong, but it does explain why its using the wrong data.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Here's the problem: you are writing your data to the output stream as ASCII text, but you are reading from your input streams as raw bytes. It's essential that you read and write using the same format, eg if you print to the output then you should use readLine to read the text input, then convert the text to an int value if necessary.
Like Norm says - add more System.out.println statements to show the values of your variables as the code is executing - that will help you see where it's going wrong.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

anand01
Please don't throw code like that at someone who is trying to learn. At the very least explain it properly. Even better explain enough for the OP to write it himself. That's the best way to learn.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

OK. Please mark this "solved"
J

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

The keyword "new" is wrong here. You are just calling the static method "forName" in the Class class. It's not a constructor.
Class ourClass = Class.forName("com.app.something");

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Ah - OK, thank you Norm.I understand now.
Muhammad - if your problem is solved please mark this thread as "solved" for future reference.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Sorry Norm, I don't understand your post either - maybe I'm having a "senior moment"?
Anyway, the problem here is that some of us forgot what the contents of a JFrame are - they are glass pane, content pane etc. When you add a component to a JFrame the method just forwards the request to the content pane, which is where the component is added. So to remove the components you have to remove them from the content pane, ie you need

 mainWindow.getContentPane().removeAll();

... followed by a quick

mainWindow.repaint();

(despite the API doc, the validate doesn't seem to be necessary)

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

The API doc for removeAll says:

This method changes layout-related information, and therefore, invalidates the component hierarchy. If the container has already been displayed, the hierarchy must be validated thereafter in order to reflect the changes.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

You did compile it. Now you need to execute it. You fill find many many tutorials on the web on how to execute a Java applet.

empror9 commented: thank you :) +2
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

That looks like it compiles correctly but when it executes it does nothing. Your main method has no executable statements in it, so of course it doesn't do anything. But if you are running this as an Applet then main isn't relevant.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Sorry to keep asking, but it's important that we get this straight. Which of the following two statements is true?
1: when i press the compile button nothing happens at all.
2. when i press the compile button I get the message "BUILD SUCCESSFUL ..."

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

What's the complete exact error message from the compiler?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

You probably still have a hard-coded array size or index somewhere in your program
What's the error in Arrays.toString - did you import java.util.Arrays ?

(ps - I'm leaving now - no more posts today)

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Put a load of print statements into your code, printing the values of the key variables at each stage so you can see where it's going wrong.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

If you declare the method as having an array as its parameter then you MUST pass an array to it when you call it, eg

    int[] data = {4.3.0.1);
    Test2.Array1(data);

ps there's a method that does what you hand-coded on line 15 - Arrays.toString(array) - which works the same with arrays of any length or type.

System.out.print(Arrays.toString(array));
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

The easiest way is just to use a "enhanced" for loop, as in

     for (Integer i : list) {
       sum += i; // etc
    }
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

On line 10 you have a { where you should have a }

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

The output of the following line of code is: Not Done End

Not according to Java. I just copied and executed the code you posted and it outputted Not End, exactly as expected. Have you tried it?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Is there any way to make the method accepts any length from the input?

Tecnically yes, you can use Array1(int... n) which declares a variable nunber (>=0) of int params - inside your method you will see n as an int array of the appropriate size.
But in practice most people would use an array as Norm suggests because in the calling program if there is a variable number of ints they will probably be in some kind of array anyway.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Perhaps it's a task switch thing? You could try a sleep(1000) after taking the screenshot but before accessing the clipboard?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

you still don't have an equal number of { (five) and } (four).
Proper indentation will make the error immediately obvious.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

You may have "enough braces", but you don't have an equal number of { (five) and } (four).
Proper indntation would make the error immediately obvious.

Johannady2 commented: /* It's still giving me the same error. vowelConsonant2.java:30: error: reached end of file while parsing } ^ 1 error */ import java.lang.String; import java.io.*; import java.util.*; public class vowelConsonant2{ static Scanner scan = new Scanner(Syste +0
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Yes, it's very likely that the heap overflow is caused by an excess of recursion, however I don't think your max recursion depth should increase so fast with array size (shouldn't it scale with log(n)?). Try putting one or more print statements in each of the methods to show what it's doing then run a (small!) test case - you may find a logic error that is causing too many recursive calls.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Fortunately Sun/Oracle have already written 99% of the code you need. It's all in the standard API.
Use the ImageIO class to read the file into memory, ImageIO will handle all the details of decompressing the jpeg for you.That gives you an in-memory BufferedImage, so you can use its getRGB and setRGB methods to access or update individual pixels. See the Java API doc for details.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Java names are case sensitive. If you look at the API documentatiuon for the String class you will find the correct versions of those method names.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

You won't find a method that converts a whole arraylist in one go. You;ll have to take the Strings one at a time, convert them, and add them to the Float ArrayList.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

How do you declare the arraylist now?
And do you mean change the way it's declared, or convert its contents from Strings to Floats?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

I guess you mean returnResult? You forgot to declare it before you used it.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

You need to scan the pixels in each frame by getting their ARGB values and testing for A (alpha) <255 to identily partially transparent pixels, or A==0 for fully transparent pixels.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

For the GridBagConstraints...
you have fill = BOTH - this makes the buttons as big as the available space. NONE would be a better choice as each button will just be its own natural size

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Line 63: overrided paintComponent, not paint
JFrame's paint method also paints the buttons etc, so by overriding it you mess that up. paintComponent is the JFrame method that paints the content area of the frame before the buttons etc are painted over it, so that's the one you need to override.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

You shouldn't be updating your GUI from your own thread, you should always do it from the Swing thread. Rather than have a loop, you should use javax.swing.Timer to schedule time-based activities for Swing. I would suggest 5 Timers, one per label so you can start or stop the individual Timers whenever you want.
ps: images = new ImageIcon("image" + i + ".png"); means you will read an image file every time you update the GUI (10 times per second!), which will be very slow and inefficient. Read all your image files into an array of ImageIcons when your program starts, then just display the icons from that array.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

If you can't change the class where the button is defined, and that class doesn't make th button public, and it doesn't provide any public methods to access it, then it's not going to be easy. Maybe you can get access to the frame or window that contains the button, then you can navigate the frame's child objects to find the button. If all else fails you can use java Reflection to access the class's private members
Of course there's no guarantee that simply "turning it on" won't screw up some or all of the private logic in the class.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Use print statements to check the values of key variables (eg rowCount) - it loks like maybe rowCount is zero, giving a [0][0] array for which any index value will be out of bounds.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

I tried to read the code in your zip file, but the lack of documenation/comments/good variable names made that very hard. What I couldn't find was where you override paintComponent for your main frame or panel. I saw all kinds of graphics objects and paint methods, but if they don't fit 100% into the standard Swing way of doing things they're simply not going to work.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Without being able to see and run the whole program I'm kinda out of ideas now... sorry

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Exactly which Jthing does Pad-Draw extend?
What does reset() do? Is it OK that you do that every time you add a new component?