help needed

Joined
Jun 15, 2009
Messages
1
Reaction score
0
i'm new to swing and java programming.the following code just gives an empty frame with nothing in it.can someone help me with where i'm going wrong.it shows no runtime or compile time errors

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

import java.awt.AlphaComposite;
import java.awt.Color;
import java.awt.Composite;
import java.awt.Container;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.geom.Rectangle2D;




class CDSframe
{
public static void main(String args[]) throws IOException{


JFrame myframe=new JFrame("CDSPLOT");
//cirarc1 c1=new cirarc1();
myframe.add(new cirarc1());
myframe.setLayout(new FlowLayout());
myframe.setSize(250,250);
myframe.setVisible(true);
myframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);



FileReader f1;
BufferedReader b1;
String t;

try{
f1=new FileReader(args[0]);
}
catch(FileNotFoundException e)
{ System.out.println("file not found");
return;
}

b1=new BufferedReader(f1);

while((t=b1.readLine())!=null)
{
//System.out.println(t);
String s1=" CDS ";
int num1=s1.length();
int num2=t.length();
for(int i=0;i<num2-num1;i++)
{//System.out.println(t.regionMatches(i,s1,0,num1));
if(t.regionMatches(i,s1,0,num1)==true) {
//System.out.println(t.regionMatches(i,s1,0,num1));
//System.out.println(t);

if (t == null) { System.out.println(" null"); }
StringBuffer strBuff = new StringBuffer();
char c;
for (int j = 0; j< t.length() ; j++)
{
c = t.charAt(j);
if (Character.isDigit(c) || c=='.')
{ strBuff.append(c);
//System.out.println(strBuff.append(c));
}

}
System.out.println(strBuff.toString());
String str=new String(strBuff.toString());
StringBuffer strbuff1=new StringBuffer();
for(int i1=0;i<str.length();i1++)//extracts the upper limit

{
char notdot=str.charAt(i1);

if(notdot!='.')
{
strbuff1.append(notdot);
}
else
break;
}
String r=new String(strbuff1);
System.out.println(strbuff1);
//int y=Integer.parseInt(r);
//System.out.println(y);


int pos=str.indexOf('.'); //extracts lower limit
String nextpart=str.substring(pos+2);
System.out.println(nextpart);




}//end of if
}//end of for

}//end of while







}//end of psvm
}//end of class

class cirarc1 extends JComponent

{

final double X_CENTER = 640 / 2;
final double Y_CENTER = 480 / 2;





public void paint(Graphics g)
{
Graphics2D g2=(Graphics2D)g;
float angle, numPix;
double radius = 200.0f;
int x, y;

/* number of pixels determines how much to increase angle for each pixel plotted */
numPix = 1000000;

//double angInc[]={4.507,3.598,2.0903,1.9870};
int circum=800;
double angInc[]=new double[4];
double angw;
int len[]=new int[800];
int lenw;
int xarr[]={1,15150,193500,3014000};
int yarr[]={13740,180200,3014000,3886000};
for(int i=0;i<xarr.length;i++)
{
len=yarr-xarr;


angInc = (float) ((2.0 * Math.PI /numPix)*len);
}

Color clr[]={Color.red,Color.blue,Color.green,Color.yellow};

// g.drawLine(X_CENTER, Y_CENTER, X_CENTER, Y_CENTER);
double startang=0.0;
for(int i=0;i<xarr.length;i++)
{
Arc2D.Double a=new Arc2D.Double();
a.setArcByCenter(X_CENTER,Y_CENTER,radius,startang,angInc,0);
g2.setColor(clr);
g2.draw(a);
startang=angInc;


if(i!=xarr.length-1)
{if(xarr[i+1]!=yarr)
{lenw=xarr[i+1]-yarr;
angw=(float)((2.0*Math.PI/numPix)*lenw);
g2.setColor(Color.white);
Arc2D.Double b=new Arc2D.Double();
b.setArcByCenter(X_CENTER,Y_CENTER,radius,startang,angw,0);
g2.draw(b);
startang=angw;


}
}






}//end for

}//end of paint














}//end of class



please help me
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top