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