Program ini menggunakan aplikasi JCreator, berikut listing programnya.
import java.awt.*;
import java.awt.geom.*;
import javax.swing.*;
class SolidPaintFill extends GrafikaKomputer
{
public static void main (String[] args)
{
SolidPaintFill g= new SolidPaintFill();
g.setTitle("Solid Paint Fill");
g.setBackground(Color.white);
g.setVisible(true);
}
public void paint(Graphics g)
{
Color[]colors=
{Color.red,
Color.pink,
Color.orange,
Color.yellow,
Color.green,
Color.cyan,
Color.magenta,
Color.blue};
Graphics2D g2= (Graphics2D) g;
float rw = (float)getBounds().getWidth()/colors.length;
float rh = (float)getBounds().getHeight();
Rectangle2D rect;
for (int i=0; i<colors.length; i++)
{
rect = new Rectangle2D.Float(rw*i,0,rw,rh);
g2.setPaint(colors[i]);
g2.fill(rect);
}
}
}
Output :
Semoga Bermanfaat.
import java.awt.*;
import java.awt.geom.*;
import javax.swing.*;
class SolidPaintFill extends GrafikaKomputer
{
public static void main (String[] args)
{
SolidPaintFill g= new SolidPaintFill();
g.setTitle("Solid Paint Fill");
g.setBackground(Color.white);
g.setVisible(true);
}
public void paint(Graphics g)
{
Color[]colors=
{Color.red,
Color.pink,
Color.orange,
Color.yellow,
Color.green,
Color.cyan,
Color.magenta,
Color.blue};
Graphics2D g2= (Graphics2D) g;
float rw = (float)getBounds().getWidth()/colors.length;
float rh = (float)getBounds().getHeight();
Rectangle2D rect;
for (int i=0; i<colors.length; i++)
{
rect = new Rectangle2D.Float(rw*i,0,rw,rh);
g2.setPaint(colors[i]);
g2.fill(rect);
}
}
}
Output :
Semoga Bermanfaat.
0 komentar:
Posting Komentar
Please Give Your Feedback Or Message.
Thank You!!?