Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8579825
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:41:38+00:00 2026-06-11T20:41:38+00:00

Alright the deal is I am trying to use the drawPie method to create

  • 0

Alright the deal is I am trying to use the drawPie method to create my pie chart in an applet. After attempting google searches I find multiple tutorials that explain part of the process but not all of it. While trying to knit together partial information I am not getting the results I want.

    import java.awt.Color;
    import java.awt.Graphics;
    import java.awt.Graphics2D;

    import javax.swing.JApplet;
    import javax.swing.JComponent;

public class JLW_PieApplet extends JApplet {

class PieData extends JComponent {
    PieValue[] slices = new PieValue[4];

    PieData() {
        slices[0] = new PieValue(35, Color.red);
        slices[1] = new PieValue(33, Color.green);
        slices[2] = new PieValue(20, Color.pink);
        slices[3] = new PieValue(12, Color.blue);

    }

    public void paint(Graphics g) {
        drawPie((Graphics2D)g, getBounds(), slices);
    }
}

}

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T20:41:39+00:00Added an answer on June 11, 2026 at 8:41 pm

    You have a PieData component within your applet but you never add it, so you need to add it in init and bring in drawPie from your link above:

    public class JLW_PieApplet extends JApplet {
    
       public void init() {
          add(new PieData());
       }
    
       class PieData extends JComponent {
          PieValue[] slices = new PieValue[4];
    
          PieData() {
             slices[0] = ...
          }
    
          @Override
          protected void paintComponent(Graphics g) {
             super.paintComponent(g);
             drawPie((Graphics2D) g, getBounds(), slices);
          }
    
          public void drawPie(Graphics2D g, Rectangle area, PieValue[] slices) {
          ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Alright, here's what I'm trying to do. I'm attempting to write a quick build
I'm attempting to create a database application for a bookstore. In the spec: After
Alright, so here's the deal. I would like to be able to create a
Alright so here is the deal. I am trying to make a application that's
Alright, this one's got me seriously stumped, after trying things out for hours with
Alright, I'm trying to use the basic document.getElementsByTagName function, but each time I do,
Alright so I have been looking around (on SO and Google) to see if
Alright, here I am again trying to write code from scratch and I can't
Alright, well this is the deal. I have a page, and then it loads
Alright y'all. I am attempting to write a bit of code that places typographic

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.