?
Solved

Graphics problem... Won't draw our damn oval!

Posted on 2003-03-12
4
Medium Priority
?
161 Views
Last Modified: 2010-03-31
We have some problems drawing an oval. The program is running, but it won't draw(fill) the oval.
The graphics object have been initialized.  

This code lies in a JPanel, that is used in a JApplet.
The code workes if we paste it into a new class(see below) but not in our situation...
Does anybody have an idea?

Thanks!


public void drawSpot(){
         
        Graphics g = getGraphics();
       
        g.setColor(new Color(0, 255, 55));      
        g.fillOval(100,100,15,15);
       
    }

==============================NEW CLASS==============================

package gui;

import java.awt.*;
public class testing1234 extends javax.swing.JApplet {
   
    private javax.swing.JButton jButton1;

    public testing1234() {
        initComponents();
     
    }
    public void drawSpot(){
         
        Graphics g = getGraphics();
       
        g.setColor(new Color(0, 255, 55));      
        g.fillOval(100,100,15,15);
       
    }
 
    private void initComponents() {
        jButton1 = new javax.swing.JButton();

        jButton1.setText("jButton1");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        getContentPane().add(jButton1, java.awt.BorderLayout.CENTER);

    }

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
          drawSpot();
    }
   
   
}
0
Comment
Question by:ballahalla
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 200 total points
ID: 8119744
Best to put the drawing code inside the overridden paintComponent(Graphics g) of the JPanel.
0
 

Expert Comment

by:CleanupPing
ID: 9058742
ballahalla:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
 
LVL 35

Expert Comment

by:girionis
ID: 9714414
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

- Points to CEHJ

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

girionis
EE Cleanup Volunteer
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Suggested Courses
Course of the Month12 days, 17 hours left to enroll

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question