JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Check out how a switch works - you haven't quite understood it properly...
http://download.oracle.com/javase/tutorial/java/nutsandbolts/switch.html
The critical sentence on that page is

The switch statement evaluates its expression, then executes all statements that follow the matching case label.

Have a look at the first example on that page. Can you see how that differs from your switch, and why (given the above quote)?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

If it's a database application, would it be possible to save the data by retrieving it from the database and saving that, as opposed to trying to capture it from inside the app?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

list.get(1) returns the HashMap that is in position 1 in the ArrayList.
When you print that HashMap you get its default output, which is a list of the key=value pairs in the HashMap
{id=2, pass=muteki, user=muteki}

list.get(1).get(1) gets the first HashMap then calls get(1) on that HashMap.
Now check out the JavaDoc for HashMap. Unlike ArrayList the parameter for HashMap's get is a key, not an integer position. So you are trying to retrieve the value whose key is the Integer 1, and there's no such key in the map, which is why it returns null.
You need to use something like
list.get(1).get("id")

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Getting at its internal data, without the source code, is going to be near impossible (unless some VB expert knows better?). Investing in adding things to a totally unsupportable program makes no sense to me, even if there is some technical way to achieve that. Seriously - look at writing a replacement program and scrapping the old one. Just how complex is this program anyway?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Nice to know that thre are two of us on the planet who are not watching the royal wedding

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Assuming, for the moment, that this isn't any kind of copyright violation, even if you add a "Save" button, what will it do when pressed? Will you need to access the internal data of the app so you can save it? If so, it may be easier to re-write the whole app in Java

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

You re-load the image from file every time you draw it. That's wh yit's slow.
Read the file and create the buffered image once, at startup.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Mattox is right. It's probably a problem in your run configuration. In particular check that your "main class" is MailClient in the run configurations dialog.

see if ... its just eclipse being a pain

The usual way that Eclipse is a "pain" is because it insists on helping you to have an error-free program and configuration. The chances of it being an Eclipse error rather than your own are roughly on a par with winning the lottery...

when i go to compile it in eclipse i get an error along the lines of cant find "main" class, program will now terminate

No. You do not get that error trying to compile anything. The distinction between compile-time errors and runtime errors is important.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Despite appearances that ian't a file. The .class operator is used with a named class to get the Class Object representing that class. So
DefaultWeightedEdge.class
returns an instance of class Class representing the DefaultWeightedEdge class.

It's passed as a parameter to a method to tell the method what kind (class) of Object you want to be created in that method. It's needed as a work-around for a limitation in Java 1,5 types that means you cannot do this:

void myMethod(T param) {
  new <T>();

but you can do this

void myMethod(Class paramClass) {
  paramclass.newInstance();

ps: more info if you're interested
http://stackoverflow.com/questions/75175/create-instance-of-generic-type-in-java

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Looks like Exceptions being thrown and chained inside AGI - is the is Asterisk interface? If so, you will probably get an answer from their support forum.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

for(int j =1;j%8!=0 ...
why not just
for(int j =1;j<8 ...

if(j==3){System.out.println("");}
looks very wrong, and is why you are getting extra line breaks. Remove it and the formatting is OK apart from the very first line. I suspect the mystery thing you are doing with "some" at the start is to do with getting the first line offset right, so you probably need to use this to get the first line printed OK

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

OR...
You can do a "roll-your-own" mini-RMI using Reflection if you don't mind compromising a bit on compile-time checking and security. It goes like this:

Send via the Socket a command String that is the name of a public void no-params method in the receiver's class.
At the receiver use Reflection to get and execute the named method.
That way you can hook directly from command Strings to callable methods without any nested ifs or switches. It's also really easy to add new commands/methods.

String command = ...

Method m = getClass().getDeclaredMethod(command);
m.invoke(this);

Biggest problem is that this exposes all the classes public void no-args methods to external execution, which may or may not be a security concern. You can obviate this by adding a custom annotation to the callable methods and checking for that annotation before invoking. (This is a part of Java that I'm particularly interested in, so if you want to pursue it further I'd be happy join in)

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

RMI provides a high-level interface for remote method invokation (via sockets, of course) so the server can "directly" call methods on the client (and v.v.), but there's quite a learning curve if you don't need all its facilities.

Sending a String or int to invoke specific functions is a pretty standard thing to do. Purists may prefer to send an enum or an Action.

I find this process works cleanly for closing a bi-directional link:

client wants to close connection:
client sends logoff message to server and exits its read wait loop
server receives message and exits its read loop and closes connection
client ignores any subsequent exceptions related to the connection.

and the same v.v. if the server wants to close.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

I can't give you a complete homework solution, but here's some pseudo-code that shows how to approach it

int offset = 2;  // this is the first element to print, 0 - (length of array -1
for i= 0 to (length of array -1)    // this controls how many numbers to print
   print array[offset]
   offset = offset + 1
   if (offset >= (array length)) offset = 0
}
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Loop with an index variable that starts from 2, but then when you increment it test if it is >= (length of the array), in which case set it back to 0.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

add is't static because you add a JThingy to an instance of JFrame, not to the class JFrame. Here the normal template for stuff lkike this

public class Main extends JFrame {
  ImageIcon ic1=new ImageIcon("12471.jpg");//12471 is an image :)
  JLabel lab1=new JLabel(ic1);
  ...
  public static void main(String []args) {
   new Main();
  }

  public Main() {  // instance constructor
   add(lab1);
   setSize(200, 200);
   setVisible(true);
   ...
  }
  ...
}
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Yes, pass it as a parameter to as I explained earlier. The example shows how to approach it.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

There are two separate steps needed to create an initialised array.

1. You create an array of a given size, as in

int size = 100;
char[] use = new char[size];

use now contains 100 uninitialised slots (not strictly true for an array of primitives, but still the safest way to think about it)

2. Now you can fill those slots with values, as in

for (int i = 0;i<size;i++){
   use[i]='a';//keep as a until rewrite
}

You were getting the NPEs that you had to suppress because you omitted the first step, and were trying to put things into an array that didn't exist yet.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Not sure I understand the whole of your requirement, but
If PlotExpression needs a value for stringFunction in order to work, and especially if that value is unlikely to change within one instance of PlotExpression, then passing it as a parameter to the constructor would be the obvious way to go.
Eg if my Person class must have the person's name:;

class Person {
   private String name;
   public Person(String personsName) {
      name = personsName;
   }
   ...
   paintComponent(Graphics g){
      g.drawString(name, ...
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
int i=0;
char []use=null;
try {
  for (;i<100;i++)//use will have a length of 100 
  {
    use[i]='a';//keep as a until rewrite
  }
}
catch (Exception e) {
}

That looks wrong.
Array "use" is null, then you try to access elements in this (non-existent) array, and use an empty catch block to ignore the resulting NPE.
Maybe I misunderstand your code, or is this something more cunning than it appears?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Problem is on you very last line. If we delete the final comment block then we are left with...

...
	//String toEnum=use.toString();
	cmd=use.toString();//put use into enum form
	
//}	
}
}
}//why do we need another?

*/

Delete the incorrectly duplicated */ and its OK

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Also, look immediately after the place where the } was requested - you may have some other error that makes the compiler think you must have finished the current class definition

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Post the code here (in code tags, indented)

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

The problem is that you don't have all the needed ones.
Or, possibly, you have found a bug in the Java compiler that not one of the thousands and thousands of users have discovered in the last 2 decades.
So, less self-confidence and more careful code reading.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

I don't know why you have that while loop anyway. Just write/read with

ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream("questions.dat"));
out.writeObject(questionList);

and

ObjectInputStream in = new ObjectInStream(new FileInputStream("questions.dat"));
Vector<Question> questionList = (Vector<Question>) in.readObject();

plus some try/catch/close boilerplate

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

OK. Time to mark this thread "solved" please.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

5-6 lines down in the stack we see

at ticketReservation.<init>(ticketReservation.java:114)
at bookAngels.actionPerformed(bookAngels.java:163)

the line numbers don't match the code you posted, so you need to look at the constructor for ticketReservation line 114 and see which variable is null.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Sorry, not something I really know about. But I bet there's something similar?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Windows? There is a system environment variable CLASSPATH that contains a list of all the places (paths) where Java must look to find classes. Either your jars go in one of those places, or add the path to where they are on to the CLASSPATH.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Just reading the not-commented stuff I see around line 165 you create a JPanel, create a JScrollPane using that panel, add the JScrollPane to you (main?) frame.
Problem is, I don't see you adding anything to the panel inside the scrollpane.

If you want a window with everything in it scrollable you need to:
create a JPanel
put everything into that panel
create a JScrollPane using that panel
add the scrollpane to your window

http://download.oracle.com/javase/tutorial/uiswing/components/scrollpane.html

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Without the code or the full details of the Exception we can only guess.
But in general an OutOfMemoryError happens because (a) you have a ginormous amount of data in memory or (b) your code is stuck in a loop creating the same objects over and over again (more likely)

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

If it didn't run then, yes, you're doing something wrong!
But without (a) the code and (b) an EXACT description of what does or does not happen when you try to run it (including the full stack trace from any Exceptions), there's nothing more anyone here can do...

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Almost right...
correct sequence of events is:

start motor
start timer (60000 mSec, not 6000 for 60 secs)
in TimerTask: stop motor

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Probably because you override paint rather than paintComponent. paint also handles painting of children (eg lables ina child panel!), borders etc, and should not normally be overridden. paintComponent just handles the painting of the content area, and is the one you normally override.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

OK, I have a little more time now...
You have a choice of java.util.Timer and javax.swing.Timer.
The first is a general purpose Timer, the second is tied into the Swing GUI environment, and should be used for any kind of GUI timing (animation etc).
For java.util.Timer you can use

public void schedule(TimerTask task, long delay)

Schedules the specified task for execution after the specified delay.

Parameters:
task - task to be scheduled.
delay - delay in milliseconds before task is to be executed.

For javax,swing.Timer it's more like

public Timer(int delay, ActionListener listener)

Creates a Timer and initializes both the initial delay and between-event delay to delay milliseconds. If delay is less than or equal to zero, the timer fires as soon as it is started. If listener is not null, it's registered as an action listener on the timer.

Parameters:
delay - milliseconds for the initial and between-event delay
listener - an initial listener; can be null

plus

public void setRepeats(boolean flag)

If flag is false, instructs the Timer to send only one action event to its listeners.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Its all in the API JavaDoc, depending on which Timer class you are using.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Timer is an option. Timers can be one-shot OR repeating. You need a timer with a 60 second initial delay and no repeats.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

I'm really sorry, but there's no point my talking if you aren't listening.
Good luck with your assignment, I'm sure you will get it OK in the end.
J

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Google "Event Dispatch Thread" (EDT or "Swing" thread).
All GUI updates are single threaded on the EDT, as are all GUI-initiated user interactions. So your jButton2ActionPerformed executes on the EDT. While it's executing all other GUI-related activities are queued (including your progress bar re-paints).
There are a number of ways round this but they all involve moving your long-running task off the EDT onto some other thread, thus un-blocking GUI activity. Generally, the SwingWorker class (new in Java 1.6) is a very good option. The standard JavaDoc includes an example of updating a progress bar from a long-running process.

ps Using Thread sleep inside an ActionPerformed is a common beginner's mistake (as explained above) - it can only help if the process has been handed off to another thread. eg by using SwingWorker. In that case you can use sleep to artificially slow down your progess, if that's what you want.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

also implement a loop if that operation is to keep on being repeated

No no no.

The javax.swing.Timer handles the repeating. If you tell a newbie to use a loop in this context you will get a loop with a sleep in it that blocks the EDT and leads inevitably to the post that goes "why isn't by background updating?".

So, no, no loop. Just a swing Timer.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Hey! Was that deliberate? Normal phrase is "heart of gold", but you wrote "hard" as in tough. difficult etc. Neat pun!
I still stand by what I said.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

READ THE DOCUMENTATION!

http://download.oracle.com/javase/tutorial/uiswing/misc/timer.html
http://download.oracle.com/javase/6/docs/api/javax/swing/Timer.html

If you can't use Google to find code samples, tutorials, and reference materials you will never be able to write programs, in any language. Getting someone else to do it for you is not an answer.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Look to me like you need to print some blanks in front of the numbers.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

javax.swing.Timer is what you need - documentation & samples in the usual places.

Define a timer task (a "run()" method) that you want to run repeatedly. On click of the start button start a Timer that will run that task every 3000 msec. On click of the stop button stop the timer.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Good morning S.
This is your homework for you to do. I'll help, but I won't do it for you. I've given you a stack of info to think about, so now it's your turn to put in some serious effort.
Sorry if that sounds harsh, but it's how things work around here, and it really is the best way.
J

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Yes, that, in general terms, is how its done. The instance variables may hold the info needed to do all the work in paintComponent, or they may just be a list of objects that have their own paint methods that can be called from paintComponent to delegate the work. Those 2 options pretty much cover it; experienced developers may be more likely to go for the second variant, depending on the exact requirements.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Add some instance variables to your class (eg a list of shapes, colours, positions ...). Add some public methods to set those variables. Use the variables in paintComponent method to control what/where/how you paint

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

I have given you a number of different ways to count the shapes. Please re-read my previous posts.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

OK, it looked like no spaces. With spaces its easy.
This is from the StringTokeniser documentation:

The following is one example of the use of the tokenizer. The code:

     StringTokenizer st = new StringTokenizer("this is a test");
     while (st.hasMoreTokens()) {
         System.out.println(st.nextToken());
     }

prints the following output:

     this
     is
     a
     test

end quote.

Assuming its the same in Java ME, that's pretty much all you need to know!

Uh-oh. Looks like StringTokenizer is deprecated in ME. The String class has a split method that splits things up OK. Look at that.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

How is that delimited? Is there anything between the sH or the r2?
Suppose the name is
HamishMacDonald64
or
Jean-ClaudeVanDamme75
?