Just another update
This commit is contained in:
parent
a25938f123
commit
00a190b0a6
6591 changed files with 94363 additions and 23227 deletions
46
Task/Draw-a-cuboid/Java/draw-a-cuboid.java
Normal file
46
Task/Draw-a-cuboid/Java/draw-a-cuboid.java
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
import java.awt.*;
|
||||
import javax.swing.*;
|
||||
|
||||
public class Cuboid extends JFrame {
|
||||
|
||||
public static void main(String[] args) {
|
||||
JFrame f = new Cuboid();
|
||||
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
f.setVisible(true);
|
||||
}
|
||||
|
||||
public Cuboid() {
|
||||
Container content = getContentPane();
|
||||
content.setLayout(new BorderLayout());
|
||||
content.add(new CuboidPanel(), BorderLayout.CENTER);
|
||||
setTitle("Cuboid");
|
||||
setResizable(false);
|
||||
pack();
|
||||
setLocationRelativeTo(null);
|
||||
}
|
||||
}
|
||||
|
||||
class CuboidPanel extends JPanel {
|
||||
|
||||
public CuboidPanel() {
|
||||
setPreferredSize(new Dimension(600, 500));
|
||||
setBackground(Color.white);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paintComponent(Graphics gg) {
|
||||
super.paintComponent(gg);
|
||||
Graphics2D g = (Graphics2D) gg;
|
||||
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
||||
RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
|
||||
g.translate(165, -80);
|
||||
|
||||
g.drawRect(50, 275, 100, 100);
|
||||
g.drawLine(50, 275, 130, 240);
|
||||
g.drawLine(150, 275, 210, 240);
|
||||
g.drawLine(130, 240, 210, 240);
|
||||
g.drawLine(210, 240, 210, 340);
|
||||
g.drawLine(150, 375, 210, 340);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue