Hi, ich hab eine sehr komplexe Klasse geschrieben, und habe bei diesem Programm ein Fenster, ein "JFrame" erscheinen lassen, dann einfach einige MenuBars geadded, und ein paar Menus, und ein paar MenuItems, so.
Ich habe alle MenuBars mit der Farbe "color" beschrieben. Bei "Optionen" gibt es MenuItems, die die Farbe ändern, aber dies geschieht nicht wieso?
///////////////////////Code//////////////////////////
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
public class Rayman_Maker extends JFrame
{
private Color backcolor = Color.cyan;
private Color forecolor = Color.blue;
public Rayman_Maker()
{
Toolkit tk = Toolkit.getDefaultToolkit();
final Dimension d = tk.getScreenSize();
setSize(d.width,d.height);
setVisible(true);
setIconImage(new ImageIcon("F:/Rayman_Maker_1.0/Icon.jpg").getImage());
setLayout(null);
setVisible(true);
setResizable(false);
setTitle("Rayman_Maker_1.0");
JMenuBar menubar = new JMenuBar();
menubar.setBounds(0,0,d.width,20);
menubar.setBackground(backcolor);
add(menubar);
JMenu option = new JMenu("Optionen");
menubar.add(option);option.setForeground(forecolor);
JMenu Farbe = new JMenu("Farbe der Menü-Bar ändern");
option.add(Farbe);Farbe.setForeground(forecolor);
JMenu Farbeb1 = new JMenu("Hintergrundfarbe ändern"); Farbeb1.setForeground(forecolor);
///
JMenuItem blue1 = new JMenuItem("Blau");
Farbeb1.add(blue1);
blue1.setBackground(Color.blue);
blue1.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e)
{ backcolor = Color.blue;}});
JMenuItem cyan1 = new JMenuItem("Türkis");
Farbeb1.add(cyan1);
cyan1.setBackground(Color.cyan);
cyan1.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e)
{ backcolor = Color.cyan;}});
JMenuItem orange1 = new JMenuItem("Orange");
Farbeb1.add(orange1);
orange1.setBackground(Color.orange);
orange1.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e)
{ backcolor = Color.orange;}});
JMenuItem yellow1 = new JMenuItem("Gelb");
Farbeb1.add(yellow1);
yellow1.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e)
{ backcolor = Color.yellow;}});
yellow1.setBackground(Color.yellow);
JMenuItem green1 = new JMenuItem("Grün");
Farbeb1.add(green1);
green1.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e)
{ backcolor = Color.green;}});
green1.setBackground(Color.green);
JMenuItem magenta1 = new JMenuItem("Magenta");
Farbeb1.add(magenta1);
magenta1.setBackground(Color.magenta);
magenta1.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e)
{ backcolor = Color.magenta;}});
JMenuItem red1 = new JMenuItem("Rot");
Farbeb1.add(red1);
red1.setBackground(Color.red);
red1.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e)
{ backcolor = Color.red;}});
JMenuItem pink1 = new JMenuItem("Pink");
Farbeb1.add(pink1);
pink1.setBackground(Color.pink);
pink1.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e)
{ backcolor = Color.pink;}});
JMenuItem white1 = new JMenuItem("Weiß");
Farbeb1.add(white1);
white1.setBackground(Color.white);
white1.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e)
{ backcolor = Color.white;}});
JMenuItem black1 = new JMenuItem("Schwarz");
Farbeb1.add(black1);
black1.setForeground(Color.white);
black1.setBackground(Color.black);
black1.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e)
{ backcolor = Color.black;}});
JMenuItem gray111111 = new JMenuItem("Grau (leicht)");
Farbeb1.add(gray111111);
gray111111.setBackground(Color.lightGray);
gray111111.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e)
{ backcolor = Color.lightGray;}});
JMenuItem gray1111 = new JMenuItem("Grau (mittel)");
Farbeb1.add(gray1111);
gray1111.setBackground(Color.gray);
gray1111.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e)
{ backcolor = Color.gray;}});
JMenuItem gray111 = new JMenuItem("Grau (stark)");
Farbeb1.add(gray111);
gray111.setBackground(Color.darkGray);
gray111.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e)
{ backcolor = Color.darkGray;}});
///
Farbe.add(Farbeb1);
}
public static void main(String[]args){new Rayman_Maker();}
}
///////////////////////Code//////////////////////////
Was mach ich den falsch, dass das net geht?
Was ich will, ein Tipp wäre net, danke schon mal im VOraus. Developer_X
PS
Admin
coolesneues Design, schöner neuer server, ehrlich
Ich habe alle MenuBars mit der Farbe "color" beschrieben. Bei "Optionen" gibt es MenuItems, die die Farbe ändern, aber dies geschieht nicht wieso?
///////////////////////Code//////////////////////////
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
public class Rayman_Maker extends JFrame
{
private Color backcolor = Color.cyan;
private Color forecolor = Color.blue;
public Rayman_Maker()
{
Toolkit tk = Toolkit.getDefaultToolkit();
final Dimension d = tk.getScreenSize();
setSize(d.width,d.height);
setVisible(true);
setIconImage(new ImageIcon("F:/Rayman_Maker_1.0/Icon.jpg").getImage());
setLayout(null);
setVisible(true);
setResizable(false);
setTitle("Rayman_Maker_1.0");
JMenuBar menubar = new JMenuBar();
menubar.setBounds(0,0,d.width,20);
menubar.setBackground(backcolor);
add(menubar);
JMenu option = new JMenu("Optionen");
menubar.add(option);option.setForeground(forecolor);
JMenu Farbe = new JMenu("Farbe der Menü-Bar ändern");
option.add(Farbe);Farbe.setForeground(forecolor);
JMenu Farbeb1 = new JMenu("Hintergrundfarbe ändern"); Farbeb1.setForeground(forecolor);
///
JMenuItem blue1 = new JMenuItem("Blau");
Farbeb1.add(blue1);
blue1.setBackground(Color.blue);
blue1.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e)
{ backcolor = Color.blue;}});
JMenuItem cyan1 = new JMenuItem("Türkis");
Farbeb1.add(cyan1);
cyan1.setBackground(Color.cyan);
cyan1.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e)
{ backcolor = Color.cyan;}});
JMenuItem orange1 = new JMenuItem("Orange");
Farbeb1.add(orange1);
orange1.setBackground(Color.orange);
orange1.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e)
{ backcolor = Color.orange;}});
JMenuItem yellow1 = new JMenuItem("Gelb");
Farbeb1.add(yellow1);
yellow1.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e)
{ backcolor = Color.yellow;}});
yellow1.setBackground(Color.yellow);
JMenuItem green1 = new JMenuItem("Grün");
Farbeb1.add(green1);
green1.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e)
{ backcolor = Color.green;}});
green1.setBackground(Color.green);
JMenuItem magenta1 = new JMenuItem("Magenta");
Farbeb1.add(magenta1);
magenta1.setBackground(Color.magenta);
magenta1.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e)
{ backcolor = Color.magenta;}});
JMenuItem red1 = new JMenuItem("Rot");
Farbeb1.add(red1);
red1.setBackground(Color.red);
red1.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e)
{ backcolor = Color.red;}});
JMenuItem pink1 = new JMenuItem("Pink");
Farbeb1.add(pink1);
pink1.setBackground(Color.pink);
pink1.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e)
{ backcolor = Color.pink;}});
JMenuItem white1 = new JMenuItem("Weiß");
Farbeb1.add(white1);
white1.setBackground(Color.white);
white1.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e)
{ backcolor = Color.white;}});
JMenuItem black1 = new JMenuItem("Schwarz");
Farbeb1.add(black1);
black1.setForeground(Color.white);
black1.setBackground(Color.black);
black1.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e)
{ backcolor = Color.black;}});
JMenuItem gray111111 = new JMenuItem("Grau (leicht)");
Farbeb1.add(gray111111);
gray111111.setBackground(Color.lightGray);
gray111111.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e)
{ backcolor = Color.lightGray;}});
JMenuItem gray1111 = new JMenuItem("Grau (mittel)");
Farbeb1.add(gray1111);
gray1111.setBackground(Color.gray);
gray1111.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e)
{ backcolor = Color.gray;}});
JMenuItem gray111 = new JMenuItem("Grau (stark)");
Farbeb1.add(gray111);
gray111.setBackground(Color.darkGray);
gray111.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e)
{ backcolor = Color.darkGray;}});
///
Farbe.add(Farbeb1);
}
public static void main(String[]args){new Rayman_Maker();}
}
///////////////////////Code//////////////////////////
Was mach ich den falsch, dass das net geht?
Was ich will, ein Tipp wäre net, danke schon mal im VOraus. Developer_X
PS
coolesneues Design, schöner neuer server, ehrlich