JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Sending mouse and keyboard events depends on the language you use, but the real problem is how to send and update the real-time screen image across a limited bandwith. It all comes down to how you compress the screen images.
We had a long thread on this in the Java forum a while back. If you skip straight to the end you'll find the algorithm that worked best for us. (The code is Java, but you will be able to translate the compression code to VB very easily.) https://www.daniweb.com/software-development/java/threads/254810/find-the-differences-between-two-images-and-the-locations-of-the-differences/

OMER AHMED commented: helpfull but need more clearification +1
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

You posted someone else's code without permission, in violation of the Member Rules. I am not advising you, I am warning you. Write yor own code, and post that.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

This web page has an excellent discussion of how to do it (and how not to do it)

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

It splits the data into an array of Strings, so the first col's data is in array[0], the second in array[1] etc.

ps: Re your SQL code:
You create a new connection for each line of data you add. That's horribly inefficient. Create the connection before enetering the loop, and close it after leaving the loop.

amogh.max commented: yes its horrible code..thanks to you i made some changes. +0
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Switch off your computer.
Get some paper and pencil. Work through a couple of short examples on paper until you have a solid grasp of what to write down and how to do the calculations etc. Then, and only then, turn the computer back on and write a program to implement what you now know.

iamthwee commented: I like this, not enough compsci students do this +14
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Yes, people here will help you to write your Java code. What help do you need exactly? (But be aware that "help you" does not mean "do it for you".)

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Hi
Compiling from the command prompt gives you a "warning: [static] static method should be qualified by type name, A, instead of by an expression" (provided you are using -Xlint, which, frankly, you would be mad not to).

// demo code
class A {
  static void x() {}
  {new A().x();}
}
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

The definitive Oracle tutorials are kept up to date, and include MySQL...
http://docs.oracle.com/javase/tutorial/jdbc/index.html
AFAIK there were no significant SQL-related changes in JDK 8.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Soiunds like a homework question to me!
Read the DaniWeb Rules
What do you think the answer is?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

It means the method is a class method as opposed to an instance method. You do not need an instance of the class to use that method, and the method has no access to any instance variables or instance methods )unless someone else supplies the instance).

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Hey! He's entitled to his opinion. (Although his post would have been better if he had supplied some justification for his opinion.)

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Line 60: shouldn't you be adding the costs, not the sizes?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

That's still a useless description of your problem.

But anyway - if you were to add an action listener to that button it may help.

stultuske commented: nice catch +13
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

There's nothing wrong with 9...9 as a large int, but Integer.MAX_VALUE is the largest possible int, and nicely self-documenting.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

I'm not a C<anything> enthusiast, but this sounds like a generic architecture question, and here's the standard generic answer.

Normally you would have a "game" class that contains (or knows about) all of the data and state information for your game. It has no user interface, but does have public methods to get/set/add its data and state info. You create an instance of it when the game starts.
Whenever you open a new window you pass the game instance to it (eg as a parameter to the window's constructor). The window then can access whatever data it needs, and pass any updates or new data back to the game instance.
In your case, the first form will pass its new Player back to the game instance, and the second form will query the game instance to get the Players.
(Inside the game instance you could indeed use something like a List<Player> to maintain all the player info)

ddanbe commented: I know you're into Java, but definitely in OO also! +15
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Lines 16 & 18 generate two numbers, but you have only one variable to strore them, so the second one overwrites the first.
So
You need at least two variables for the two random numbers, then you can use those to display the question (like line 20).
Once you have the user's input you can convert that to a number (like line 14 but in another variable) and compare that with the correct answer.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Your loop (line 6) keeps dividing number by 2 until it's zero - then you print it. So of course it's zero.
One fix is to use a copy of number in the loop, so the original number isn't changed.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Here's the secret. ActionCommand defaults to the button's text but only if you ask the button itself. An explicit ActionCommand is actually stored in the Model but if you query the model there's no default value there.
group.getSelection() returns the model, so doesn't see the default ActionCommand, only an explicit one.
So you need to set the action commands for your radio buttons explicitly.

(Yes, that's a really stupid design mistake in the Java API)

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Simply call dispose() on the containing window (closes it and releases all its resources) and make sure you have no other references to the JTable so the garbage collecter can get rid of it.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

There are lots of people here who will freely give their time to help you become the best Java programmer you can be. There's nobody here who is interested in helping you cheat or doing your homework for you.

DaniWeb Member Rules (which you agreed to when you signed up) include:
"Do provide evidence of having done some work yourself if posting questions from school or work assignments"
http://www.daniweb.com/community/rules

Post what you have done so far and someone will help you from there.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

I think you best option is to use ProcessBuilder to run an external command or app that writes all that info to a file or output stream, from where you can capture and forward it. The command or app will depend on what version of what operating system you are running.
I don't know of any standard Java API that will give you the information directly.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

DaniWeb Member Rules (which you agreed to when you signed up) include:
"Do provide evidence of having done some work yourself if posting questions from school or work assignments"
http://www.daniweb.com/community/rules

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Jack_11 is just some kid who has been wasting our time.

ps: Using the same IP address was bit of as give-away.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

If this is you final year project then aren't you supposed to write it youself?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

If the nonsense code you posted here is yours then, to answer your original question,...

no, you displayed no special talent whatsoever. You code Java like a complete beginner with an incompetent teacher.

The tragedy is that with the attitude and approach you have displayed here, you will never improve.

Slavi commented: lol'd xD +6
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Admins and Mods have access to your IP address.
It's time to end this bull and move onto something productive.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

MIT offered me a scholarship as soon as they heard my my mother was pregnant, but I was too busy correcting Einstein's mistakes in General Relativity to take it up. I was also on the Apollo 11 mission - it was me who took all the photos on the moon (which is why I'm not in any of them).

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

"And of course I know APIs! "

Of course you do, all of them, 100%.
Well. you really had us all fooled for a while there.
Anyway, I'm going back to working with adults now.
Bye

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Remember also that the programming language is by far the smallest and easiest thing a Programmer has to learn.
Much larger is the API (.net, Java SE API etc) withoiut which the language is useless. The Java API is over 4000 classes with tens of thousands of methods...
Also working with others adds a load of compexity - not just code mamnagement, but working with others, some of who will be really dumb...
Then there's designing/structuring programs - no subsitute for experience here

Stuugie commented: This is what I was thinking, great post! +6
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

"if some body been given a question and has no idea he cant be help"

We help people who show effort. You have been given a detailed step-by-step set of instructions for what to do, but you haven't even tried to follow them. Just start writing code and stop wasting our time.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Yes, sorry. We did hijack your thread for a side discussion about & and &&. That was a bit naughty of us.
Anyway, I'm really glad that you got it working properly. Well done.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Either you have a truely exceptional ability or you don't really understand what it means learn or know a language.
Maybe if you post some examples of your best code people here could tell you which it is?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

I would also avoid that tutorial site. Seems to have been written by someone whith limited knowledge and no experience of Java.

Eg One almost the first page I looked at I found:
variable names like email_address1
use of Boolean rather than boolean
and (where isMatch is a Boolean)...
if (isMatch == true) { ...

truly terrible examples of Java code.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

<Sigh>
I'm sure you know this by now but...

Do provide evidence of having done some work yourself if posting questions from school or work assignments
(DaniWeb Member Rules)

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

20 differ = annualSales,
What is this intended to do? annualSales wasn't initialised explicitly, so differ will just be a copy of its default value of 0

if (n < -1 && n > NUM_EMPLOYEES -1)
Unless NUM_EMPLOYEES is negative, this expression can never be true.

Lots of people (me included) don't have the time to decypher un-indented code.

ps: yes, conventions are matters of opinion, but for Java there are Sun/Oracle's own documented set of conventions that are always used within the Java development community (eg see the source code of the Java API classes), and so those are the ones you should use unless your employer/teacher requires otherwize.

Traevel commented: Agreed! I should've better specified the difference between "opinion" conventions and official conventions. +5
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

I agree with the above.
Time spent on variable, method/function, and class names is time well spent because it leads to code that needs no further explanation.
Personally I'm a fan of the quick one-liner at the top of each block of code stating what it dis going to achieve (eg // get item number from user and validate it... ) because that makes it easier to find the right part of the code.
The one place where the code itself needs comments is where it would be unreasonable to expect the reader to be familiar with the algorithm you are using. Eg I recently needed code to model two balls (different sizes/weights) bouncing off each other. The comment was longer than the code.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Presumably the row variable contains a row number in the range 0 to (n-1) where n is the number of rows in a JTable, and InteractiveForm.this.tableModel is a reference to the JTable's table model, in which case...

InteractiveForm.this.tableModel.getRowCount() gives the number of rows, so
InteractiveForm.this.tableModel.getRowCount() -1 is the number of the last row

so that code is testing to see if row refers to the last row in the table

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

JavaFX has a rich set of classes to handle animation, so you don't need to mess about with low-level timers or (shudder) timing loops.
Have a look at the javafx.animation.Animation class and its TimeLine subclass, and the AnimationTimer class and related tutorials (this one looks pretty good). It's a higher-level way of dealing with events over time that will need you to do some re-structuring of legacy code, but in the end will save you a lot of tedious coding.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Don't forget that Java 8 has been out since last Spring, so you should be using a Lambda expression instead of that clunky anonymous inner class, eg

c.addItemListener(ie -> System.out.println("Your choice was" + c.getSelectedItem()));

http://docs.oracle.com/javase/tutorial/java/javaOO/lambdaexpressions.html#approach9

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

How about checking the values of getEditingColumn() and getEditingRow() ?
(Details are in the API doc as always.)

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

You're getting that error because the constructor you used to create your JTable is a simple one that doesn't build a TabelModel that supports adding rows.

DefaultTableModel is the obvious first choice. To get a DefaultTableModel you simply ask for one, ie

DefaultTableModel tm = new DefaultTableModel(data, colNames);
table= new JTable(tm);

now you have a JTable with a TableModel that supports adding rows.

Setting up the event handler to add the row at the right time is a different problem, but ... one step at a time

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Here's the trick:
JTable is just a view, the actual structure and data is in its TableModel.
Get your JTable's TableModel (DefaultTableModel) myTable.getModel(), and add a new row to that addRow(Object[] data)

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

You never initialise your layout variables (line 24), so all your panels have a null layout manager.

ps: all this padding and boilerplate

       exit.addActionListener(new java.awt.event.ActionListener(){
           public void actionPerformed(ActionEvent e){
               exit_ActionPerformed(e);
           }
               }
       );

can now be replaced with

exit.addActionListener(this::exit_ActionPerformed);
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Thank you, and the same to you
J

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

No, that's not what it outputs. The actual output is

i=1 , j=0
i=2 , j=0
i=2 , j=1

(all you needed to do is to run it)

Just step through the two loops one step at a time...

i = 0
   j = 0
      i == j, continue outer
i = 1
   j = 0
      print
   j = 1
       i == j, continue outer
i = 2
   j = 0
      print
   j = 1
      print
   j = 2 - exit loop
i = 3 - exit loop
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

It would help if yu posted the actual code.
Line 115 you call a method TopCost, but you haven't defined any such method.

Many of your methods are confusing because they set an instance variable, but they also return that value, and when you call the method you ignore the return value.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

... and you didn't think it was worth mentioning that at the beginning?
Is there any other essential information that you want to share with us?

Have you looked at this?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Just FYI - you can also chose what text to show on the buttons, which will make things clearer for the user, eg
Object[] options = { "Right Answer", "Wrong Answer" };
.. which you use with the showOptionDialog(Component parentComponent, Object message, String title, int optionType, int messageType, Icon icon, Object[] options, Object initialValue) method.

See the API doc for details

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

stultuske & I usually agree, but maybe not this time.
In my opinion, real projects end up with a lot of code, and structuring that is the single most important skill in software. Working in a team forces you to define a good structure with clearly separated and defined responibilities and public interfaces for all every module.
UML class diagrams force you think about modules, classes, and their interfaces, and to document those in a standard formal way. "Plain English" may be a first step towards the UML, but it's no substitute.
Do all that and, in the end, writing the code is the easy part.