JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Did you compile this? rowInput < 1 may not work too well when rowInput is a String!

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

client-server-client really isn't hard at all. You already have the code for receiving messages from a client and sending them to a client, so the forwarding code is a very small and easy addition.
On the other hand, configuring machines that are probably behind a NAT router and one or more firewalls to receive incoming connections is a total minefield of problems.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

That is also extensively documented on the web at every level from complete beginner to expert. Why do you think anyone here has the time to write you your own personal tutorial?
Put in some efort yourself. Do some research. If you then still have specific questions or problems then ask them here and someone will help

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Sounds like you expect A to connect directly to B? That implies that B has a server running an open server port that's accessible from the internet.
Normally an app like this uses the server to route messages from one user to another, so no user needs to know anything about the other's connection, and the clients do not need to operate in server mode.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

I assume that you did take a quick moment to Google JAX-WS vs JAX-RS before asking for help...
Having read the first few answers from that search, what uncertainities are you trying to get resolved here?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

That's what I said.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

In your paintComponent you need to paint all the lines and all the rectangles etc. That's one loop thru the lines array, folowed by one thru the recs array (etc). The code you posted just paints lines, and there's a variable ShapeType that makes no sense

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

After updating the lines array, eg after line 63.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Here's a little demo I wrote a while ago that runs on Java 7 and has a transparent/shaped/undecorated window (JFrame window2). Maybe you can find what you need to know in this code? I remember that the order of the setUndecorated/setBackground/setOpacity/setVisible is critical. J.

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Shape;
import java.awt.Toolkit;
import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.geom.Ellipse2D;
import java.lang.reflect.Method;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.Timer;


public class DemoWindows implements ActionListener {

   public static void main(String[] args) {
      // create a new demo, and update it every 50 mSec
      new Timer(30, new DemoWindows()).start();
   }

   int phase = 0; // demo runs a number of consecutive phases
   int count = 0; // each of which takes a number of timesteps

   JFrame window1 = new JFrame("Java windows demo");
   JLabel text1 = new JLabel("<HTML><H1>Hello" + "<BR>Everyone");
//         "<HTML><H1>This is a demo of some of the effects"
//         + "<BR>that can be achieved with the new Java"
//         + "<BR>transparent window methods</H1>"
//         + "<BR>(requires latest version of Java)");
   JFrame window2 = new JFrame("Java windows demo");
   JLabel text2 = new JLabel("<HTML><center>Java<BR>rocks");

   int w, h, r, x, y; // parameters of iris circle

   DemoWindows() {

      // build and diplay the windows
      window1.add(text1);
      window1.pack();
      window1.setLocationRelativeTo(null);
      window1.setVisible(true);

      window2.setUndecorated(true);
      window2.setBackground(new Color(0, 0, 0, 0)); // alpha <1 = transparent
      window2.setOpacity(0.0f);

      text2.setFont(new Font("Arial", 1, 60));
      text2.setForeground(Color.red);

      window2.add(text2);
      window2.pack();
      window2.setLocationRelativeTo(null);
      window2.setVisible(true);

      // parameters of the smallest circle that encloses window2
      // this is the starting pouint for the "iris out" effect
      w = window2.getWidth();
      h …
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

That's right. In my pseudo code there's a boolean "valid" that is set to tell you if the int value if OK or not. You would then wrap that whole thing inside a loop like the one I posted earlier and keep looping/prompting/inputting/parsing until the boolean tells you the input was ok and the int value is ok to use.
There may be slicker ways to do it, but this pattern is very general, and can be used for inputting booleans, or chars that must be one of a small set, or requiring int values to be in a specified range etc etc

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

You could read the user's input as a String, then try to parse it and catch any exception something like this

read input
try {
   intVar = Integer.valueOf(input);
   valid = true; // if we get here the string was parsed OK
} catch NumberFormatException {
   valid = false
}
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

When you add lines etc in your mouse handler there's no way for Java to know that this will affect the way the panel is painted, so the paintComponent won't get called. After updating the Lines etc, call the repaint(); method for your drawing panel, so Java will schedule an update of the panel and call your paintComponent.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Start with one simple validation, get it working, then repeat that pattern.
Here's a typical pattern for inputting one value and validating it, with an initial prompt, and a different re-prompt after errors:

display normal request for input
while (true) {
   get user input
   if (user cancelled) exit program // give user a way out if they can't get input right
   validate user input
   if (input is valid) break;
   display error message/re-prompt for input
}

the "validate user input" may involve catching an exception, but you can handle that right there and generate an error message, so the structure remains simple.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

NEVER NEVER NEVER ignore an exception when writing or debugging code!
Java has created an instance of SQLException packed full of debugging info for you, and you have chosen to ignore it. Bad move.
Repeat after me: e.printStackTrace() e.printStackTrace() e.printStackTrace() ...

:)
J

somjit{} commented: that was fun to read! :D and it worked :D +3
riahc3 commented: Step 0 should be this +6
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

A new thread sounds like a good idea - the question is relevent to so many applications other than just t-t-t

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

It's always a good idea to protect your program from bad user input. The alternative is just to let it all crash, which will upset the user and reflect badly on your programming skills!
It's not hard - a simple loop that keeps prompting the user and validating the input until the input is valid. You are going to have to do this in almost every program you write, so it's a bit of an effort to get it right the first time, but then you'll know how to do it and the rest will be easy.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

There's no problem using an s format for enums - print will actually use the enum's .toString() anyway, so you can use a fixed-width string format like
printf("| %6s | %6s | %6s |", board[0][0], board[0][1], board[0][2])
Where it all falls down is if you want to center the shorter strings in their width - there's no format for that so you have to do tacky stuff with calculating how many blanks to add (AFAIK)

ps
boolean squareStatus = false;// needs comment because you have no idea what true or false would mean much better just to give it a good name, egboolean squareIsFull = false; // obvious what that means!`

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

cant you guys please do that for me please

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.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

I'm not reading all that code either, but it sounds like you need a single controller class that deals with the database, keeps the timer(s) and creates or re-displays the question frame(s) as required.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

This web page has details on running the JRE from a DVD or thumb drive (first answer)

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

If its someone else's computer then you may have all kinds of objections to installing Java on it.
If you have enough room you could put a JRE on the thumb drive, and use a tiny batch file on the drive to invoke javaw.exe from that drive to run your jar (use relative paths in the .bat so it doesn't depend on the drive letter). There's quite a lot of stuff to Google on the web if you need more detailed instructions.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Just try adding a pack(); after line 106 ( getContentPane().add( buttonPanel, BorderLayout.SOUTH ); )

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

^ like he said, plus you don't need to put the variable names in parenthesis
if (variable1 && ! variable2) ...

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

That seems clear enough. Obviously Tester doesn't implement an add method, and doesn't extend any class that it can inherit add from.
ps the paint method is seriously wrong. Every time it's called you add jName again. Depending on what's happening on the screen paint may be called many times - it's outside your control.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

It's true that getters and setters promote encapsulation compared to directly sharing variables. But passing values as parameters keeps them in a smaller scope which is even more "encapsulated".

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

This can work either way, so it's a question of which is clearer/safer. Here's my opinion...
the user's selected row/col is a transient kind of thing that isn't really an attribute of the ttt board, so I would go with local variables in the user input method, and pass them to validation methods etc as required.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

From your description it's not clear which is better. It sounds like the clearest structure could be

while (more)
   get user input
   if (isValid(input)) process(input)

isValid may involve a number of separate methods, but personally I would hide that complexity inside a single "master" method, rather than clutter the main loop with irrelevant detail.

My objection to using instance variables here is that they are a form of hidden dependency between method calls - the methods need the variables to have been set, and may assume that they have already been processed by another method, but that's not obvious.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

There's no one right answer to this, but here are two very short answers to start the discussion...

If those values represent something persistent about the MyTest instance that is relevant to a number of methods then they should be instance vars (with getters/setters) and should not be passed in as parameters.

If they are just needed for the doSomething method, and will vary from one call to the next, then they should be passed in as parameters, and there's no reason for them to be instance variables.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

How did you try to run it? Double-click? Command line? Does that computer have a Java runtime installed?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Calls to instance methods are resolved at run time, so when you call addAll or add from an instance of InstrumentedHashSet the JVM looks for versions defined in InstrumentedHashSet, and only looks for them in HashSet if they are not overridden in InstrumentedHashSet (unless you explictly use the super keywod which makes the JVM start looking for the method in the current objects superclass).

Don't worry too much about the addAll doc - addAll is defined in java.util.AbstractCollection, which does not have a proper implementation of add, it just throws the unsupported exception. When you subclass java.util.AbstractCollection with a non-abstract class you will have a real add method, so everything is OK.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

No-one here can run your code because (a) that's not the definitive current complete version and (b) we don't have the database. Perhaps you can prepare and post a complete runnable stand-alone minimum version that someone here can run to reproduce and help fix you problem?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Did you try calling pack() on your JFrame after adding all the components?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

i felt a little more info would have been more helpful.

Yes, absolutely. We really try to discourage people from posting homework solution code without explanation or any attempt to teach.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

from where will your toDate() method get its string?

??? Nobody has any such method! There is a toDate(String str) method, and it's obvious where that gets its String.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

It may be a lot easier to extend something that has a paintComponent method, and include the rounded rectangle by composition rather than subclassing...

class RRectText extends JComponent {
    RoundRectangle2D rect;
    String text;
    public RRectText(float x, y, w, h, arcw, arch, String text) {
       rect = new RoundRectangle2DFloat(z,y, ...
       this.text = text;
    }
    ...
    public void paintComponent(Graphics g) {
        g.drawShape(rect)
        g.drawString(text, ...
    }
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

I'm not familiar with dtexec, but isn't /f part of the arguments, not part of the command itself? And isn't the final .dtsx part of the first argument?
I would have guessed
{"dtexex","/f C:\\EconAnalysisConferenceBoard\\EconAnalysisConferenceBoard\\EconAnalysisConferenceBoard\\ConferenceBoardETL.dtsx"};
(note space between /f and c:), or maybe
{"dtexex","/f", "C:\\EconAnalysisConferenceBoard\\EconAnalysisConferenceBoard\\EconAnalysisConferenceBoard\\ConferenceBoardETL.dtsx"};

Stuugie commented: Thank you for trying to see me through this, I really appreciate it! +2
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Something like this...

String[] runParameters = {"command", "arg 1", "arg 2"};
// array of strings, first is command, following are the args required for that command
Runtime.getRuntime().exec(runParameters);
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

ProcessBuilder is nowdays recommended over Runtime.exec, but in this case there's probably no real advantage. The main thing is to pass the dtexec and its parameters in separate elements of a String array, not just as one String.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

In the absense of quote marks that's true, but if, for example you have a path for the executable that contains blanks (eg default Windows 7) you have major problems. I'm not saying that it's parsing is unclear or undocumented. I'm saying that it often does not do what you want or need.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

The version of exec that takes a single String as its argument is full of problems if you have a command with arguments, or spaces or quotes anywhere in it. It tries to parse the command/arguments itself and often gets it wrong.
There is a version of exec that takes a String array as its parameter. Put the command (executable) in the first element, and the argument(s) in the following element(s). No need to put quotes round any of them. This avoids all those problems.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

You are doing (trying to do) the right thing. You just need to get your syntax right on that one line. You are not calling a constructor, so the new keywod is wrong. It's jus a simple method call, like the example I gave you earlier.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

That looks 99% right!
getSubimage (note capitals - Java is case-sensitive) is a method in the BufferedImage class, so you need an instance of BufferedImage to call it, eg
myImage.getSubimage(0, 0, 100, 100) returns the top left 100x100 pixels of myImage as a new BufferedImage

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Calling your class Applet isn't an error as such, but is guaranteed to cause problems since Applet is an exsting class in the API that you are trying to use at the same time. First thing to do is to change it to a unique name. (Don't forget to change the .java dile name to match).

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Instead of that loop you just need to add the right number of Strings to columnNames. You already have an example of adding right there (it's just columnNames.addElement("My first column name"); etc)

ps: Many of our members have English as their second (or third...) language, so "leet" or other semi-coded language will be unreasonably difficult for them. Please keep to proper English.
DaniWeb Member Rules include:
"Do post in full-sentence English"
http://www.daniweb.com/community/rules

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

This is where the column names are created...

for (int i = 1; i <= columns; i++) {
   columnNames.addElement( md.getColumnName(i) );
}

.. so instead of that just add your own preferred Strings to the Vector colmnNames

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Exactly which variable / method return is null?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Lines 16-22:

portList = CommPortIdentifier.getPortIdentifiers();
...
System.out.println(portList.nextElement());

while (portList.hasMoreElements()) {
  ...
  portId = (CommPortIdentifier) portList.nextElement();

This may be a problem. You call nextElement for the println, which will print the first element in the Enumeration, so your while loop will start with the second element (if any) in the Enumeration. The first element will never be processed in that while loop.

(This is a surprisingly common problem - someone adds a println(...nextElement()) to help debug their code, but by consuming an element the print breaks the code it's meant to help test.)

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

You have a String in a known format and you want to convert that to a Date object - yes?
If so your first code was the right approach. Did you fix the format specification as noted by Schol-R-LEA

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

You seeem to be confused about the Date class.
A Date object represents an instant in time, and has methods to access it. It does NOT have a format. When you convert a Date to or from a String that's when a format is applied.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

It must be hard, working all day with such a range of languages when really you don't enjoy it. Maybe you can use it as a springboard for moving on to something that you will enjoy more? I know I've had jobs where it was hard to tear myself away in the evenings, and others where it was hard to get up in the morning, and I know which I preferred!
Anyway, if "that's it" then please mark this solved.
J