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();
}
}

Your method initGUI() is never called, so you never create the GUI.

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

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.

Member Avatar for hfx642

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).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.