I'm having trouble translating the following java (from https://stackoverflow.com/questions/21604762/drawing-over-screen-in-java) to clojure:
Window w=new Window(null)
{
@Override
public void paint(Graphics g)
{
final Font font = getFont().deriveFont(48f);
g.setFont(font);
g.setColor(Color.RED);
final String message = "Hello";
FontMetrics metrics = g.getFontMetrics();
g.drawString(message,
(getWidth()-metrics.stringWidth(message))/2,
(getHeight()-metrics.getHeight())/2);
}
@Override
public void update(Graphics g)
{
paint(g);
}
};
w.setAlwaysOnTop(true);
w.setBounds(w.getGraphicsConfiguration().getBounds());
w.setBackground(new Color(0, true));
w.setVisible(true);
I think I want something along the lines of this:
(proxy [Window] [nil]
(paint [ g]
;...
))
But am getting an error like
More than one matching method found:
x.core.proxy$java.awt.Window$ff19274a
@jjttjj The problem is that java.awt.Window
has two constructors that accept one argument and so Clojure can't tell which you want.
You can workaround that by doing this
user=> (def ^java.awt.Window w-nil nil)
#'user/w-nil
user=> (proxy [java.awt.Window] [w-nil] (paint [g] ...) (update [g] ...))
@seancorfield awesome thanks so much!