Hallo Leute,
ich brauche unbedingt eine Antwort und hoffe jemand kann mir hier helfen... ICh möchte die Schrift auf einem Panel oder das Panel selber dazu bekommen das es in verschiedenen Farben blinkt..Wie bekomme ich das hin...
ich brauche unbedingt eine Antwort und hoffe jemand kann mir hier helfen... ICh möchte die Schrift auf einem Panel oder das Panel selber dazu bekommen das es in verschiedenen Farben blinkt..Wie bekomme ich das hin...
Code:
package test;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
public class Test extends JFrame
{
int a,b,c,d;
JPanel p1;
JLabel l1;
JButton nul;
Test(String titel)
{
super (titel);
this.getContentPane().setLayout(null);
nul = new JButton("test");
p1 = new JPanel( null );
l1 = new JLabel("hallo");
p1.setBounds(20,20,200,200);
nul.setBounds(300, 300, 100, 20);
p1.setBackground(Color.cyan);
this.nul.addActionListener(new CMeinActionLauscher());
this.getContentPane().add(nul);
this.getContentPane().add(p1);
}
class CMeinActionLauscher implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
String knopf; // 1. Möglichkeit
knopf = e.getActionCommand();
if (knopf.equals("test"))
{
a = (int)(Math.random()*266);
b = (int)(Math.random()*266);
c = (int)(Math.random()*266);
p1.setBackground(new Color(a, b, c));
}
}
}
public static void main(String[]args)
{
Test frame = new Test("Hallo");
frame.setSize(600, 600);
frame.setVisible(true);
}
}