java novice needs help quickly


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: java novice needs help quickly

  1. #1
    tawanda chipato Guest

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

    }




    }

  2. #2
    Soft Solution System Limited Guest

    Re: java novice needs help quickly

    If you want to draw, you need Graphics and Graphics2D.


    "tawanda chipato" <tchipato2000@yahoo.com> gl
    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();
    >
    > }
    >
    >
    >
    >
    > }




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center