java novice needs help quickly
i am trying to draw shapes eg rectangles, circles,ellipses on my applications
using but i am failing. here is a sample of my code so far
with jbutton added.pliz reply soonest.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class TwelfthFrame extends JFrame {
public TwelfthFrame() {
Container contentPane = getContentPane();
contentPane.setLayout(new FlowLayout());
contentPane.setBackground(Color.blue);
JButton button = new JButton("Next");
button.setMnemonic(KeyEvent.VK_1);
ImageIcon icon = new ImageIcon("a:forwad.gif","previous");
button = new JButton(icon);
button.addActionListener(new ActionListener()
{ public void actionPerformed(ActionEvent e )
{
}
});
contentPane.add(button);
JLabel myLabel=new JLabel("Hie there!",BorderLayout.CENTER);
myLabel.setLocation(500,500);
myLabel.setSize(100,50);
contentPane.add(myLabel);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);}
public void windowClosed(WindowEvent e) {}
public void windowIconified(WindowEvent e){}
public void windowOpened(WindowEvent e ){}
public void windowDeiconified(WindowEvent e){}
public void windowActivated(WindowEvent e){}
public void windowDeactivated(WindowEvent e){}
});
}
public static void main(String args[])
{
TwelfthFrame frame = new TwelfthFrame();
frame.setTitle("Addition Facts of 8");
frame.setSize(800,600);
frame.show();
}
}
Re: java novice needs help quickly
If you want to draw, you need Graphics and Graphics2D.
"tawanda chipato" <tchipato2000@yahoo.com> ¼¶¼g©ó¶l¥ó
news:3cd4ef1f@10.1.10.29...
>
> i am trying to draw shapes eg rectangles, circles,ellipses on my
applications
> using but i am failing. here is a sample of my code so far
> with jbutton added.pliz reply soonest.
>
> import java.awt.*;
> import java.awt.event.*;
> import javax.swing.*;
>
> public class TwelfthFrame extends JFrame {
>
>
> public TwelfthFrame() {
>
> Container contentPane = getContentPane();
> contentPane.setLayout(new FlowLayout());
> contentPane.setBackground(Color.blue);
> JButton button = new JButton("Next");
> button.setMnemonic(KeyEvent.VK_1);
> ImageIcon icon = new ImageIcon("a:forwad.gif","previous");
> button = new JButton(icon);
>
> button.addActionListener(new ActionListener()
>
> { public void actionPerformed(ActionEvent e )
>
> {
> }
> });
>
>
>
> contentPane.add(button);
>
>
> JLabel myLabel=new JLabel("Hie there!",BorderLayout.CENTER);
> myLabel.setLocation(500,500);
> myLabel.setSize(100,50);
> contentPane.add(myLabel);
> addWindowListener(new WindowAdapter() {
>
> public void windowClosing(WindowEvent e) {
> System.exit(0);}
> public void windowClosed(WindowEvent e) {}
> public void windowIconified(WindowEvent e){}
> public void windowOpened(WindowEvent e ){}
> public void windowDeiconified(WindowEvent e){}
> public void windowActivated(WindowEvent e){}
> public void windowDeactivated(WindowEvent e){}
> });
>
> }
>
>
>
>
> public static void main(String args[])
>
>
> {
>
> TwelfthFrame frame = new TwelfthFrame();
> frame.setTitle("Addition Facts of 8");
> frame.setSize(800,600);
> frame.show();
>
> }
>
>
>
>
> }