• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

swing doesn't work

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've been trying to display a frame, with two buttons using swing. The file compiled, and when I run it, it displays a grey empty box(frame). I tried 'swing' examples from a book, and again, grey box, with nothing in it.
I rewrote the file using awt, and it works fine.
I am using SDK 1.4.0 beta 3, on WIN98SE.
Any idea?
Berko
 
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try out the following example and let me know that it runs on your platform or not :

Good luck
Rashid Ali
[ January 22, 2002: Message edited by: Rashid Ali ]
 
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why don't you show us your code. Are you by chance creating an Applet with Swing? If so, you need the plug in to get it to run.
 
dodo dimitrius
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys!
Rashid, I tried your code, and the result is the same, the frame (grey box) displays with no elements on it(button and textfield).
Paul, here is my code:
import java.awt.*;
import javax.swing.*;
public class BoxStacker {
public static void main(String[] args) {
JPanel p = new JPanel();
p.add(new JButton("Save"));
p.add(new JButton("Hello"));
JFrame f = new JFrame("Berko");
f.getContentPane().add(p);
f.setSize(200,200);
f.setVisible(true);
}
}
It displays the frame with the name on it, but there is no buttons inside, just grey empy box.
Any idea?
Berko
 
Rashid Ali
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear Berko
I tried your code and it works fine shows two buttons on the little frame having title 'Save' and 'Hello'. I did not made any change in your code just compiled and run.
I think there's some problem with you J2SDK1.4 due to which it's not working on your computer.
Reinstall it again and try your code it will definitely works fine.
Hope it helps.
Rashid Ali
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic