So I am totally new to java, only had it in class for about two months or so, so I'm only familliar with basic terms etc. For a school assignment I have to create a java project. It involves making an oven I have to open/close with a checkbox and much more but i'm already stuck with this one. I already drew an oven with the graphics class but i dont know how to make it interact with the checkbox so i can open/close the oven door. Any help is appreciated!
so this is what i got so far (so just the oven I drew with lines and rectangles)
public class FornuisPanel extends javax.swing.JPanel {
/**
* Creates new form FornuisPanel
*/
public FornuisPanel() {
initComponents();
repaint();
}
public void paintComponent(Graphics g) {
super.paintComponent(g);
g.setColor (Color.PINK);
g.fillRect(100, 200, 200, 200); /* oven */
g.setColor (Color.black);
g.drawLine(100, 200, 150, 100);
g.drawLine(300, 200, 250, 100);
g.drawLine(150, 100, 250, 100);
g.drawRect (120, 220, 160, 160); /* oven door */
g.drawLine(180, 230, 220, 230); /* handle oven */
g.setColor(Color.gray);
g.fillOval(210, 110, 35, 30); /* hot plate up right */
g.fillOval(210, 145, 45, 40); /* hot plate bottom right */
g.fillOval(160, 110, 30, 25); /* hot plate up left */
g.fillOval(135, 145, 52, 47); /* hot plate bottom right */
}
Aucun commentaire:
Enregistrer un commentaire