Go Back   PCMech Forums > Help & Discussion > Web Design / Development

Need Some Help? Type Your Keywords Here:

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Old 03-04-2003, 09:23 PM   #1
Member (8 bit)
 
nikerw's Avatar
 
Join Date: Jun 1999
Location: Valley Center and Manhattan, KS
Posts: 135
Send a message via AIM to nikerw
Java programming

Disclaimer: Im in a java programming class in college and the professor doesnt do very good at explaining things, so dont be suprised if you see me posting quite a few questions on the boards.

OK, my first question. I am making a multiplication table using nested for statements and MVC architecture, not really because it is the only way to do it, but because it is required for the class that we do it this way. Anyways, I made my multiplication table, but when I am displaying it the spaces get all messed up. Is there a tab command for java, and will it line up the numbers in vertical rows. To see what I am talking about I have attached my jar file. Thank you very much.
Attached Files
File Type: zip program 6.zip (7.5 KB, 30 views)
nikerw is offline   Reply With Quote
Old 03-06-2003, 05:12 AM   #2
aym
Registered User
 
aym's Avatar
 
Join Date: Nov 2001
Posts: 1,965
Hi,
I did some modifications to your files:
1)When you override JComponent.paintConponent(Graphics), make sure that you call the super function in the first line of the new function's body.
Code:
super.paintComponent(g);
2)Instead of using JFrame.setSize(int, int),I recommend using JComponent.setPreferredSize(int, int), or in your case, when subclassing JComponent, override JComponent.getPreferredSize()
3)To make sure that the program exits after closing the frame, use:
Code:
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
4)After creating the frame, call JFrame.pack()
5)You missed String[] parameter of function main in class StartUp.

Now, your program works, but it only displays headers, I didn't touch the model class, try to do it yourself, and if you have problems, just post!
Attached Files
File Type: zip new.zip (4.0 KB, 27 views)
aym is offline   Reply With Quote
Old 03-06-2003, 10:25 PM   #3
Member (8 bit)
 
nikerw's Avatar
 
Join Date: Jun 1999
Location: Valley Center and Manhattan, KS
Posts: 135
Send a message via AIM to nikerw
I have it all figured out now, thank you very much, I made some stupid mistakes, and finally figured out the spacing. I also figured out why you probly couldnt see anything but the header. If another window gets infront of the display frame, and your things you painted on there wern't in the paintcomponent method then it doesnt repaint them. hmmm....java....fun language.....
Thanks a lot.
nikerw is offline   Reply With Quote
Old 03-08-2003, 07:51 AM   #4
aym
Registered User
 
aym's Avatar
 
Join Date: Nov 2001
Posts: 1,965
This happens because the window needs to repaint itself after reactivating, this isn't only in Java, it happens in MFC too.
aym is offline   Reply With Quote
Reply

Bookmarks

Still Need Help? Type Your Keywords Here:


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 12:31 PM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
SEO by vBSEO 3.6.0 PL2