ציור ב- Java, אני די Noob - עמוד 3 - תכנות - HWzone פורומים
עבור לתוכן
  • צור חשבון

ציור ב- Java, אני די Noob


X_Dror

Recommended Posts

אתה יכול לעשות דבר כזה:





class SignPanel extends JPanel

{
Stock s;
public SignPanel(Stock sArg)
{
s = sArg;
}

public void paintComponent(Graphics comp)
{
.paintComponent(comp);
Graphics2D c=(Graphics2D) comp;
Point2D.Double[] p=new Point2D.Double[20];
c.setColor(Color.white);
c.fillRect(0, 0, 720, 640);
//Draws the drawing box
Color g=new Color(230,230,230);
c.setColor(g);
c.fillRect(60, 60, 600, 500);
//Draws the table
p[0]=new Point2D.Double(60,60);
p[1]=new Point2D.Double(660,560);
int count=2;
c.setColor(Color.black);
//Will draw horizontal lines
for (double i=60;i<=500;i=i+(500/5))
{
p[count]=new Point2D.Double(0,i);
c.drawLine(60, (int)i,660, (int)i);
}
//Will draw vertical lines
for (double i=60;i<=600;i=i+(600/3))
{
p[count]=new Point2D.Double(0,i);
c.drawLine((int)i, 60,(int)i,560 );
}
//will draw the graph


FontRenderContext frc = c.getFontRenderContext();
Font f = new Font("Helvetica",Font.BOLD, 48);
TextLayout tl = new TextLayout(s.toString(), f, frc);
Dimension theSize=getSize();
GradientPaint magentatogreen =new GradientPaint(100,0,Color.magenta,300, 0,Color.green);
c.setPaint(magentatogreen);
tl.draw(c, 40, 40);

}
}

קישור לתוכן
שתף באתרים אחרים

  • תגובות 30
  • נוצר
  • תגובה אחרונה

ארכיון

דיון זה הועבר לארכיון ולא ניתן להוסיף בו תגובות חדשות.


×
  • צור חדש...