0

i have jst started programing in java m beginer.
m making gui which contains a two radio button a slider and a text message.
although its compiling coreectly but it doesnot display any thing

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;

public class GUI
{
JFrame frame;
JLabel coord;
JRadioButton Man=new JRadioButton("man");
JRadioButton Woman= new JRadioButton("woman");
JSlider slider;

public void initGUI()
{
frame=new JFrame();
Container cont=frame.getContentPane();
cont.setLayout(new BorderLayout());
cont.add(Man);
cont.add(Woman);
cont.add(slider);
JTextField numberEnter = new JTextField("ideal weight is:", 20);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(300,300);
frame.setVisible(true); 
}
public static void main (String arg[])
{
GUI g=new GUI();
}
}
3
Contributors
4
Replies
5
Views
6 Years
Discussion Span
Last Post by hfx642
0

oh i got that. but now i have got some other error in running it. it compiles successfully. first error is some nullpointer error.

0

some nullpointer error.

The error message tells you exactly where the error happened. If you post the complete error message here we can have a look at it for you, but first look yourself at the line in your file that it gives you, and look for an uninitialised variable being used on that line.

0

You also may want to correct...

cont.add(Man);
cont.add(Woman);
cont.add(slider);

You are NOT specifying WHERE on your JPanel you want to put these (since you are using a BorderLayout).

Edited by hfx642: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.