Hi,
ich habe eine klasse mit einem JRootPane auf dieses soll ein GlassPane gezeichnet werden was mache ich falsch?
ich habe eine klasse mit einem JRootPane auf dieses soll ein GlassPane gezeichnet werden was mache ich falsch?
Code:
package applet.menue;
import java.awt.Color;
import java.awt.Component;
import java.awt.Cursor;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.MenuItem;
import java.awt.Polygon;
import java.awt.Rectangle;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import java.util.Vector;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRootPane;
import applet.menue.MenueMove;
public class Menue extends JRootPane implements MouseListener{
MenueDesign mDesign;
Component []array;
Component upItem,downItem;
MenueRoot menueRoot;
JPanel glassPanel = new JPanel();
Vector v=new Vector();
int count=0;
public Menue(MenueDesign mDesign){
getGlassPane().setBounds(0,0,100,310);
getGlassPane().setVisible(true);
getGlassPane().addMouseListener(this);
this.mDesign=mDesign;
upItem=mDesign.upItem();
upItem.addMouseListener(this);
downItem=mDesign.downItem();
downItem.addMouseListener(this);
}
public void setBounds(Rectangle rectangle){
try{
super.setBounds(rectangle);
int anzahl=((rectangle.height-50)/15);
anzahl=(anzahl*15>rectangle.height-50)?anzahl--:anzahl;
System.out.println("anzahl:"+anzahl);
array = new Component[anzahl];
draw();
}catch(Exception e){}
}
protected void aktuallisiere(MenueItemStandart menueItemStandart){
if(menueItemStandart.getVisible()==true){
for(int i=0;i<menueItemStandart.countChild();i++)
{
v.addElement(menueItemStandart.getChild(i));
aktuallisiere(menueItemStandart.getChild(i));
}
}
}
public void draw(){
try{
removeAll();
setLayout(null);
v.removeAllElements();
try{
aktuallisiere(menueRoot);
}catch(Exception e){
}
for(int i=0;i<array.length&&i+count<v.size();i++){
MenueItem menueItem=(MenueItem)v.elementAt(i+count);
if(menueItem.countChild()==0){
array[i]=mDesign.newEndItem();
mDesign.setTextEndItem(array[i],menueItem.getName());
}else{
array[i]=mDesign.newItem();
mDesign.setTextItem(array[i],menueItem.getName());
}
array[i].addMouseListener(this);
array[i].setBounds(new Rectangle(5*menueItem.getPosition(),25+15*i,getWidth()-(5+5*menueItem.getPosition()),15));
add(array[i]);
}
repaint();
}catch(Exception e){}
}
public void addMenueRoot(MenueRoot menueRoot){
menueRoot.addMenue(this);
menueRoot.setVisible(true);
this.menueRoot=menueRoot;
draw();
}
public void mouseClicked(MouseEvent e) {
// TODO Auto-generated method stub
}
public void mousePressed(MouseEvent e) {
// TODO Auto-generated method stub
}
public void mouseReleased(MouseEvent e) {
// TODO Auto-generated method stub
}
public void mouseEntered(MouseEvent e) {
// TODO Auto-generated method stub
System.out.println("true");
}
public void mouseExited(MouseEvent e) {
// TODO Auto-generated method stub
System.out.println("false");
}
}