hallo erstmal!!
trotz api und forum, schaff ich es nicht ein hintergrundbild hinter die animation zu bringen!!
ich habs schon mit einem jlabel probiert funzt auch nicht!
frame kennt auch das getContentPane nicht!!
wenn ich die JFrame als vaterklasse nehm funzt die animation nicht mehr!! hintergrundbild hab ich auch noch nie geschaftt zum vorschein zu bringen!!
hier der code:
danke für den support
mfg chris
trotz api und forum, schaff ich es nicht ein hintergrundbild hinter die animation zu bringen!!
ich habs schon mit einem jlabel probiert funzt auch nicht!
frame kennt auch das getContentPane nicht!!
wenn ich die JFrame als vaterklasse nehm funzt die animation nicht mehr!! hintergrundbild hab ich auch noch nie geschaftt zum vorschein zu bringen!!
hier der code:
Code:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.sql.*;
import javax.imageio.*;
import java.io.*;
public class Example2404
extends Frame
implements Runnable
{
int i = 1;
public static void main(String[] args)
{
Example2404 wnd = new Example2404();
wnd.setSize(400,300);
wnd.setVisible(true);
wnd.startAnimation();
}
public Example2404()
{
super("Verfügbare First-Responder");
setBackground(Color.WHITE);
/*try {
bild = ImageIO.read(new File("lndscp.png"));
}
catch (IOException exio)
{
System.out.println(exio);
}*/
// WindowListener
addWindowListener(
new WindowAdapter() {
public void windowClosing(WindowEvent event)
{
System.exit(0);
}
}
);
}
public void startAnimation()
{
Thread th = new Thread(this);
th.start();
}
public void run()
{
int updown = 1;
while (true) {
switch(updown)
{
case 1: i = i + 1;
updown = 0;
break;
case 0: i = i - 1;
updown = 1;
break;
}
repaint();
try {
Thread.sleep(200);
} catch (InterruptedException e) {
//nichts
}
}
}
public void paint(Graphics g)
{
int u;
String db = "jdbc:mysql://localhost/redcrossadmin";
String user = "root";
String pw = "rca";
Statement stmt;
Connection con;
try {
Class.forName("com.mysql.jdbc.Driver");
} catch (Exception e)
{
System.err.println("Kann Treiber nicht laden");
}
try {
for(u=1;u<6;u++)
{
con = DriverManager.getConnection(db,user,pw);
stmt = con.createStatement();
ResultSet result = stmt.executeQuery("SELECT X,Y FROM koordinaten WHERE rMNr = " + u + " ");
result.next();
Point p = new Point(result.getInt(1),result.getInt(2));
g.setColor(Color.RED);
g.fillOval(p.x-i, p.y-i, 5*i,5*i);
// g.drawImage(bild,0,0,this);
}
}
catch (SQLException e)
{
System.out.println("");
}
}
}
danke für den support
mfg chris