DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2
  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> ¼¶¼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();
    >
    > }
    >
    >
    >
    >
    > }




Bookmarks

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


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links