StephNicolaou 32 Posting Whiz in Training
public static int getLineNumber() {    
   return Thread.currentThread().getStackTrace()[3].getLineNumber(); 
}

"The index will change based on the JVM version. I believe it changed from 1.4 to 1.5". Resource: http://bit.ly/xLDhVJ

I have changed the index to [3] instead of [2] but try either based on the version you are using until the line number of where function was called from is correct.

Hope this helps :)

DavidKroukamp commented: cool :) +9
StephNicolaou 32 Posting Whiz in Training

Under your main method (public static void main(String[] args)) call a createAndShowGUI() method that constucts and sets visible the main frame you want to use. Then under your public method you can use the JMenubar package to create menu items that open your other frames. Using this you can create menu items and add them to the menu using methods menuItem = new JMenuItem("part 1") and menu.add(menuItem).

To see the full example, go to:

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

Or you can simply constuct, add, set action listeners of buttons using the:

button = new JButton("Button"),
addActionListener(this) and
add(button) methods, as well as many other things.

Set visible the frame/ "part" you want to appear under each menu button.

Go to the Oracle docs to see these examples:

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

StephNicolaou 32 Posting Whiz in Training

I can't see anywhere that you have constructed any frame or panel in which to add to the frame to then set it frame visible, you can also use a Container...

e.g.

JPanel p = new JPanel();
p.setLayout(new BoxLayout(p, BoxLayout.PAGE_AXIS));
p.add(label1);         
p.add(label2);

I would suggest you look at the BoxLayout or JFrames/Panels tutorials so you can see how a basic class is put together as a whole. Oracle uses a container or you can construct a frame and panel to then add the panel to it. Links provided below:

Box Layout Examplehttp://docs.oracle.com/javase/tutorial/displayCode.html?code=http://docs.oracle.com/javase/tutorial/uiswing/examples/layout/BoxLayoutDemoProject/src/layout/BoxLayoutDemo.java

Box Layouts http://docs.oracle.com/javase/tutorial/uiswing/layout/box.html

Panels http://docs.oracle.com/javase/tutorial/uiswing/components/panel.html#creating

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

I would also make the lables public as you want to use them in a public method.

Hope that helps

StephNicolaou 32 Posting Whiz in Training

It's printerJob, I would advise you to take a look at oracle documents which explain everything to do with setting the jobs, rendering with the Printable interface and opening the printer dialog.

Go through the document list and look at the examples and you should be able to then put something together. Also look at the class file and let us know if you have any problems.

Start with using the java.awt.print.* package as noted.

Oracle:
http://docs.oracle.com/javase/tutorial/2d/printing/printable.html

http://docs.oracle.com/javase/tutorial/2d/printing/dialog.html

Class file:
http://docs.oracle.com/javase/1.4.2/docs/api/java/awt/print/PrinterJob.html

Hope that helps :)

dantinkakkar commented: Excellent answer [I would like to add something to make the job easier, though.] +3
StephNicolaou 32 Posting Whiz in Training

Firstly, you're missing the master data for the people attending the lecture table. You can either have 2 tables; Student Master and Staff Master or a Persons table with a Student/Staff drop-down menu from a PersonsType table.

2. You don't really need two TimeTable's, you can add a Join table between Persons and TimeTable, thus called Persons_Timetable. This should have the fields PersonsID and ClassID. Then you can either show the timetable for one particular student or one particular staff member with all the students they are teaching. Depends on how you would like to write your query.

3. The Working Hours table. You could just add a lengthTime to the SubjectMaster table and work out how many hours the staff member has worked by the subjects they are assigned to. However, if you want it to be like business real-world clocking system in and out of lectures (which is not how the education industry works but whatever), you should add the PersonsID field to the Working Hours table assuming their ID card is coded with their PersonsID card in the DB.

4. The subjectCode in the TimeTable and StaffAllocation table should be a foreign key of the SubjectMaster assuming that you would still like to keep the StaffAllocation table instead of my suggestion of the Persons_Timetable to allocate them together.

Just Remember, a table holds data solely related to that entity/ thing. When it's field like subjectcode is used in another timetable, that isn't a …

StephNicolaou 32 Posting Whiz in Training

Try setting the location of your frame under your listeners, so it will always stay in this position

StephNicolaou 32 Posting Whiz in Training

If you are currently echoing every age option under 100, do you want the selected age?

Have you tried the get method?

$_Get Variable on w3s:

http://www.w3schools.com/php/php_get.asp

Session Variables:

http://www.w3schools.com/php/php_sessions.asp

echo $_GET['age']; or
$var = intval($_get['age']);
StephNicolaou 32 Posting Whiz in Training

Make sure you are using the correct version of the sql connector, Connector/J 5.1.18 is the latest:

http://www.mysql.com/downloads/connector/j/

Check whether you connection is correct, your path, username and password are correct.

Instructions are provided below:

http://www.mkyong.com/jdbc/how-to-connect-to-mysql-with-jdbc-driver-java/

I don't use Netbeans, I would package it in command line so see if that helps.

http://docs.oracle.com/javase/tutorial/deployment/jar/build.html
http://www.skylit.com/javamethods/faqs/createjar.html

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

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

Thanks a lot BitBlt! I got it to work using QueryDefs :)

All I had to do is create the temporary table in the backend table, which made updating much easier, rather than updating a remote table with a local table. Then the update worked fine using the QueryDefs method.

Now I just have to do this throughout my whole database, all in the name of security.

There isn't a lot of information on how to do this on the web so I've posted my code syntax for anyone else looking to do this.

Set up the path to the back-end database:

Dim path As String
path = "C:\BackEndDatabase.mdb"

Set the database to the back-end database:

Set db = OpenDatabase(path)
Dim qDef As QueryDef

Create the update query in the back-end database using QueryDefs:

Set qDef = db.QueryDefs("UpdateQueryInBackEnd")

Within my queries that created the temp table, I added IN '"& path &"' to create the temporary table in the back-end database:

DoCmd.RunSQL ("SELECT DISTINCT [TBLs] INTO TEMP IN '" & path & "' FROM [TBLs] IN '" & path & "' WHERE  [. . .] ;")

Now when updating the tables using QueryDefs, it worked fine:

qDef.sql = "UPDATE TBL1, TEMP SET TBL1.Score = [TEMP]![NewScore] WHERE  [. . .]"
qDef.Execute
qDef.Close

Lesson learned: Insert and Update queries do not work with DoCmd.RunSql when inserting into or updating a remote database. These only work when QueryDefs are used.

Thanks,
Cleo123

BitBlt commented: Thanks for posting your solution! +6