StephNicolaou 32 Posting Whiz in Training

Exactly what the title says...

Look closely at line 3.

Rs.Open "Select * from tblpayroll where EmployeeID= '"+ Trim(txtEmpID.Text) +"' ", Cn
StephNicolaou 32 Posting Whiz in Training

You seem to already know how to get the data entered from a dialog box as the method is already in your code, line 210:

String str = JOptionPane.showInputDialog(null, "Enter tag: ");
jLabel2.setText(str);

Just do the same for the text area. I'd keep it as a label really.

Use the Cursor class.

//Get the image you want
Toolkit toolkit = Toolkit.getDefaultToolkit();  
Image image = toolkit.getImage("img.gif");  

//Set the cursor
Cursor cursor = toolkit.createCustomCursor(image, newPoint(mainPane.getX(), mainPane.getY()), "img");  
setCursor(cursor);

Instructions to set cursor are here:

http://stackoverflow.com/questions/4274606/how-to-change-cursor-icon-in-java
http://www.codebeach.com/2008/02/using-custom-cursors-in-java.html

Research.

StephNicolaou 32 Posting Whiz in Training

1) yes, make sure you've constructed the frame then you can use setVisible(true)

2) Java Web Server - try port 7001

3) Yes.

Google is your friend. Use it.

Servlets:

http://docs.oracle.com/javaee/1.4/api/javax/servlet/http/package-summary.html
http://www.apl.jhu.edu/~hall/java/Servlet-Tutorial/Servlet-Tutorial-First-Servlets.html

Oracle JWS Annotation Reference:

http://docs.oracle.com/cd/E13222_01/wls/docs90/webserv/annotations.html

Oracle Internal Frames Tutorial:

http://docs.oracle.com/javase/tutorial/uiswing/components/internalframe.html

StephNicolaou 32 Posting Whiz in Training

I solved this by just comparing the ID of the Scores instead of the string value!

StephNicolaou 32 Posting Whiz in Training

Cross post!

StephNicolaou 32 Posting Whiz in Training

Olivia, use NetBeans. You can drag and drop all the panels, frames, tabs and components.

If you would like to build/download GUI examples you can find loads of examples in the Oracle guide for all the below GUI layouts:

BorderLayout
BoxLayout
CardLayout
FlowLayout
GridBagLayout
GridLayout
GroupLayout
SpringLayout

http://docs.oracle.com/javase/tutori...ut/visual.html

StephNicolaou 32 Posting Whiz in Training

I usually set db = CurrentDB, store the the db path in a string variable named path, (including the db extension at the end) and then when I set the recordset I can just do this, which will select all of the tables in your database:

Set rs = CurrentDb.OpenRecordset("SELECT Name " & _
                                    "FROM MSysObjects IN '" & path & "' " & _
                                    "WHERE Type=1 AND Flags=0")

Then when you want to select a particular object just do this:

Me.RecordSource = "SELECT * FROM [TableOrQuery] IN '" & path & "'"

When inserting/updating you will need a queryDef.

StephNicolaou 32 Posting Whiz in Training

Need a lot more information to put a whole UML diagram together. All you have here is the object 'Employee' in the many/* multiplicity of a Class or Object diagram. You don't just put a line of Java code into a diagram.

I advise some research on UML diagrams, and the types of UML diagrams that exist:

Use case diagrams
Class diagrams
Object diagrams
Sequence diagrams
Collaboration diagrams
Statechart diagrams
Activity diagrams
Component diagrams
Deployment diagrams


Tutorials:

http://www.smartdraw.com/resources/tutorials/uml-diagrams/
http://visualcase.com/tutorials/uml-tutorial.htm
http://edn.embarcadero.com/article/31863
http://www.objectmentor.com/resources/publishedArticles.html

StephNicolaou 32 Posting Whiz in Training

Okay so in your Java, you use try catch statements, while statements and variables.
PHP is capable of all this so all you have to do is put it into the PHP syntax.

Look at these helpful websites.

How to create variables in PHP:
http://www.w3schools.com/php/php_variables.asp

How to do try, catch (return) in PHP:
http://www.w3schools.com/php/php_variables.asp

How to do while statements in PHP:
http://php.net/manual/en/control-structures.while.php

W3Schools and PHP have a lot more tutorials you could get started on.

StephNicolaou 32 Posting Whiz in Training

Try to use the getSource() method prior to your isSelected if statement (within your actionlistener).

I would also make your price integers public.

if ((e.getSource()) == package1) {
if ((package1.isSelected()) {
...
StephNicolaou 32 Posting Whiz in Training

That's cool. Never heard of this being done before.
From not knowing anything about JNI/JNA, I would say to check that it's connecting to the C files properly, the problem isn't with the suma function, it just can't find it. So you could create a print statement in the C files on connection to them just to test that they're connectig properly. Possibly try to publicise int suma.
I can't offer much more advise sorry!

StephNicolaou 32 Posting Whiz in Training

Gourav1,

The site is the official Oracle website, it doesn't have any problems! All you have to do is click on the exam you're doing and it tells you every possible subject that can appear in the exam, they're not going to tell you exactly which ones- it's an exam! The book will also help with actually studying. Just start studying now and don't procrastinate.

Exam Topics

Section 1: Declarations, Initialization and Scoping
--------------------------------------------------------------------------------

Develop code that declares classes (including abstract and all forms of nested classes), interfaces, and enums, and includes the appropriate use of package and import statements (including static imports).
Develop code that declares an interface. Develop code that implements or extends one or more interfaces. Develop code that declares an abstract class. Develop code that extends an abstract class.
Develop code that declares, initializes, and uses primitives, arrays, enums, and objects as static, instance, and local variables. Also, use legal identifiers for variable names.
Given a code example, determine if a method is correctly overriding or overloading another method, and identify legal return values (including covariant returns), for the method.
Given a set of classes and superclasses, develop constructors for one or more of the classes. Given a class declaration, determine if a default constructor will be created, and if so, determine the behavior of that constructor. Given a nested or non-nested class listing, write code to instantiate the class.

Section 2: Flow Control
--------------------------------------------------------------------------------

StephNicolaou 32 Posting Whiz in Training

I don't know about JNA but there isn't a suma or sum method in Java. Usually you need to create a sum integer variable and calculate sum = a+b and print out the variable, System.out.println(sum). You also need to initiate and assign a and b values...

StephNicolaou 32 Posting Whiz in Training

Initially it looks like you're giving us your assignment to do, "Here is my assignment: Here is your assignment: " and your code isn't in code tags which will put a lot of people off!

You don't really need to setSize a JTextField if you have already constructed it with the number of columns! (JTextField options = new JTextField(30))
I would just get rid of the setSize method (options.setSize(200,150)) but if you really have to then try the setPreferredSize() method instead.

You can setLocation of labels but it also depends which layout you've used. I've never used tabbed layout only border and spring layout where you just state north/east/south/west of the component or state the x,y of how many pixels between each location.

Here is an oracle guide for all the below layouts:

BorderLayout
BoxLayout
CardLayout
FlowLayout
GridBagLayout
GridLayout
GroupLayout
SpringLayout

http://docs.oracle.com/javase/tutorial/uiswing/layout/visual.html

JamesCherrill commented: Clear and very informative +14
StephNicolaou 32 Posting Whiz in Training

When you move your image 'base' left or right, you have updated/repainted its x, y position under key pressed, it the image moving? Is the problem that it's not moving?

StephNicolaou 32 Posting Whiz in Training

Yes, I would say so. With the mouse listener (mouse Clicked event) you could get the x,y co-ordinate for when you display the name of the person when the mouse rolls over the image (mouse entered). You could also draw a rect graphic in the paint method (that facebook has when you enter the photo) and display it over the tagged area using the x,y position.

The mouse listener tutorial can be found here, it's simple:
http://docs.oracle.com/javase/tutorial/uiswing/events/mouselistener.html

Just display a message box on click (mouse clicked event) to get the details (JOptionPane.showInputDialog(), tutorial is also found here:

http://docs.oracle.com/javase/tutorial/uiswing/components/dialog.html

Hope that helps.

StephNicolaou 32 Posting Whiz in Training

Centralised - database in one location
Decentralised - database on more than one CPU

There's lots of this topic online - research!

StephNicolaou 32 Posting Whiz in Training

Exam details can be found here http://www.whizlabs.com/scjp/scjp.html and you can buy the study guide 'SCJP Sun Certified Programmer for Java 6 Exam' 310-065 by Katherine Sierra, Bert Bates.

Also, it is now known as Oracle Certified Professional Java Programmer where the Exam Topics can be found on the Oracle site:

http://education.oracle.com/pls/web_prod-plq-dad/db_pages.getpage?page_id=320&p_org_id=28&lang=US

StephNicolaou 32 Posting Whiz in Training

Have you got a method that orders the rank of "Trainee", "Junior", "Senior", "Administrator" ?

It's still ordering by alphabetical order because they are not numbered in any way so it won't know the rank of these nouns.

StephNicolaou 32 Posting Whiz in Training

You need to actually initiate a number for each case and create a shared/global phone number string to add this number (as a string) to. Then finally output it.

e.g. [case1 = 5, phonenumber = phonenumber & case1], [case2 = 10, phonenumber = phonenumber & case2].

That's not the exact syntax, but the logic I would use.

StephNicolaou 32 Posting Whiz in Training

Try, in a non abstract class then...

return result.toString();

Just to test I would have tried:

public void display() {		
   toString();
   System.out.println(result);
}

Hope this helps...

StephNicolaou 32 Posting Whiz in Training

Line 71 is not needed and you could do the same for line 11 in the second FileRead class.

Also on line 102, filename is within speechmarks.

The coding looks okay, do you have an error message?

StephNicolaou 32 Posting Whiz in Training

Oh right, sorry about that. It would only not go through the first time when the while is at the start as with Q2. Right?

StephNicolaou 32 Posting Whiz in Training

On line 36, you have not identified the actual file name, eg

file = new File(file.txt);

To check that the destination is correct you can use the below methods:

isReadable(Path), isWritable(Path), and isExecutable(Path).

As shown on the Java tutorial ()

"The following code snippet verifies that a particular file exists and that the program has the ability to execute the file."

Path file = ...;
boolean isRegularExecutableFile = Files.isRegularFile(file) &
                                  Files.isReadable(file) &
                                  Files.isExecutable(file);
StephNicolaou 32 Posting Whiz in Training

The score is actually a string so teh problem lays when using the operator...Any ways around this?

StephNicolaou 32 Posting Whiz in Training

Hi, I have a simple query I've used again and again previously, but in this case it's telling me that it is too complex. I've output this sql string into a message and cannot see any problems with the syntax, I'm completely baffled with this one so any help would be greatly appreciated.

SQL = "SELECT * FROM thisQuery IN '" & path & "' WHERE thisQuery.[Score]" & operator & Score

Forms(stDocName).RecordSource = SQL

operator is a variable taken from the form's combo box of =, >, <, etc. and score is a variable taken from the other combobox of 1-5.

StephNicolaou 32 Posting Whiz in Training

Thanks, I suppose you would have to use the index to only remove one of the duplicated values which would depend on the case anyway.

I'm not a programmer, I'm the analyst so don't have an ide at work :o

StephNicolaou 32 Posting Whiz in Training

Yes that was a bit too mean.

Okay for the first question, I think the question would be, a.0. As the rule is while x >100. x is not more than 100 so it won't be stored.

The next one x has to be less than 100, which it is, so 10 will be added to x until it reaches 100. Therefore this will only be 10 times (10x10=100) and then it will stop as the rule is: x numst be less than 100.

A void method is when it does not return a value, where q5 is the opposite, the reference of that return value object.

StephNicolaou 32 Posting Whiz in Training

So, how would you remove a duplicated number in an array list without using "Collection.removeAll(Collection<?> c) " out of interest?

StephNicolaou 32 Posting Whiz in Training

Scanner is the better option.

Also because it has a lot more methods including the boolean methods to check a wide range of input types before to you begin implementing a certain function. As well as pattern matching and find in line, etc.

It's a lot more easier to use.

StephNicolaou 32 Posting Whiz in Training

Do you just want 123456789987654321?

for (int i=1; i<=9; i++){	
   System.out.println("i"+i);
}		

for (int j=9; j>=i; j--){						
   System.out.println(j"+j);
}

But there's probably a more expert way of doing this...

StephNicolaou 32 Posting Whiz in Training

To simply have a counter on the number of times the scanner takes the next line, you just need,

count++

after line 51 with a count variable initialised to 0 at the top of your class. To print this out just used a system print with this count variable after your large if statement/while. To clean up your code a little more you could use,

System.out.println("The number has only five places.\nThe first five characters of your guess will be used.");

where the \n starts a new line.

Also since you are doing the same thins between lines 84 - 93 and 103 - 111, I would suggest placin this in a method and calling it from within the if statement rather than repeating the same coded function.

StephNicolaou 32 Posting Whiz in Training

Where you have readFile( args[0] ); which calls the readfile method, you haven't constructed what the filename is within the method.

StephNicolaou 32 Posting Whiz in Training

Thanks! No don't worry, that's great, it just took me a while getting my head around the 'Java speak' termonologies. It's all sorted now, I understand that the icon needed to be assigned in the JLabel class as that's where the label methods are inherited from and so it was constructing an empty label...

StephNicolaou 32 Posting Whiz in Training

Well, I've just used the setIcon(icon); method in the paintComponent method of the egLabel class. The image now appears. However if I want to set the bounds of labelOne again, it doesnt seem to listen from the main class.

labelOne.setBounds(0,0,X, Y); repaint();
labelOne.getParent().repaint();
StephNicolaou 32 Posting Whiz in Training

Hmm, so I need the main class to know about 'icon', when adding it to the panel? What method would I use in addition to pCenter.add(labelOne, null) ?

StephNicolaou 32 Posting Whiz in Training

Oh I have, I just haven't included that in the code.

In the main publc class section I have:

public ImageIcon img = new ImageIcon("TheImage.gif"); 

int labelAngle=0 //initially!
StephNicolaou 32 Posting Whiz in Training

Hey guys,

I have an Jlabel class and trying to simply add it to the panel in my main class. However is nowhere to be seen! No errors are being output so currently have no idea what wrong...unless you can see whether my method is wrong...

Jlabel class:

public class egLabel extends JLabel{

	int angleOfRotation;
	ImageIcon icon;



public egLabel(int angleOfRotation, ImageIcon icon) {
	 this.angleOfRotation = angleOfRotation;
	 this.icon = icon;

	 this.setBounds(0,0,150,250);
	 this.setVisible(true);
}
. . .

Main class:

labelOne = new egLable(labelAngle, img);
pCenter.add(labelOne, null);

Cleo

StephNicolaou 32 Posting Whiz in Training

Thanks for your advice :)

Currently breaking this down, it works great but shorted is always better.

private JLabel lblRover = new JLabel(imageIcon) {
	protected void paintComponent(Graphics g) {
	Graphics2D g2 = (Graphics2D)g;
	g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
							RenderingHints.VALUE_ANTIALIAS_ON);
	AffineTransform aT = g2.getTransform();
	Shape oldshape = g2.getClip();
	double x = getWidth()/2.0;
	double y = getHeight()/2.0;
	aT.rotate(Math.toRadians(angle), x, y);
	g2.setTransform(aT);
	g2.setClip(oldshape);
	super.paintComponent(g);
    }
};

http://www.java-forums.org/awt-swing/24770-jlabel-rotation-property.html

StephNicolaou 32 Posting Whiz in Training

Hey guys,

I've seen very limited examples out there about this unsupported function, however I am sure there must be a quick method to get this done with the Affine Transform ?

Any ideas appreciated.

Cleo

StephNicolaou 32 Posting Whiz in Training

Cheers, just needed the repaint() within the paintComponent method!

StephNicolaou 32 Posting Whiz in Training

Hey guys,

I've drawn a grid, and I have a label contatining a picture. Whenever I change the location of this label, the grid dissapears until I resize/move the frame.

Any suggestions on best method to buffer these grid lines?

They aren't going to be moving graphics or anything like that so I'm hoping for the most easiest method.

pseudocode
> draw x line
> draw y line
>set bounds of label to x,y

Any ideas appeciated.

StephNicolaou 32 Posting Whiz in Training

This also opens a new frame of the main class, just want to refer to it's variable!

StephNicolaou 32 Posting Whiz in Training

This got a little confusing but I had to use the height in the x line and the width in the y line, and the multiply by x/y instead.

g.drawLine(xPos+i*h, yPos ,xPos +i*h, yPos+w*e);
g.drawLine(xPos, e*w+ yPos, xPos+h*i, e*w + yPos);
StephNicolaou 32 Posting Whiz in Training

Hey guys,

I've constructed the main class to refer to a variable in it and I receive a stack overflow error. Any suggestions on the causes of this error, I've used this method previously and have not got this before.

In other class:

MainClass class = new MainClass();

errors:

Exception in thread "main" java.lang.StackOverflowError
	at java.awt.Insets.<init>(Insets.java:86)
	at sun.awt.windows.WToolkit.getScreenInsets(Native Method)
	at sun.awt.windows.WToolkit.getScreenInsets(WToolkit.java:549)
	at java.awt.Window.init(Window.java:395)
	at java.awt.Window.<init>(Window.java:433)
	at jav

       . . . and so on

Cleo

StephNicolaou 32 Posting Whiz in Training

There was just something else in my coding causing it to go in a never ending loop! yes scanners should normally allow string variables to parse into them for anyone else who needed to know this...

StephNicolaou 32 Posting Whiz in Training

Stupid question deleted.

StephNicolaou 32 Posting Whiz in Training

J,

I'm not taking this personally. I'm happy for people to say what people think, this is supposed to be a learning-teaching environment after all, and I am highly critical of the fact that people simply want to be critical without providing constructive critism! If you want to critise my code, say what is wrong with it. I provided exactly the same reference to another class that you did, as below, before we finally got to find out that a jframe was required.

OtherClass anyName = new OtherClass();
Watcher beholder = new Watcher();

This thread is solved now, finished, it doesn't matter now.

StephNicolaou 32 Posting Whiz in Training

I initially said that I was assuming 'form' was your main class, from what I got of 'initiate my class in the form class'. So, I provided advice on how to construct another class, call a method from another class and return the result from another class, to give you the basics. Then when you later provided some idea that you wanted a JFrame I provided advice on the class having to extend the JFrame, as standard practice.

Any thanks for the advice I have tried to give based on your attempted explaination, instead of any kind of discrimination, would be nice.

StephNicolaou 32 Posting Whiz in Training

Hey guys,

I'm drawing a grid using the nested for loop with draw line method.
Any tips on getting this in the center of my screen?

I am currently using the getWidth and getHeight methods of my center panel but it is still drawing in the top left corner.

It's to do with my drawLine method but I can't get it right...

for(int i = 1; i <= x; i++) {     // y

   for(int e = 1; e <= y; e++) { // x

   g.drawLine(i*h, 0,i*h, centerHeight); // y line
   g.drawLine(0 ,e*w, centerWidth, e*w); // x line

   int X=0;int Y=0;
	
   if (i == 1 & e == 1) {
       X = (i*w+i*w) - roverWidth;
       Y = ((5-e)*h+(5-e)*h) + roverHeight;
       lblRover.setBounds(0,0,X, Y);
   }
}