Need help with pie chart code

I am new to Java and am having problems and I am in need of some help. I have written the code for my Mortgage Calculator but do not know how to get my chart to work. I found an example of the chart code in my text book but I am not sure if I wrote it wrong. When I run the MortCalc code it compiles but the Pie Chart code won't. I tried to run the chart code by itself but it prints out another calculator. My question is 1.) Is my chart code written wrong? and 2.) How do i enter it into my MortCalc code so that I get my chart?
**Below I have included the assignment(so you know what I am doing exactly) and below that the pie chart code just in case you have questions. Thanks for any advice you can give.
**If you need the rest of the code I can post it too. It was too long to post with the pie chart code.
Assignment:
Write the program in Java(w/ a GUI) and have it calculate and display the mortgage payment amount from user input of the amount of the mortgage adn the user's selection from a menu of availible mortgage loans:
--7 yrs @ 5.35%
--15 yrs @ 5.5%
--30 yrs @ 5.75%
Use an array for the mortgage data for the different loans. Read the interst rates to fill the array from a sequential file. Display the mortgage payment amount followed by the loan balance and interest paid for each payment over the term of the loan. Add graphics in the form of a chart.Allow the user to loop back and enter a new amount and make a new selection of quit. Please insert comments in the program to document the program.
CODE:
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Rectangle;
//Class to hold a value for a slice
public class PieValue {
double value;
Color color;
public PieValue(double value, Color color) {
this.value = value;
this.color = color;
// slices is an array of values that represent the size of each slice.
public void drawPie(Graphics2D g, Rectangle area, PieValue[] slices) {
// Get total value of all slices
double total = 0.0D;
for (int i=0; i<slices.length; i++) {
total += slices.value;
// Draw each pie slice
double curValue = 0.0D;
int startAngle = 0;
for (int i=0; i<slices.length; i++) {
// Compute the start and stop angles
startAngle = (int)(curValue * 360 / total);
int arcAngle = (int)(slices[i].value * 360 / total);
// Ensure that rounding errors do not leave a gap between the first and last slice
if (i == slices.length-1) {
arcAngle = 360 - startAngle;
// Set the color and draw a filled arc
g.setColor(slices[i].color);
g.fillArc(area.x, area.y, area.width, area.height, startAngle, arcAngle);
curValue += slices[i].value;

// Draw each pie slice
double curValue = 0.0D;
int startAngle = 0;
for (int i=0; i<slices.length; i+) {
// Compute the start and stop angles
startAngle = (int)(curValue 360 / total);
int arcAngle = (int)(slices.value * 360 / total);Look here and i think you will find some syntax errors.
Count the brackets.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

Similar Messages

  • Need Help with Pie Chart

    Hi guys,
    I am trying do generate a pie chart using JSP or Servlet. I tried out the codings at the www.builder.com site.
    But it's not working as it returns "index array out of bounds 0" error.
    Has anyone tried it before...
    Any help would be much appreciated
    the url for the site
    http://builder.com.com/5100-6370-1051766.html?tag=search

    The comple JSP code from the site is at :
    http://builder.com.com/5110-6370-1051781.html

  • Need help with a activation code for Adobe Acrobat X Standard for my PC,, Don't have older version serial numbers,  threw programs away,  only have Adobe Acrobat X Standard,  need a code to unlock program?

    Need help with a activation code for Adobe Acrobat X Standard for my PC, Don't have older Version of Adobe Acrobat 9, 8 or 7. 

    You don't need to install the older version, you only need the serial number from your original purchase. If you don't have them to hand, did you register? If so, they should be in your Adobe account. If not you really need to contact Adobe, though it isn't clear they will be able to do anything without some proof of purchase etc.

  • Need Help With Simple ABAP Code

    Hello,
    I'm loading data from a DSO (ZDTBMAJ) to an Infocube (ZCBRAD06). I need help with ABAP code to some of the logic in Start Routine. DSO has 2 fields: ZOCTDLINX & ZOCBRDMAJ.
    1. Need to populate ZOCPRODCD & ZOCREFNUM fields in Infocube:
        Logic:-
        Lookup /BI0/PMATERIAL, if /BIC/ZOCBRDMAJ = /BIC/OIZOCBRDMAJ
        then /BIC/ZOCPRODCD = ZOCPRODCD in Infocube
               /BIC/ZOCREFNUM = ZOCREFNUM in Infocube         
    2. Need to populate 0G_CWWTER field in Infocube:
        Logic:
        Lookup /BIC/PZOCTDLINX, if /BIC/ZOCTDLINX = BIC/OIZOCTDLINX
        then G_CWWTER = 0G_CWWTER in Infocube.
    I would need to read single row at a time.
    Thanks!

    I resolved it.

  • Need help with adjusting Javascript code to work in Adobe Edge (Countdown)

    Hello
    Im a newbie when it comes to working with Javascript and Adobe Edge and need a bit of help with adjusting some javascript code to work with Adobe Edge. A friend of mine helped me with making this javascript code: Edit fiddle - JSFiddle
    Its a simple countdown which counts down to a certain time at a certain date. What I aim to do is to add this code as a trigger on a text-element called "countdown" (within a symbol called "count").
    I have tried to do this as the code is, but it does not work. Anyone have any suggestions?
    Thanks!
    Mvh,
    Øyvind Hermans

    Hello again
    I have stumbled upon a problem with these animations; They crash the browser after viewing them a little while, usually less than 30 seconds in.
    Is this problem also occuring when you watch the animations?
    Is the countdown-code to much for the browsers to handle?
    Thanks in advance for your answers.
    Sincerely,
    Øyvind Hermans

  • Need help on Pie chart

    Please check the xml given here. My requirement is as
    group1 on M_KOG3_conc (split by page break)
    - group2 on MARKT_LINE_CONC
    - pie chart showing % of QTY_TIRE_SO_FTP with respect to S2_SEGMENT2(condition:S2_SEGMENT2 not null)
    - end of group2
    end of group1
    I tried with creating two groups on M_KOG3_CONC then by MARKT_LINE_CONC outside the chart, conditional region for S2_Segment2!='' and in pie chart used value=QTY_TIRE_SO_FTP and label=S2_SEGMENT2; checked 'Group Data' option, 'chart is inside group' option, but it is coming blank in preview.
    <?xml version="1.0" encoding="UTF-8" ?>
    <DataSet>
    <ROW>
    <M_KOG3_CONC>574: CHARTERWAY</M_KOG3_CONC>
    <MARKT_LINE_CONC>R02: CES - New Tire</MARKT_LINE_CONC>
    <S2_SEGMENT2>CP20: Corporate PKW</S2_SEGMENT2>
    <RIM_IN_INCH>15</RIM_IN_INCH>
    <QTY_TIRE_SO_FTP>2415</QTY_TIRE_SO_FTP>
    <SHARE_FITTED_TIRE>3.96226415094339622641509433962264150943E-01</SHARE_FITTED_TIRE>
    <POLICY_FITTMENT_FTP>1</POLICY_FITTMENT_FTP>
    </ROW>
    <ROW>
    <M_KOG3_CONC>574: CHARTERWAY</M_KOG3_CONC>
    <MARKT_LINE_CONC>R02: CES - New Tire</MARKT_LINE_CONC>
    <S2_SEGMENT2>CP20: Corporate PKW</S2_SEGMENT2>
    <RIM_IN_INCH>16</RIM_IN_INCH>
    <QTY_TIRE_SO_FTP>1442</QTY_TIRE_SO_FTP>
    <SHARE_FITTED_TIRE>2.36587366694011484823625922887612797375E-01</SHARE_FITTED_TIRE>
    <POLICY_FITTMENT_FTP>1</POLICY_FITTMENT_FTP>
    </ROW>
    <ROW>
    <M_KOG3_CONC>574: CHARTERWAY</M_KOG3_CONC>
    <MARKT_LINE_CONC>R02: CES - New Tire</MARKT_LINE_CONC>
    <S2_SEGMENT2>CP20: Corporate PKW</S2_SEGMENT2>
    <RIM_IN_INCH>17</RIM_IN_INCH>
    <QTY_TIRE_SO_FTP>10</QTY_TIRE_SO_FTP>
    <SHARE_FITTED_TIRE>1.64068908941755537325676784249384741592E-03</SHARE_FITTED_TIRE>
    <POLICY_FITTMENT_FTP>1</POLICY_FITTMENT_FTP>
    </ROW>
    <ROW>
    <M_KOG3_CONC>574: CHARTERWAY</M_KOG3_CONC>
    <MARKT_LINE_CONC>R02: CES - New Tire</MARKT_LINE_CONC>
    <S2_SEGMENT2>CP20: Corporate PKW</S2_SEGMENT2>
    <RIM_IN_INCH />
    <QTY_TIRE_SO_FTP>3867</QTY_TIRE_SO_FTP>
    <SHARE_FITTED_TIRE>6.34454470877768662838392124692370795734E-01</SHARE_FITTED_TIRE>
    <POLICY_FITTMENT_FTP>1</POLICY_FITTMENT_FTP>
    </ROW>
    <ROW>
    <M_KOG3_CONC>574: CHARTERWAY</M_KOG3_CONC>
    <MARKT_LINE_CONC>R02: CES - New Tire</MARKT_LINE_CONC>
    <S2_SEGMENT2>CP22: Competitor PKW</S2_SEGMENT2>
    <RIM_IN_INCH>15</RIM_IN_INCH>
    <QTY_TIRE_SO_FTP>576</QTY_TIRE_SO_FTP>
    <SHARE_FITTED_TIRE>9.45036915504511894995898277276456111567E-02</SHARE_FITTED_TIRE>
    <POLICY_FITTMENT_FTP>2.60416666666666666666666666666666666667E-02</POLICY_FITTMENT_FTP>
    </ROW>
    <ROW>
    <M_KOG3_CONC>574: CHARTERWAY</M_KOG3_CONC>
    <MARKT_LINE_CONC>R02: CES - New Tire</MARKT_LINE_CONC>
    <S2_SEGMENT2>CP22: Competitor PKW</S2_SEGMENT2>
    <RIM_IN_INCH>16</RIM_IN_INCH>
    <QTY_TIRE_SO_FTP>235</QTY_TIRE_SO_FTP>
    <SHARE_FITTED_TIRE>3.8556193601312551271534044298605414274E-02</SHARE_FITTED_TIRE>
    <POLICY_FITTMENT_FTP>1.82978723404255319148936170212765957447E-01</POLICY_FITTMENT_FTP>
    </ROW>
    <ROW>
    <M_KOG3_CONC>574: CHARTERWAY</M_KOG3_CONC>
    <MARKT_LINE_CONC>R02: CES - New Tire</MARKT_LINE_CONC>
    <S2_SEGMENT2>CP22: Competitor PKW</S2_SEGMENT2>
    <RIM_IN_INCH />
    <QTY_TIRE_SO_FTP>811</QTY_TIRE_SO_FTP>
    <SHARE_FITTED_TIRE>1.33059885151763740771123872026251025431E-01</SHARE_FITTED_TIRE>
    <POLICY_FITTMENT_FTP>7.15166461159062885326757090012330456227E-02</POLICY_FITTMENT_FTP>
    </ROW>
    <ROW>
    <M_KOG3_CONC>574: CHARTERWAY</M_KOG3_CONC>
    <MARKT_LINE_CONC>R02: CES - New Tire</MARKT_LINE_CONC>
    <S2_SEGMENT2>CT10: Corporate LKW</S2_SEGMENT2>
    <RIM_IN_INCH>17.5</RIM_IN_INCH>
    <QTY_TIRE_SO_FTP>327</QTY_TIRE_SO_FTP>
    <SHARE_FITTED_TIRE>5.36505332239540607054963084495488105004E-02</SHARE_FITTED_TIRE>
    <POLICY_FITTMENT_FTP>1</POLICY_FITTMENT_FTP>
    </ROW>
    <ROW>
    <M_KOG3_CONC>574: CHARTERWAY</M_KOG3_CONC>
    <MARKT_LINE_CONC>R02: CES - New Tire</MARKT_LINE_CONC>
    <S2_SEGMENT2>CT10: Corporate LKW</S2_SEGMENT2>
    <RIM_IN_INCH>19.5</RIM_IN_INCH>
    <QTY_TIRE_SO_FTP>350</QTY_TIRE_SO_FTP>
    <SHARE_FITTED_TIRE>5.7424118129614438063986874487284659557E-02</SHARE_FITTED_TIRE>
    <POLICY_FITTMENT_FTP>1</POLICY_FITTMENT_FTP>
    </ROW>
    <ROW>
    <M_KOG3_CONC>574: CHARTERWAY</M_KOG3_CONC>
    <MARKT_LINE_CONC>R02: CES - New Tire</MARKT_LINE_CONC>
    <S2_SEGMENT2>CT10: Corporate LKW</S2_SEGMENT2>
    <RIM_IN_INCH>20</RIM_IN_INCH>
    <QTY_TIRE_SO_FTP>6</QTY_TIRE_SO_FTP>
    <SHARE_FITTED_TIRE>9.84413453650533223954060705496308449549E-04</SHARE_FITTED_TIRE>
    <POLICY_FITTMENT_FTP>1</POLICY_FITTMENT_FTP>
    </ROW>
    <ROW>
    <M_KOG3_CONC>574: CHARTERWAY</M_KOG3_CONC>
    <MARKT_LINE_CONC>R02: CES - New Tire</MARKT_LINE_CONC>
    <S2_SEGMENT2>CT10: Corporate LKW</S2_SEGMENT2>
    <RIM_IN_INCH>22.5</RIM_IN_INCH>
    <QTY_TIRE_SO_FTP>480</QTY_TIRE_SO_FTP>
    <SHARE_FITTED_TIRE>7.87530762920426579163248564397046759639E-02</SHARE_FITTED_TIRE>
    <POLICY_FITTMENT_FTP>1</POLICY_FITTMENT_FTP>
    </ROW>
    <ROW>
    <M_KOG3_CONC>574: CHARTERWAY</M_KOG3_CONC>
    <MARKT_LINE_CONC>R02: CES - New Tire</MARKT_LINE_CONC>
    <S2_SEGMENT2>CT10: Corporate LKW</S2_SEGMENT2>
    <RIM_IN_INCH />
    <QTY_TIRE_SO_FTP>1163</QTY_TIRE_SO_FTP>
    <SHARE_FITTED_TIRE>1.90812141099261689909762100082034454471E-01</SHARE_FITTED_TIRE>
    <POLICY_FITTMENT_FTP>1</POLICY_FITTMENT_FTP>
    </ROW>
    <ROW>
    <M_KOG3_CONC>574: CHARTERWAY</M_KOG3_CONC>
    <MARKT_LINE_CONC>R02: CES - New Tire</MARKT_LINE_CONC>
    <S2_SEGMENT2>CT12: Competitor LKW</S2_SEGMENT2>
    <RIM_IN_INCH>16</RIM_IN_INCH>
    <QTY_TIRE_SO_FTP>39</QTY_TIRE_SO_FTP>
    <SHARE_FITTED_TIRE>6.39868744872846595570139458572600492207E-03</SHARE_FITTED_TIRE>
    <POLICY_FITTMENT_FTP>0</POLICY_FITTMENT_FTP>
    </ROW>
    <ROW>
    <M_KOG3_CONC>574: CHARTERWAY</M_KOG3_CONC>
    <MARKT_LINE_CONC>R02: CES - New Tire</MARKT_LINE_CONC>
    <S2_SEGMENT2>CT12: Competitor LKW</S2_SEGMENT2>
    <RIM_IN_INCH>17</RIM_IN_INCH>
    <QTY_TIRE_SO_FTP>2</QTY_TIRE_SO_FTP>
    <SHARE_FITTED_TIRE>3.28137817883511074651353568498769483183E-04</SHARE_FITTED_TIRE>
    <POLICY_FITTMENT_FTP>0</POLICY_FITTMENT_FTP>
    </ROW>
    <ROW>
    <M_KOG3_CONC>574: CHARTERWAY</M_KOG3_CONC>
    <MARKT_LINE_CONC>R02: CES - New Tire</MARKT_LINE_CONC>
    <S2_SEGMENT2>CT12: Competitor LKW</S2_SEGMENT2>
    <RIM_IN_INCH>17.5</RIM_IN_INCH>
    <QTY_TIRE_SO_FTP>54</QTY_TIRE_SO_FTP>
    <SHARE_FITTED_TIRE>8.85972108285479901558654634946677604594E-03</SHARE_FITTED_TIRE>
    <POLICY_FITTMENT_FTP>3.7037037037037037037037037037037037037E-02</POLICY_FITTMENT_FTP>
    </ROW>
    <ROW>
    <M_KOG3_CONC>574: CHARTERWAY</M_KOG3_CONC>
    <MARKT_LINE_CONC>R02: CES - New Tire</MARKT_LINE_CONC>
    <S2_SEGMENT2>CT12: Competitor LKW</S2_SEGMENT2>
    <RIM_IN_INCH>19.5</RIM_IN_INCH>
    <QTY_TIRE_SO_FTP>20</QTY_TIRE_SO_FTP>
    <SHARE_FITTED_TIRE>3.28137817883511074651353568498769483183E-03</SHARE_FITTED_TIRE>
    <POLICY_FITTMENT_FTP>0</POLICY_FITTMENT_FTP>
    </ROW>
    <ROW>
    <M_KOG3_CONC>574: CHARTERWAY</M_KOG3_CONC>
    <MARKT_LINE_CONC>R02: CES - New Tire</MARKT_LINE_CONC>
    <S2_SEGMENT2>CT12: Competitor LKW</S2_SEGMENT2>
    <RIM_IN_INCH>22.5</RIM_IN_INCH>
    <QTY_TIRE_SO_FTP>58</QTY_TIRE_SO_FTP>
    <SHARE_FITTED_TIRE>9.51599671862182116488925348646431501231E-03</SHARE_FITTED_TIRE>
    <POLICY_FITTMENT_FTP>0</POLICY_FITTMENT_FTP>
    </ROW>
    <ROW>
    <M_KOG3_CONC>574: CHARTERWAY</M_KOG3_CONC>
    <MARKT_LINE_CONC>R02: CES - New Tire</MARKT_LINE_CONC>
    <S2_SEGMENT2>CT12: Competitor LKW</S2_SEGMENT2>
    <RIM_IN_INCH />
    <QTY_TIRE_SO_FTP>173</QTY_TIRE_SO_FTP>
    <SHARE_FITTED_TIRE>2.83839212469237079573420836751435602953E-02</SHARE_FITTED_TIRE>
    <POLICY_FITTMENT_FTP>1.15606936416184971098265895953757225434E-02</POLICY_FITTMENT_FTP>
    </ROW>
    <ROW>
    <M_KOG3_CONC>574: CHARTERWAY</M_KOG3_CONC>
    <MARKT_LINE_CONC>R02: CES - New Tire</MARKT_LINE_CONC>
    <S2_SEGMENT2 />
    <RIM_IN_INCH />
    <QTY_TIRE_SO_FTP>6014</QTY_TIRE_SO_FTP>
    <SHARE_FITTED_TIRE>9.86710418375717801476620180475799835931E-01</SHARE_FITTED_TIRE>
    <POLICY_FITTMENT_FTP>8.46358496840705021616228799467908214167E-01</POLICY_FITTMENT_FTP>
    </ROW>
    <ROW>
    <M_KOG3_CONC>574: CHARTERWAY</M_KOG3_CONC>
    <MARKT_LINE_CONC>R03: CES - Retreads</MARKT_LINE_CONC>
    <S2_SEGMENT2>CT11: Corporate RE LKW</S2_SEGMENT2>
    <RIM_IN_INCH>22.5</RIM_IN_INCH>
    <QTY_TIRE_SO_FTP>13</QTY_TIRE_SO_FTP>
    <SHARE_FITTED_TIRE>2.13289581624282198523379819524200164069E-03</SHARE_FITTED_TIRE>
    <POLICY_FITTMENT_FTP>1</POLICY_FITTMENT_FTP>
    </ROW>
    <ROW>
    <M_KOG3_CONC>574: CHARTERWAY</M_KOG3_CONC>
    <MARKT_LINE_CONC>R03: CES - Retreads</MARKT_LINE_CONC>
    <S2_SEGMENT2>CT11: Corporate RE LKW</S2_SEGMENT2>
    <RIM_IN_INCH />
    <QTY_TIRE_SO_FTP>13</QTY_TIRE_SO_FTP>
    <SHARE_FITTED_TIRE>2.13289581624282198523379819524200164069E-03</SHARE_FITTED_TIRE>
    <POLICY_FITTMENT_FTP>1</POLICY_FITTMENT_FTP>
    </ROW>
    <ROW>
    <M_KOG3_CONC>574: CHARTERWAY</M_KOG3_CONC>
    <MARKT_LINE_CONC>R03: CES - Retreads</MARKT_LINE_CONC>
    <S2_SEGMENT2>CT13: Competitor RE LKW</S2_SEGMENT2>
    <RIM_IN_INCH>17.5</RIM_IN_INCH>
    <QTY_TIRE_SO_FTP>29</QTY_TIRE_SO_FTP>
    <SHARE_FITTED_TIRE>4.75799835931091058244462674323215750615E-03</SHARE_FITTED_TIRE>
    <POLICY_FITTMENT_FTP>0</POLICY_FITTMENT_FTP>
    </ROW>
    <ROW>
    <M_KOG3_CONC>574: CHARTERWAY</M_KOG3_CONC>
    <MARKT_LINE_CONC>R03: CES - Retreads</MARKT_LINE_CONC>
    <S2_SEGMENT2>CT13: Competitor RE LKW</S2_SEGMENT2>
    <RIM_IN_INCH>19.5</RIM_IN_INCH>
    <QTY_TIRE_SO_FTP>18</QTY_TIRE_SO_FTP>
    <SHARE_FITTED_TIRE>2.95324036095159967186218211648892534865E-03</SHARE_FITTED_TIRE>
    <POLICY_FITTMENT_FTP>0</POLICY_FITTMENT_FTP>
    </ROW>
    <ROW>
    <M_KOG3_CONC>574: CHARTERWAY</M_KOG3_CONC>
    <MARKT_LINE_CONC>R03: CES - Retreads</MARKT_LINE_CONC>
    <S2_SEGMENT2>CT13: Competitor RE LKW</S2_SEGMENT2>
    <RIM_IN_INCH>22.5</RIM_IN_INCH>
    <QTY_TIRE_SO_FTP>21</QTY_TIRE_SO_FTP>
    <SHARE_FITTED_TIRE>3.44544708777686628383921246923707957342E-03</SHARE_FITTED_TIRE>
    <POLICY_FITTMENT_FTP>0</POLICY_FITTMENT_FTP>
    </ROW>
    <ROW>
    <M_KOG3_CONC>574: CHARTERWAY</M_KOG3_CONC>
    <MARKT_LINE_CONC>R03: CES - Retreads</MARKT_LINE_CONC>
    <S2_SEGMENT2>CT13: Competitor RE LKW</S2_SEGMENT2>
    <RIM_IN_INCH />
    <QTY_TIRE_SO_FTP>68</QTY_TIRE_SO_FTP>
    <SHARE_FITTED_TIRE>1.11566858080393765381460213289581624282E-02</SHARE_FITTED_TIRE>
    <POLICY_FITTMENT_FTP>0</POLICY_FITTMENT_FTP>
    </ROW>
    <ROW>
    <M_KOG3_CONC>574: CHARTERWAY</M_KOG3_CONC>
    <MARKT_LINE_CONC>R03: CES - Retreads</MARKT_LINE_CONC>
    <S2_SEGMENT2 />
    <RIM_IN_INCH />
    <QTY_TIRE_SO_FTP>81</QTY_TIRE_SO_FTP>
    <SHARE_FITTED_TIRE>1.32895816242821985233798195242001640689E-02</SHARE_FITTED_TIRE>
    <POLICY_FITTMENT_FTP>1.60493827160493827160493827160493827161E-01</POLICY_FITTMENT_FTP>
    </ROW>
    <ROW>
    <M_KOG3_CONC>574: CHARTERWAY</M_KOG3_CONC>
    <MARKT_LINE_CONC />
    <S2_SEGMENT2 />
    <RIM_IN_INCH />
    <QTY_TIRE_SO_FTP>6095</QTY_TIRE_SO_FTP>
    <SHARE_FITTED_TIRE>1</SHARE_FITTED_TIRE>
    <POLICY_FITTMENT_FTP>8.37243642329778506972928630024610336341E-01</POLICY_FITTMENT_FTP>
    </ROW>
    </DataSet>
    Please tell me the steps if it is possible through wizard or give me the xsl if wizard is not sufficient.
    Kind Regards.

    Found this by searching for PieChart in this forum: drawing pie charts.

  • I need help with some simple code! Please read!

    hi everyone.
    I'm having problems with a piece of code, and i'd be extremely greatful if somebody could give me a hand with it. I'm totally new to java and have to make a program for my university degree, but i'm finding it extremely difficult, mainly due to my total lack of apptitude for this type of thing. I know this is easy stuff, but the books I have are no use so any help would be greatly appreciated.
    I have to write a program which uses two class files. I want one with the code to produce a simple button, and one to invoke it several times at different locations. I decided to write the program as one class file at first, and thought i'd be able to split it up at later. The program works fine when it is one class file. My book said that to split the two classes up, all i needed to do was change the second class to public, although this seems to not work at all. I'm at my wits end on this, and if anyone could correct my code I'd be eternally greatful.
    Here is the first class... (sorry about the lack of indentation)
    >>>>>>>>>>
    import java.awt.*;
    import java.applet.Applet;
    public class Phone extends Applet {
    private Image image;
    public void init() {
    setLayout(null);
    image = getImage(getDocumentBase(), "phone.jpg");}
    public void paint (Graphics g) {
    g.drawImage(image, 0, 0, 700, 530, this);
    PhoneButton myButton;
    myButton = new PhoneButton(20,20);
    >>>>>>>
    This is the second class....
    >>>>>>>
    public class PhoneButton {
    private Button butt;
    public PhoneButton(int a, int b, int c){
    setLayout(null);
    butt = new Button();
    butt.setBounds(a,b,20,20);
    add(butt);
    >>>>>>>>
    My compiler generates errors relating to Button, but i can't do anything to please it.
    Also, could anyone give me some pointers on how to add a different number or symbol to each button. That is what I added int c for, but i couldn't get it to work.
    Cheers in advance.
    Michael Morgan

    I found that there are 5 error in your code.
    1. You should import the "java.awt" package to the PhoneButton.java
    2. The PhoneButton is not a kind of Component. You cannot not add it to the Phone class
    3. the myButton = new PhoneButton(20, 20) does not provide enough parameters to create PhoneButton
    4. You cannot add a Button to a PhoneButton. Becaue the PhoneButton is not a kind of Container
    Fixed code:
    import java.awt.*;
    public class PhoneButton extends Button {
    public PhoneButton(int a, int b, int c){
         setBounds(a, b, 20, 20);
         setLabel(String.valueOf(c));
    ===========================================
    import java.awt.*;
    import java.applet.Applet;
    public class Phone extends Applet {
    private Image image;
    public void init() {
    setLayout(null);
    image = getImage(getDocumentBase(), "phone.jpg");}
    public void paint (Graphics g) {
    g.drawImage(image, 0, 0, 700, 530, this);
    PhoneButton myButton;
    myButton = new PhoneButton(20,20, 1);
    ======================
    Visual Paradigm for UML - Full Features UML CASE tool
    http://www.visual-paradigm.com/

  • Need help with my batch code, cant seem to figure out the errors.

    Hello all, so as part of my job I have to check a list of shared drives on random servers throughout the world to make sure they are not open. I am trying to make a batch file to check them all at once instead of mapping to each one individually. It would
    save a lot of time. So far I got this code with the help of a member of
    reddit:
    @echo off
    :: Ensure Extensions are enabled to avoid silent failure
    setlocal EnableExtensions DisableDelayedExpansion
    set "Input-Server-List=H:\Desktop\serverlist.txt"
    set "Open-Share-List=H:\Desktop\open_shares.txt"
    set "Locked-Share-List=H:\Desktop\locked_shares.txt"
    :: Create empty files
    copy nul "%Open-Share-List%" 1>nul
    copy nul "%Locked-Share-List%" 1>nul
    :: Test the shares to see if they're online or not
    for /f "usebackq delims=" %%S in ("%Input-Server-List%") do @(
    pushd "%%~S" 2>nul && (
    popd
    1>> "%Open-Share-List%" echo %%~S
    echo ONLINE -- %%S
    ) || (
    1>> "%Locked-Share-List%" echo %%~S
    echo OFFLINE - %%S
    echo Testing Complete! Results have been logged to File.
    :: Open files in default program (typically notepad.exe)
    explorer "%Open-Share-List%"
    explorer "%Locked-Share-List%"
    :: End of script
    endlocal
    timeout -1 /nobreak
    exit /b
    But there are a few (approx 4) servers that are coming up as online/accessible in the list that are actually closed/appropriately locked down. I have no idea why.. all the rest are working as they should. Any help would be much appreciated. Any questions
    let me know. Once again, I would really really appreciate some help.

    Here's a tester:
    Get-Content .\shareList.txt | ForEach {
    $share = $_
    If (Test-Path -Path $share) {
    $found = $true
    } Else {
    $found = $false
    try {
    $null = Get-ChildItem -Path $share -ErrorAction Stop
    $connect = $true
    } catch {
    $connect = $false
    $props = @{
    Share = $share
    Found = $found
    Connect = $connect
    New-Object PsObject -Property $props
    } | Select Share,Found,Connect |
    Sort Connect,Share |
    Export-Csv .\shareListCheck.csv -NoTypeInformation
    As the others have pointed out though, this won't really give you any solid information.
    Don't retire TechNet! -
    (Don't give up yet - 13,085+ strong and growing)

  • Needed help with updating java code

    Hello all,
    Let me begin by let you know I am not a programmer and I have tried to solve this by reading on the net. I am a network admin so I tech knowledge but no programming.
    I have a webcam sending a Jpg to an FTP site and there I have used an applet called view.class to refresh once a second.
    site:http://70.154.170.253/webcamold.html
    My problems is now that it refreshes the same image over and over. It refreshes the cached image not the new image.
    From reading I suspect that it has to do with the newer version of java (it used to work fine).
    I have tried using JavaCam but same issue it just refreshes cached image. Also image flickers, the applet I am trying to fix was really smooth.
    I have also tried to compile code that I found on this forum but I got error dealing with deprecated code.
    Any help would be greatly appreciated!!!
    Code:
    import java.applet.Applet;
    import java.awt.*;
    import java.io.PrintStream;
    public class View extends Applet
    implements Runnable
    public void init()
    setBackground(Color.white);
    String s = getParameter("refresh");
    if(s == null)
    update = 30;
    else
    try
    update = Integer.parseInt(s);
    catch(Exception _ex)
    update = 30;
    filename = getParameter("picture");
    if(filename == null)
    System.out.println("No filename given as parameter.");
    md = new MediaTracker(this);
    off = createImage(size().width, size().height);
    refreshImage();
    public void paint(Graphics g)
    g.drawImage(off, 0, 0, this);
    public void update(Graphics g)
    paint(g);
    public void refreshImage()
    img = getImage(getDocumentBase(), filename);
    md.addImage(img, 0);
    try
    md.waitForID(0);
    catch(Exception exception)
    exception.printStackTrace();
    Graphics g = off.getGraphics();
    g.drawImage(img, 0, 0, this);
    img.flush();
    public void run()
    while(th != null)
    try
    refreshImage();
    repaint();
    Thread.sleep(update * 1000);
    catch(Exception exception)
    System.out.println("Error when thread was supposed to sleep: " + exception.getMessage());
    public void start()
    if(th == null)
    th = new Thread(this);
    try
    th.start();
    return;
    catch(Exception exception)
    System.out.println("Couldn't start thread: " + exception.getMessage());
    return;
    } else
    return;
    public void stop()
    if(th != null)
    th.stop();
    th = null;
    public void destroy()
    stop();
    public View()
    update = 30;
    Thread th;
    String filename;
    int update;
    Image img;
    Image off;
    MediaTracker md;

    This is compile error free code and regarding your issues i don't think am good at this stuff
    import java.applet.Applet;
    import java.awt.Color;
    import java.awt.Graphics;
    import java.awt.Image;
    import java.awt.MediaTracker;
    public class View extends Applet implements Runnable {
         Thread th;
         String filename;
         int update;
         Image img;
         Image off;
         MediaTracker md;
         public void init() {
              setBackground(Color.white);
              String s = getParameter("refresh");
              if (s == null) {
                   update = 30;
              } else {
                   try {
                        update = Integer.parseInt(s);
                   } catch (Exception _ex) {
                        update = 30;
              filename = getParameter("picture");
              if (filename == null) {
                   System.out.println("No filename given as parameter.");
              md = new MediaTracker(this);
              off = createImage(size().width, size().height);
              refreshImage();
         public void paint(Graphics g) {
              g.drawImage(off, 0, 0, this);
         public void update(Graphics g) {
              paint(g);
         public void refreshImage() {
              img = getImage(getDocumentBase(), filename);
              md.addImage(img, 0);
              try {
                   md.waitForID(0);
              } catch (Exception exception) {
                   exception.printStackTrace();
              Graphics g = off.getGraphics();
              g.drawImage(img, 0, 0, this);
              img.flush();
         public void run() {
              while (th != null) {
                   try {
                        refreshImage();
                        repaint();
                        Thread.sleep(update * 1000);
                   } catch (Exception exception) {
                        System.out.println("Error when thread was supposed to sleep: "
                                  + exception.getMessage());
         public void start() {
              if (th == null) {
                   th = new Thread(this);
                   try {
                        th.start();
                        return;
                   } catch (Exception exception) {
                        System.out.println("Couldn't start thread: "
                                  + exception.getMessage());
                   return;
              } else {
                   return;
         public void stop() {
              if (th != null) {
                   th.stop();
                   th = null;
         public void destroy() {
              stop();
         public View() {
              update = 30;
    }

  • Need help with graph/chart

    Heey everyone,
    I am currently using a Spider8 and Labview to gain data from sensors, after that i use Labview to process the data to charts or graphs. Alltough I have 2 small problems using a chart/graph:
    1: For some charts/graphs i want to use 1 Y-axis (example: volts or current) and 1 X-axis, time. I want this time to be like a clock which only counts seconds (example: 0-100sec), using absolute or relative time for formatting is not an option because they count way too much/fast. There is an example of these kind of charts/graphs in the appendix: currents vs time measurement.
    2: For most of the other charts/graphs i want to use several Y-axis (example for a motor: current, RPM and torque) and i want to use a X-axis which can go "back" (example for a motor: rotations). There is an example of these kind of charts/graphs in the appendix: Torque measurement.
    I dont have any idea of how to do this the right way, so your help is very welcome
    Thanks!
    Currently using labview 8.2.1
    Solved!
    Go to Solution.
    Attachments:
    Current-vs-time measurement.JPG ‏63 KB
    Torque measurement.JPG ‏136 KB

    Could anyone help me please? I have used the XY-graph for both graphs i wanted to make and they work. The point is I want to use an XY-graph (with several Y-axis) so i can plot in several different signals. For example we have 2 signals for the XY-graph: one is going from -10 to +10 and the other from -150 to +150 but i`ve created a graph which has 2 Y-axis (one from -20 to +20 for signal 1, one from -200 to +200 for signal 2). Well how am I able to say that signal 1 is for y-axis 1 and signal 2 is for Y-axis 2. I have tried to use a "merge signals" to merge signal 1 and 2 for the Y-axis but this doesn`t really work, it only shows me 1 of the 2 signals for Y-axis 1 depending which one is on top in the merge signals block. PS: I have posted the vi which im testing this problem with in the appendix.
    If anyone knows how to solve this problem, please help me !
    Currently using labview 8.2.1
    Attachments:
    XYgraph-test.vi ‏197 KB

  • Need help with "pie" graphic

    Hi, I'm trying to create a background that has a circular pie kind of effect that's popular these days where each slice of the pie is a slightly different color to create a cool background. This isn't the greatest example but check the red and dark red sun ray effect here ...
    http://gainesvillesuzuki.com/images/ad_one.jpg
    My question is, what is the easiest way to create this in illustrator?? I've been creating one slice with the pen tool, copying it while I rotate it with the rotate tool after I change the rotate axis to the middle , but doing that like 30-40 times gets really tedious, plus the pie slices never fit exactly together at the end (because the slices aren't divisions of 360).
    If anyone knows a better way I'm all ears, thanks!

    This kind of pie graph is easy. Double-click on the graph tool and select the pie graph. Drag a square. Then enter as many digits as you need (always the same digit) in the top line of the data spreadsheet. Use the right arrow key to hop between boxes. You will need to fill in as many boxes as you need slices in the pie graph.
    When you are satisfied with the number of slices, copy/drag the graph and ungroup it. Now you can colour the slices as you wish.
    It's a good idea to keep the original grouped graph in case you need to add slices in the data spreadsheet.

  • Need help with image charts from query wizard

    When I try to make an image chart all I get is a broken pic. I am running Windows NT so its not a unix problem. I did however find this error in my jserv.log when I tried to display the chart.Can anyone tell me what it means?
    [09/05/2001 08:45:12:187 PDT] java.io.FileNotFoundException: http://national/pls/portal30/PORTAL30.CHART_0509084315.show?p_format=XML
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:528)
    at oracle.webdb.chart.ChartServlet.doGet(ChartServlet.java:36)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:499)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:588)
    at org.apache.jserv.JServConnection.processRequest(JServConnection.java, Compiled Code)
    at org.apache.jserv.JServConnection.run(JServConnection.java, Compiled Code)
    at java.lang.Thread.run(Thread.java:479)
    null

    Thanks for the link! I'm able to do a File Select via JFileChooser and display the image onto a JLabel using the ImageIcon method (many thanks for that!). Currently, this is what I have (ImageFilter() extends FileFilter):
         ImageIcon photoIcon;
         JLabel photoLabel = new JLabel();
         JFileChooser fc = new JFileChooser();
         <snip>
         private JPanel DPCtr()
              <snip>
              photoIcon = new ImageIcon("default.jpg");
              photoLabel.setIcon(photoIcon);
              photoLabel.setPreferredSize(new Dimension(150, 150));
              <snip>
              return p;
         <snip>
         public void actionPerformed(ActionEvent a)
              if (a.getSource() == browseBut) {
                   fc.setFileFilter(new ImageFilter());
                   int returnVal = fc.showOpenDialog(DiseasePane.this);
                   if (returnVal == JFileChooser.APPROVE_OPTION) {
                        File imgFile = fc.getSelectedFile();
                        try {
                             photoIcon = new ImageIcon(imgFile.toURL());
                        } catch (MalformedURLException e) {
                             System.err.println("Invalid URL");
                        photoLabel.setIcon(photoIcon);
         }

  • Need help with powerpoint charts

    i can't get started in building a chart.  it tells me to close a dialog box but there are none open.  can anyone help?

    Are you using Keynote to convert a PowerPoint file to keynote, or are you using the Powerpoint application?
    Please clarify this and supply details of OS and application versions.

  • Need help with the following code (Want an input popup with numeric pad)

    Hello,
    I put the following code in an event :
    import javax.swing.JOptionPane;
    value = javax.swing.JOptionPane.showInputDialog("Price", "");
    try {
    Double newPrice = new Double(value);
    line.setPriceTax(newPrice);
    } catch (NumberFormatException e) {
    JOptionPane.showMessageDialog(null, "Not valid number: " + value, "Error", JOptionPane.PLAIN_MESSAGE);
    But this only gives an input popup screen and then i have to use a keyboard instead of my touchscreen to give the input,
    i would rather like it to be a popup input screen with a numeric pad attached.
    Is this possible, and how??
    Thanks in advance.
    Jeroen

    hii,
    set321go wrote
    make your own. Create a custom OptionPane and add --->
    // global def.
    private final JLabel amountLabel = new JLabel(" Input Trades Amount : ");
    private JFormattedTextField amountTextField;
    private double amount = 0.00;
    private NumberFormat amountFormat;
    // in panel class add --->
    amountFormat = NumberFormat.getNumberInstance();
    amountFormat.setMinimumFractionDigits(2);
    amountFormat.setMaximumFractionDigits(2);
    amountFormat.setRoundingMode(RoundingMode.HALF_EVEN);
    amountLabel.setFont(new Font("Serif", Font.BOLD, 16));
    amountLabel.setForeground(KopikSalesTest.textColor);
    amounTextField = new JFormattedTextField(amountFormat);
    amountTextField.setValue(0.00);
    amountTextField.setFont(new Font("Serif", Font.BOLD, 20));
    amountTextField.setForeground(Color.someColor);
    amountTextField.setBackground(Color.someColor);
    amountTextField.addFocusListener(new FocusListener() {
                public void focusGained(FocusEvent e) {
                    amountTextField.requestFocus();
                    amountTextField.setText(amountTextField.getText());
                    amountTextField.selectAll();
                public void focusLost(FocusEvent e) {
                    //on exit
    somePanel.add(amountLabel);
    somePanel.add(amountTextField); ... kopik

  • Need help with a Chart

    Hi, I apologize if this is the wrong area to enter this question but I really need to find a solution.  Please let me know where I should be posting this if it is in the wrong location.  I have a report that has a bar chart that will show me gps usage data for all vehicles in megs.   I have a formula called buckets that looks like this:
    if {@megs} < .10 then "0.00 to 0.10" else
    if {@megs} < .50 then "0.11 to 0.50" else
    if {@megs} < .69 then "0.51 to 0.69" else
    if {@megs} < .99 then "0.70 to 0.99" else
    if {@megs} < 1.5 then "1.0 to 1.5" else
    if {@megs} < 2.0 then "1.6 to 2.0" else
    if {@megs} < 3.0 then "2.1 to 3.0" else
    if {@megs} < 5.0 then "3.1 to 5.0";
    I also have a count of all vehicles called {@assetcount}
    I want the chart to show all the buckets regardless if there is data for them or not.  That way the bars will be in the same location for every one of my accounts.  Is this possible because currently I only get the buckets that have data.  I hope that makes sense.  Thanks.

    Hi Tammy
    I have tried creating a similar report where I didn't had any data for a country. When I create a achrt on it it shows me the bars for all the countries(also for the countries that dont have data).
    Please let me know what values are you grouping on and also let me know whats all fields and formulas have you selected in the chart expert.Are you using the defined formula to be displayed on the chart?
    Thanks
    Pradeep Hulke

Maybe you are looking for

  • Accounting documents not getting automatically cleared.

    Dear Experts, User posted the sales Billing invoice and delivered the order...later on he cancelled the Billing invoice in VF11 then it generated reversed billing document and accounting entry. But the system still shows billing entry and reverse ent

  • How to update Adobe ExportPDF to Acrobat XI pro?

    I have an Adobe ExportPDF licence and would like to upgrade it to Acrobat XI pro. How to proceed?

  • Integration with JMS queue from BizTalk 2013R2

    Hi All, We are planning to integrate biztalk application with Oracle Siebel CRM (8.1.1.11). they wanted to use JMS queue to receive xml message from BizTalk2013R2 and also send message to BizTalk for more reliability. IS there any out of box adapter

  • How do I add an Audio Book that I have...

    How do I add an Audio Book that I have thats in the correct format to iTunes.My Audio Book Playlist is not there in iTunes,My iPod shows that Audio Books is there,but not in iTunes?..Thanks for any help..:)

  • Opening MS attachments in Mail with Parallels installed

    Here's the situation that's happening with a friend that I need some help with. She's running OS X Leopard and Windows XP with Parallels. She has MS Office for both platforms. She uses Mail in OS X as her email application. When she receives attachme