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! |