problem with code

Joined
Apr 7, 2007
Messages
3
Reaction score
0
HI everyone!!

I am new to this forum and hope get many friends and help out here..
we can be helpful for each other.Looking forward to get many replies!!


I am new to java.and really need some help.
My problem is with my code.Actually my code is not displaying background color in frame.I have even tried to do that with panel.ButThe only change i see is a strip of selected color at the top of my window.plz help me out with this.
looking forward to your replies.
thanks a lot!!

here is my code:-
this is my main class and the code has other classes too.Plz see why this isn't working


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



public class front extends JFrame{

private JLabel select ;
File file;
private JButton go;
private JRadioButton download,split,zip,Rename,Copymail;
private ButtonGroup radioGroup;


public front()
{

Container c = getContentPane();
c.setLayout(new GridLayout(0,1));
this.getContentPane().setBackground(Color.BLACK);
setSize(530,120);

setResizable(false); // to disable the maximize button


c.add( new Label("Choose the operation to be done :"));



ImageIcon ii= new ImageIcon("split.jpg");
split=new JRadioButton("Splitter",ii,true);
ImageIcon ij= new ImageIcon("zip.jpg");
zip=new JRadioButton("Zipper",ij,false);
ImageIcon ik= new ImageIcon("rename.jpg");
Rename=new JRadioButton("Rename all",ik,false);
ImageIcon il= new ImageIcon("copymail.jpg");
Copymail=new JRadioButton("Copy Mail",il,false);
ImageIcon im= new ImageIcon("download.jpg");
download=new JRadioButton("Download",im,false);



RadioButtonHandler handler = new RadioButtonHandler();


download.addItemListener( handler );
split.addItemListener( handler );
zip.addItemListener( handler );
Rename.addItemListener( handler );
Copymail.addItemListener( handler );
c.add(download);
c.add (split);
c.add(zip);
c.add(Rename);
c.add(Copymail);




// create logical relationship between JRadioButtons
radioGroup = new ButtonGroup();
radioGroup.add( download );
radioGroup.add(split );
radioGroup.add( zip);

radioGroup.add(Rename );
radioGroup.add( Copymail);





// setPosition(250,250);

setSize(300,500);
show();
setVisible(true);

}
private class RadioButtonHandler implements ItemListener {
public void itemStateChanged( ItemEvent e )
{
if ( e.getSource() == download )
{
WebBrowser file = new WebBrowser();
}
if ( e.getSource() == split)
{
Gui file = new Gui();
}
if ( e.getSource() == zip)
{

zipping file= new zipping();
}
if ( e.getSource() == zip)
{

zipping file= new zipping();
}
if ( e.getSource() == Copymail)
{

zipping file= new zipping();
}


}
}
public static void main(String args[])
{
front f=new front();


f.addWindowListener(
new WindowAdapter() {
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
});
}
}
 
Joined
Apr 7, 2007
Messages
3
Reaction score
0
plz help

please help me out!!i really need to solve this i am working on this code but can't resolve the problem..atleast do reply..
 
Joined
Apr 23, 2007
Messages
1
Reaction score
0
A very silly way of doing it but it solves the problem you have :smile:

ImageIcon ii= new ImageIcon("split.jpg");
split=new JRadioButton("Splitter",ii,true);
split.setBackground(Color.black);
ImageIcon ij= new ImageIcon("zip.jpg");
zip=new JRadioButton("Zipper",ij,false);
zip.setBackground(Color.black);
ImageIcon ik= new ImageIcon("rename.jpg");
Rename=new JRadioButton("Rename all",ik,false);
Rename.setBackground(Color.black);
ImageIcon il= new ImageIcon("copymail.jpg");
Copymail=new JRadioButton("Copy Mail",il,false);
Copymail.setBackground(Color.black);
ImageIcon im= new ImageIcon("download.jpg");
download=new JRadioButton("Download",im,false);
download.setBackground(Color.black);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,989
Messages
2,570,207
Members
46,783
Latest member
RickeyDort

Latest Threads

Top