+62 852-4056-7490 •

Artikel

Membuat Sketsa Mobil Dengan Java Applet

Rahman 3 Comments Maret 17, 2018
img

Assalamu'alaikum Warahmatullahi Wabarakatuh

Halo.. Apa kabar semuanya ?? Baik-baik saja kan

Oke. Pada tutorial kali ini saya ingin berbagi tentang Cara Membuat Sketsa Mobil dengan Java Applet. Gimana caranya ??
Berikut source codenya..

package tugasprakpbo_152375;
 
import java.applet.Applet;
import java.awt.*;


public class Tugas3_152375 extends Applet{
   
public void paint (Graphics g){

  //kerangka  
  g.setColor(Color.LIGHT_GRAY);
  int carx[] = {750,730,760,   750,765,710,600,200,    208,200,320,450,760};
  int cary[] = {150,155,175,   200,280,320,320,320,    290,240,200,120,140};
  int np = carx.length;   
  g.drawPolygon(carx, cary, np);     
 Polygon poly = new Polygon(carx, cary, np);  
 g.fillPolygon(poly);
 
 //bandepan
 g.setColor(Color.BLACK);
 g.fillOval(250, 270, 90,90);
 g.setColor(Color.BLUE);
 g.fillOval(262, 283, 65,65);
 g.setColor(Color.BLACK);
 g.fillOval(280, 300, 30,30);
//banbelakang
 g.setColor(Color.BLACK);
 g.fillOval(600, 270, 90,90);
 g.setColor(Color.BLUE);
 g.fillOval(613, 283, 65,65);
  g.setColor(Color.BLACK);
 g.fillOval(630, 300, 30,30);
   
 //hiasanbelakang
 g.setColor(Color.BLACK);
  int catx[] = {760,750,730,760,750,757,730,740,710};
  int caty[] = {140,150,155,175,200,240,250,180,150  };
  int t = catx.length;    
  g.drawPolygon(catx, caty, t);     
 Polygon yy = new Polygon(catx, caty, t);  
 g.fillPolygon(yy);
 
  //hiasandepan
 g.setColor(Color.BLACK);
  int lmpx[] = {215, 225, 215,    200,208,200};
  int lmpy[] = {235, 290, 320,    320,290,240 };
  int c = lmpx.length;    
  g.drawPolygon(lmpx, lmpy, c);     
 Polygon d = new Polygon(lmpx, lmpy, c);  
 g.fillPolygon(d);
 
 //lampudepan
 g.setColor(Color.RED);
  int plx[] = {280, 260,200, 200};
  int ply[] = {213, 230,250, 240  };
  int k = plx.length;    
  g.drawPolygon(plx, ply, k);     
 Polygon v = new Polygon(plx, ply, k);  
 g.fillPolygon(v);
 
 //hiasanbawah
 g.setColor(Color.BLACK);
  int htx[] = {560,580,350,370};
  int hty[] = {285,320,320,295};
  int a = htx.length;    
  g.drawPolygon(htx, hty, a);     
 Polygon b = new Polygon(htx, hty, a);  
 g.fillPolygon(b);
 
//lampubelakang
 g.setColor(Color.RED);
  int lamx[] = {750,757,730,737,750,750};
  int lamy[] = {200,240,250,200,200,200 };
  int n = lamx.length;    
  g.drawPolygon(lamx, lamy, n);     
 Polygon ss = new Polygon(lamx, lamy, n);  
 g.fillPolygon(ss);

 //garis1
 g.setColor(Color.BLACK);
 g.drawLine(670,280, 730, 250);
 //garis2
 g.drawLine(670,190, 715, 150);
 //garis3
 g.drawLine(670,190, 290, 210);
 //garis4
 g.drawLine(660,190,680 ,275 );
 //garis5
 g.drawLine(540,197,520 ,290 );
  //garis6
 g.drawLine(370,205,370,300 );
 
 //jendela2
 g.setColor(Color.BLACK);  
  int winx[] = {580,700,670,560};
  int winy[] = {136,150,180,190};
  int l = winx.length;   
g.drawPolygon(winx, winy, l);     
 Polygon ra = new Polygon(winx, winy, l);  
 g.fillPolygon(ra);
 
 //jendela   
 g.setColor(Color.BLACK);
  int jenx[] = {330,450,570,550};
  int jeny[] = {200,130,135,190};
  int p = jenx.length;   
  g.drawPolygon(carx, cary, p);     
 Polygon win = new Polygon(jenx, jeny, p);  
 g.fillPolygon(win);
 
 Font f;
 String teks = "Mobil = Fathur Rahman";
 f = new Font ("Rockwell Condensed", Font.BOLD, 40);
 g.setColor(Color.black);
 g.setFont(f);  
 g.drawString(teks, 250, 450);

}   
}

Dan inilah Hasilnya :

Semoga bermanfaat yah.. Sekian dan Terima Kasih

Wassalamu'alaikum Warahmatullahi Wabarakatuh

 


Tags:

3 Comments

reply

John Doe

June 29, 2014 - 11:23 Proin eget tortor risus. Cras ultricies ligula sed magna dictum porta. Pellentesque in ipsum id orci porta dapibus. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
reply

Diana Doe

June 29, 2014 - 11:23 Proin eget tortor risus. Cras ultricies ligula sed magna dictum porta. Pellentesque in ipsum id orci porta dapibus. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
reply

Melissa Doe

June 29, 2014 - 11:23 Proin eget tortor risus. Cras ultricies ligula sed magna dictum porta. Pellentesque in ipsum id orci porta dapibus. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Peter Doe

June 29, 2014 - 11:23 Proin eget tortor risus. Cras ultricies ligula sed magna dictum porta. Pellentesque in ipsum id orci porta dapibus. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Leave a reply Your email address will not be published.


Allowed HTML tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Inappropriate and irrelevant comments will be removed at an admin's discretion.
Your email is used for verification purposes only, it will never be shared.