Modify this code to draw a 3D cylinder, it needs a some manipulation to look like 3d
Question:
Modify this code to draw a 3D cylinder, it needs a some manipulation to look like 3d cylinder
import java.awt.BorderLayout;
import java.awt.GridLayout; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel;
import java.awt.*; import java.applet.*; import java.awt.*; public class Cylinder3D extends Applet {
public void paint(Graphics g) {
int x[]={100,100,140,140}; int y[]={100,160,160,100}; g.setColor(Color.black); g.fillPolygon(x,y,4);
int x1[]={60,60,100,100}; int y1[]={100,160,160,100}; g.setColor(Color.black); g.fillPolygon(x1,y1,4);
g.setColor(Color.gray); g.fillOval(74,100,50,50);
g.setColor(Color.gray); g.fillOval(124,100,50,50);
g.setColor(Color.black); g.drawLine(60,110,140,110);
g.setColor(Color.black); g.drawLine(60,150,140,150); }
public static void main(String[] args) { Cylinder3D c = new Cylinder3D(); JFrame f = new JFrame(); f.add(c); f.setSize(300, 300); f.setVisible(true); } }
Introduction To Materials Management
ISBN: 978-9386873248
8th edition
Authors: Arnold J. R. Tony, Gatewood Ann K., M. Clive Lloyd N. Chapman Stephen