Google Answers Logo
View Question
 
Q: Java - Drawing an Oval on a form that is created in NetBeans 5.0 ( No Answer,   0 Comments )
Question  
Subject: Java - Drawing an Oval on a form that is created in NetBeans 5.0
Category: Computers > Programming
Asked by: mikedynamite-ga
List Price: $15.00
Posted: 01 Nov 2005 18:17 PST
Expires: 03 Nov 2005 15:53 PST
Question ID: 587793
I am fairly new to developing java applications and I know that I am
using a beta version of NetBeans however that should have nothing to
do with the problem I have.

My Problem: 
I am simply trying to draw an oval on a form. My form consist of
several textboxes, labels, and buttons all created with the Netbeans
graphical tools. All of the tutorials I have read tell you how to
display graphics and add buttons but not with a Netbeans form. There
is probably a very simple solution however with my lack of Java
experience I am missing it.


I have tried to create a class as follows:

import java.awt.*;
import javax.swing.*;
import java.awt.geom.*;

public class SimpleShape extends javax.swing.JPanel {
        
    public void paintComponent(Graphics g) {
         super.paintComponent(g);    // paints background
        
         g.setColor(Color.blue);
         g.drawOval(50,50,30,30);
         
    }
}


and then implement it like the following:

import java.awt.*;
import javax.swing.*;
import java.awt.geom.*;
import java.awt.Graphics2D;

public class PlasmidGUI extends javax.swing.JFrame {
        
        JPanel drawOval = new SimpleShape();

        Plasmid p = new Plasmid();         
        String name, vector, insert, promoter;
        int event = 0;      
        
    /** Creates new form PlasmidGUI */
    public PlasmidGUI() {
        initComponents();                 
        dispPlasmid();

        I Want to draw the oval here!! 
...
}

Thank you ahead of time!

Clarification of Question by mikedynamite-ga on 03 Nov 2005 15:51 PST
I found a way to over write the paint method for the JFrame and
display the oval however it is codded in an accepted manner.

    public void paint(Graphics g) {
         super.paint(g);    // paints background        
         g.setColor(Color.blue);
         g.drawOval(200,360,250,250);
    }
Answer  
There is no answer at this time.

Comments  
There are no comments at this time.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy