problemas con glassPane
Buenas a todos, mi problema es que estoy intentando dibujar una linea diagonal en el glassPane con un JButon en el contentPane y no logro conseguirlo, este es el codigo por si podeis exarme una mano. Muchas gracias:
import java.awt.*;
import javax.swing.*;
public class ejecutable {
public static void main(String[] args) {
JFrame f=new JFrame();
Container cpane=f.getContentPane();
JButton b=new JButton("BOTON");
PanelTraslucido p=new PanelTraslucido();
cpane.add(b);
f.setGlassPane(p);
f.pack();
f.setVisible(true);
}
}
class PanelTraslucido extends JComponent{
public PanelTraslucido(){
super();
}
public void paintComponent(Graphics g){
g.drawLine(20, 20, super.getWidth(), super.getHeight());
super.setVisible(true);
}
}
import java.awt.*;
import javax.swing.*;
public class ejecutable {
public static void main(String[] args) {
JFrame f=new JFrame();
Container cpane=f.getContentPane();
JButton b=new JButton("BOTON");
PanelTraslucido p=new PanelTraslucido();
cpane.add(b);
f.setGlassPane(p);
f.pack();
f.setVisible(true);
}
}
class PanelTraslucido extends JComponent{
public PanelTraslucido(){
super();
}
public void paintComponent(Graphics g){
g.drawLine(20, 20, super.getWidth(), super.getHeight());
super.setVisible(true);
}
}
