Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link

Tom Rodrigo

Greenhorn
+ Follow
since Dec 07, 2001
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Tom Rodrigo

Hi vikinsa, William, Tim & Ken,
thanks for all of your answers, this is what I needed to know!
Regards,
Tom
19 years ago
Hi all,
I don't know much about JSP and Servlets but was wondering if a package which is intended for the use with JSP/Servlet also can be used for a java application. Can this be done easily or is it more complicated?
Thanks,
Tom
19 years ago
Hello all,
thanks for all of your replies!
I think I agree with Allen: I cannot do what I wanted.
James: I have looked up those nested query things for quite a couple of times but I don't think this will work.
Bald: I have tried your statement, but didn't work. Maybe my database-system does not support the UNION-expression. But anyway, the result would be not what I needed (only the three amount values by only one query).
Nethertheless thank you very much for your help!
Regards,
Tom
Hello Nate,
thank you very much for your response!
I tried your PrintTest() and yes, there is no slowdown, but it makes no difference if BufferedImage is used or not (at least to my printer...)
I also tried BufferedImage on my code, but the problem stays the same.
This seems to be hopeless...
Nevertheless I would like to thank you for giving me some new input and spending your time on my prob.
I'm glad to have a place like Big Moose Saloon!
Tom
19 years ago
Hello all,
I'm wondering if it is possible to get the following three sql-queries in one:
Select sum(amount) as amount1 from tbl_accounts where accountNo like '22%' and customerName like 'A%';
Select sum(amount) as amount2 from tbl_accounts where accountNo like '37%' and customerName like 'B%';
Select sum(amount) as amount3 from tbl_accounts where accountNo like '44%' and customerName like 'C%';
... so that I will get amount1, amount2, amount3 without querying the database three times;
[Note that accountNo and/or customerName can be the same for each query]

I know I can do
Select accountNo, customerName, sum(amount) from tbl_accounts
where
((accountNo like '22%' and customerName like 'A%') or
(accountNo like '37%' and customerName like 'B%') or
(accountNo like '44%' and customerName like 'C%'))
group by accountNo, customerName;
But this is not the same, because I would then get:
22345, avalon inc., 300000
22567, avalon inc., 100000
22664, another inc., 2000
22778, alpha-beta, 234990
37143, betaGames, 10000
37232, big sports, 200000
37734, barcks sparks, 19
44322, cesars palace, 12234
44449, choco dreams, 934290
44450, choco dreams, 60000
44589, cold airwaves, 50000

(so I will have to sum up the amounts for each accountNo starting with 22 (or 37 or 44) )

Is there a way to achieve this (getting the result like amount1, amount2, amount3)?
Thanks,
Tom
[ August 29, 2002: Message edited by: Tom Rodrigo ]
Hi amer,
try:
ImageIcon icon = new ImageIcon("icon.gif");
this.setIconImage(icon.getImage());
where 'this' is your JFrame...

Regards,
Tom
19 years ago
No reply ??
I'm trying to solve this problem for hours and hours, but I still have no clue about it.
There must be a way to do it.
Come on guys, any help is appreciated.
Thanks in advance!
Tom
19 years ago
Hello all,
I want to print a JPanel jp1 and some graphics (rectangle, rectangle2D and drawn Strings) on the same paper.
For some special reasons I cannot add the graphics and the panel jp1 to another JPanel and print this other panel on my printer. So I need to create a printerJob() for my JPanel jp1 and draw the graphics on the jp1 graphics2D in the print()-method.
I have tested this out and everything works fine, but my printer needs a lot of time before printing. I suppose this is because of doubleBuffering, as when I comment out my graphics, my printer prints immediately [for jp1 doubleBuffering is turned off].
Now, how can I disable doubleBuffering for my graphics?
Here is the print()- method for my JPanel jp1:

To make it clear: I must draw my graphics in the print()-method. I cannot add them to a panel. And I need to use Graphics2D. I don't know exactly what doubleBuffering is, maybe it's the wrong way trying to disable it on my graphics, but my printer needs a lot of time before starting to print.
I have no idea how to solve this.
Any comments on this?
Thanks in advance !
Tom
[ August 22, 2002: Message edited by: Tom Rodrigo ]
19 years ago
Hi all,
I need to fill 4*4 = 16 JComboBoxes with data out of a DB2 database. I've figured out two ways to do this, but would like to read your suggestions for the better way...
Scenario:
I want to fill some JComboBoxes depending on the selected Items in other JComboBoxes.
To make it easier to understand let's say I want to visit 4 of my friends around the world, but don't know where to go...
So I first select a continent (stored in the first box) and get a list of the countries (in the second box) where I know the people. I select a country and get a list of cities (in the third box) where my friends live. I select a city and get a list of friends (in the fourth box) in this city.
For unknown reasons I want to visit exactly four of my friends, so I need these 4 boxes four times [in total: 16 JComboBoxes].
All JComboBox-items are stored in a database with something about 3000 rows of data in 5 tables. The queried values are of type int, char, string; the number of items will be no more than 10 for a single JComboBox.
I think there are two ways to fill the boxes, but I don't know which one is better:
Solution 1:
I query the database each time after selecting a value in order to get the items for the next JComboBox. By this way I will have to query my db many times, but it is very easy to put the retrieved values in the boxes.
Solution 2:
I query the database only once and put all data in several vectors, which will be added to one big vector, which is used to fill the JComboBoxes. It seems to be complicated to put all data in the right way in the big vector and also to get the items for a specific box, but this keeps my database-traffic low and maybe it is the most common way to do such a thing.

First I tried to fill the JComboBoxes using solution2, as it seems to be the more professional way, but I found out that it is not easy to get a specific value out of the big vector [and sort it] for I have to do something like this:

So now I prefer solution1, although I have to query my db many times, but it's a small db and also the retrieved data is not as that much.
What do you think? [even any better idea?]
Thanks in advance!
Tom
[ July 31, 2002: Message edited by: Tom Rodrigo ]
Hello Chantal,
I got it working!
I've renamed initialize() to initComponents() and put the initialization into it, as you suggested.
I've also fixed the NullPointerException, so everything works fine now.
Here's the relevant code-sequence:

I think the problem was that I was expecting something like painterPanel.add(MyPainter.MyMethod()) [which should be explicitly called up and returns a graphic object and adds this to the panel], but I suppose, I just have to overwrite paintComponent() and add the whole class-object to painterPanel...
[Maybe I'm using the words not in the right context, but I'm sure you know, what I mean...]
So everything is fine now and this is how I feel:
Thanks to you, Chantal! You really helped me.
Tom
19 years ago
Hello Chantal,
thank you for your suggestions!
As you and all the others will see, I have edited my recent post and corrected my coding. Also my problem has changed, I am getting a NullPointerException now...
1.) myDialog and myPainter (formerly PaintString) are part of a larger project. Actually I don't want to paint only the string, but also some arcs and polygons, so I can't use a JLabel.
2.) corrected.
3.) Sorry, I don't understand what you mean. Could you explain it a little more, please? [perhaps with a code-sequence?] I do not have initComponents() and I don't know what to declare private... I've read some java books about this, but I'm not quite sure if I really understood the things about initialization and private declarations...
4.) corrected.
5.) I am using JFrame only for the main window of my application and JDialog only for the smaller windows in this app.
Many thanks for your help, Chantal!
Any ideas about the Exception?
TIA
Tom
[ July 24, 2002: Message edited by: Tom Rodrigo ]
19 years ago
Hello all,
I have two classes in the same package. Class MyDialog shall create a dialog in my application and request a drawn String for one of its Panels. The String shall be drawn by my second class, called PaintString. I am unable to connect the two classes.
Maybe it is easy, but as I am a newbie, I don't get it...
Any help is appreciated.
Here is the code [I think the problem is in my second class]:

By the way: Could you please give me a feedback concerning my code writing? Do I make severe mistakes??
What about my initialize-try? Do I need a System.exit(0) in every dialog or only in my main frame [MyDialog is part of another frame]?
Please help!
Thanks in advance!!!
Tom Rodrigo
[ July 24, 2002: Message edited by: Tom Rodrigo ]
19 years ago
Hey Rob,
you did it!
It took me some work to pass the JFrame to the JDialog constructor, but it works fine now...
Thanks for you help!
Tom
20 years ago
Hi all,
In my (one and only) JFrame it is possible to call up several JDialogs, only one or two at a time. These jdialogs are setModal(true). Now, everything works fine, but when I start another program, i.e. Windows Explorer, and I want to move back to my little application via the windows-taskbar, it's only possible to view the jframe, but not an (open) jdialog. I can only switch to the open dialog via Alt + Tabulator.
How can I automatically switch to an open JDialog whenever the JFrame is in front of the screen?
I've heard that maybe I should replace the dialogs by frames but I don't want to fill the windows-taskbar with more than one 'button' for the same application...
Any ideas?
Thanks in advance!
Tom
20 years ago
Hey Joe,
I got it!
By pressing 'Apply' the changes are saved to the database and 'newNodeString' is filled with the changed nodes text. Now call:

and everything works fine => the nodes text is updated and no branch collapses. I already tried it with valueForPathChanged(...) some time ago, but maybe I filled it with the wrong values ? Don't know...
When a node is added or removed [which happens not to often, so it�s acceptable], I still call updateUI(); [=> branches collapse; This will do it for now, but maybe I will work on this later...]
As I've read your last posting 5 minutes ago, I'm happy to know you've had the same solution in the meantime, so this might be the most common way for this problem [as i'm new to java; good to know...]
Many thanks Joe for all the support [I'll go and get the candle lit..] and good luck for your project! Have a great day!
Tom
20 years ago