MajorGeeks Support Forums

Go Back   MajorGeeks Support Forums > ----------= PC, Desktop and Laptop Support =---------- > Software
Register FAQ Members List Calendar Casino Mark Forums Read

Software Software such as operating systems like Windows XP, Windows Vista, Windows 7 etc., or specific programs.


 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 04-04-04, 20:14
Computer Acolyte Computer Acolyte is offline
Senior Member
 
Join Date: Dec 2003
Posts: 104
Thanks: 0
Thanked 0 Times in 0 Posts
Default Java help

Ok this is a very basic problem but I can't figure out what's wrong.
I'm learning the awt (Abstract Windowing Toolkit) package (I know it's old but that's what the Java book has)
Anyway, I wrote a small program just to see how it all fits together, it's supposed to give me a window titled "Animals" with 3 colored buttons.
Here's the code:

import java.awt.*;
public class TestAwt {
public static void main(String[] args) {
Frame frame=new Frame("Animals");
Panel panel=new Panel();
Button b1=new Button("Dog");
Button b2=new Button("Cat");
Button b3=new Button("Hamster");

b1.setForeground(Color.white);
b1.setBackground(Color.blue);
b2.setForeground(Color.white);
b2.setBackground(Color.blue);
b3.setForeground(Color.white);
b3.setBackground(Color.blue);

panel.setBackground(Color.blue);
panel.add(b1);
panel.add(b2);
panel.add(b3);

frame.add(panel);
frame.setVisible(true);
frame.setSize(200,200);

}
}

For some reason all it gives me is the frame (overall window) but no components inside (no buttons, no background [panel]), which is very strange, considering that this program (a simpler version of the previous one) works:

import java.awt.*;
public class Wtf {
public static void main(String[] args) {
Frame frame=new Frame("Alice in wonder land");
Panel panel=new Panel();
Button b=new Button("Press");
panel.add(b);
frame.add(panel);
frame.setSize(300,300);
frame.setVisible(true);
panel.setBackground(Color.black);

}
}

What am I missing here?
Reply With Quote
Sponsored links
 

Thread Tools
Display Modes

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 Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Unknown Java error, possible virus/hacker? kwyjibo Software 1 11-15-03 18:07
Help with Java please. ColonelAngus Software 7 07-15-03 07:43
IE and java morlok Software 17 07-13-03 15:39


All times are GMT -5. The time now is 01:44.


MajorGeeks.Com Home Page
| Admin Tools | All In One | Anti-Spyware | Anti-Virus | Appearance | Backup | Benchmarking | BIOS | Browsers | Covert Ops |
Data Recovery | Diagnostics | Drive Cleaners | Drive Utilities | Drivers | Driver Tools Ergonomics | Firewalls | Games | Game Tweaks | Graphics | Input Devices | Internet Tools | Macintosh | Mail Utilities | Memory | Messaging | Monitoring | Microsoft | Multimedia | Networking | Office Tools | Process Management | Processor | Registry | Security | System Info | Toys | Video | Miscellaneous
|
Powered by vBulletin® Version 3.8.4
Copyright © 2009 vBulletin Solutions, Inc. All rights reserved.
Ad Management by RedTyger