Proiect Semestrial La Disciplina Programare Vizuala in Java
Proiect Semestrial La Disciplina Programare Vizuala in Java
LA DISCIPLINA
PROGRAMARE VIZUALA IN JAVA
@SuppressWarnings("serial") &
public class AlegeCuloarea extends JFrame { &
JPanel panel; &
Color bgColor = Color.LIGHT_GRAY; // culoare fundal Panel &
// Constructor pentru UI componente si evenimente &
public AlegeCuloarea() { &
panel = new JPanel(new BorderLayout()); &
& & &*
& &*
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setTitle("Sa schimbam culoarea");
setSize(400, 300);
setLocationRelativeTo(null); // centrarea ferestrei
setVisible(true);
// sa o arate
}
& &*3
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
@SuppressWarnings("serial")
public class CGMoveALine extends JFrame {
/ / defining size
public static final int CANVAS_WIDTH = 500;
public static final int CANVAS_HEIGHT = 140;
3
case KeyEvent.VK_RIGHT:
x1 += 10;
x2 += 10;
repaint();
break;
}
}
});
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // Handle the CLOSE
button
setTitle("Move a Line");
pack();
setVisible(true); // show it
requestFocus(); // set the focus to JFrame to receive KeyEvent
}