Follow along with the video below to see how to install our site as a web app on your home screen.
Anmerkung: This feature may not be available in some browsers.
public void zeichnen() {
Stift = getGraphics();
Dimension Groesse = getSize();
int hoehe = Groesse.height;
int breite = Groesse.width;
Stift.setColor(Color.red);
Stift.fillOval(10, 60, 50, 50);
}
public void verschieben() {
Stift.copyArea(10, 60, 48, 52, 52, 0);
}
public void weg() {
repaint();
}
public class XXX{
public static void main(String[] args){
new XXX();}
private JFrame window = new JFrame();
private int cnt = 50;
public XXX(){
window.setBounds(100,100,290,150);
window.add(panel);
SwingUtilities.invokeLater(new Runnable() {
public void run() {
window.setVisible(true);
}
});
Thread myThread = new Thread(new Runnable(){
public void run(){
while(true){
try{Thread.sleep(20);}catch(Exception e){e.printStackTrace();}
++cnt;
if(cnt > 200){
cnt = 50;
}
panel.repaint();
}
}
});
myThread.start();
}
JPanel panel = new JPanel(){
public void paintComponent(Graphics g){
super.paintComponent(g);
g.drawRect(cnt,50,30,20);
}
};
}
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
class grafik extends JFrame
{
private int radius = 25;
private int xkoor = 20;
private int ykoor = 40;
public grafik()
{
super("JAVA RULES!!!");
JPanel Platte = new JPanel();
setContentPane(Platte);
}
public void paint(Graphics g) {
g.setColor(Color.green);
g.fillOval(xkoor, ykoor, radius*2, radius*2);
while(true){
g.drawOval(xkoor,ykoor,radius*2,radius*2);
repaint();
xkoor++;
try { Thread.sleep(20) ; } catch (Exception e) { };
}
}
public static void main (String[] args) {
grafik Rahmen = new grafik();
Rahmen.setSize(600, 500);
Rahmen.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Rahmen.setVisible(true);
}
}
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class WorkOne extends Thread {
String name;
int zahlen;
public WorkOne(int z) {
zahlen = z;
}
public void run() {
long summe = 0;
for (int i=0; i < zahlen; i++) {
String theString = "" + summe;
System.out.println("" + theString);
summe = summe + 1;
try
{
Thread.sleep(100);
}
catch(InterruptedException x) {
//...
}
}
}
public static void main(String[] args) {
WorkOne work1 = new WorkOne(400);
work1.start();
}
}