import javax.swing.*;
import jav.awt.*;
import java.awt.event.*;
public interface Inter
{
public void methodInter();
}
public class Lucky
{
public static void main(String args[])
{
Lucky lk = new Lucky();
lk.run();
}
public void run()
{
JFrame fm;
JPanel pb, pm;
JSeparator sep;
JTextField txf;
String titlename, authorname;
fm = new JFrame("Welcome!"); // create a new frame.
pb = new JPanel(); // create top panel which has a radio button.
pm = new JPanel();
sep = new JSeparator();
pb.setLayout(new FlowLayout()); // setting layout so can add more
//buttons in future.
class JRadioButton1 extends JRadioButton implements Inter
{
private ActionListener al1 = new ActionListener()
{
public void actionPerformed(ActionEvent e1)
{
txf.setText((JRadioButton)e1.getSource()).getText();
}
};
public JRadioButton1(String header)
{
pb.add(super("One radion button"));
// creating a radio button and adding it to top panel.
}
// implementing method Inter by creating 2 new String objects.
public void methodInter()
{
titlename = new String("Charles Dickens");
authorname = new String("Great Expectations");
}
// want to set these String objects to a text field and display the
// textfield.
txf = new JTextField(titlename + "-" + authorname);
txf.setEditable(false);
pm.add(txf); // adding the textfield to the bottom panel.
Container fc = fm.getContentPane();
fc.add(pm, BorderLayout.SOUTH);// adding both panels to the
//frame.
fc.add(pb, BorderLayout.NORTH);
//end of inner class RadioButton1
fm.setVisible(true);
fm.pack();
}
}//end of class Lucky.
Hi,
Can anyone please tell me whats wrong and how to I correct it?
import jav.awt.*;
import java.awt.event.*;
public interface Inter
{
public void methodInter();
}
public class Lucky
{
public static void main(String args[])
{
Lucky lk = new Lucky();
lk.run();
}
public void run()
{
JFrame fm;
JPanel pb, pm;
JSeparator sep;
JTextField txf;
String titlename, authorname;
fm = new JFrame("Welcome!"); // create a new frame.
pb = new JPanel(); // create top panel which has a radio button.
pm = new JPanel();
sep = new JSeparator();
pb.setLayout(new FlowLayout()); // setting layout so can add more
//buttons in future.
class JRadioButton1 extends JRadioButton implements Inter
{
private ActionListener al1 = new ActionListener()
{
public void actionPerformed(ActionEvent e1)
{
txf.setText((JRadioButton)e1.getSource()).getText();
}
};
public JRadioButton1(String header)
{
pb.add(super("One radion button"));
// creating a radio button and adding it to top panel.
}
// implementing method Inter by creating 2 new String objects.
public void methodInter()
{
titlename = new String("Charles Dickens");
authorname = new String("Great Expectations");
}
// want to set these String objects to a text field and display the
// textfield.
txf = new JTextField(titlename + "-" + authorname);
txf.setEditable(false);
pm.add(txf); // adding the textfield to the bottom panel.
Container fc = fm.getContentPane();
fc.add(pm, BorderLayout.SOUTH);// adding both panels to the
//frame.
fc.add(pb, BorderLayout.NORTH);
//end of inner class RadioButton1
fm.setVisible(true);
fm.pack();
}
}//end of class Lucky.
Hi,
Can anyone please tell me whats wrong and how to I correct it?