StephNicolaou 32

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: [URL=""][/URL]

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

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:


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:


StephNicolaou 32

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. [code]
JPanel p = new JPanel();
p.setLayout(new BoxLayout(p, BoxLayout.PAGE_AXIS));

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:

[B]Box Layout Example[/B][URL][/URL]

[B]Box Layouts[/B][URL=""][/URL]



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

Hope that helps

StephNicolaou 32

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.



[B]Class file:[/B]

Hope that helps :)

dantinkakkar commented: Excellent answer [I would like to add something to make the job easier, though.] +3

StephNicolaou 32

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.

  1. 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.

  2. 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.

  3. 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 part of the timetable ...

StephNicolaou 32

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

StephNicolaou 32

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

Have you tried the get method?

[B]$_Get Variable on w3s:[/B]


[B]Session Variables:[/B]


echo $_GET['age']; or
$var = intval($_get['age']);

StephNicolaou 32

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


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

Instructions are provided below:


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


StephNicolaou 32

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:



JamesCherrill commented: Clear and very informative +14

StephNicolaou 32

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;
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);


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.


StephNicolaou 32

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 [. . .]"

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.


PS. ...

BitBlt commented: Thanks for posting your solution! +6