java

2019-01-02T05:20:59.001300Z

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

seancorfield 2019-01-02T05:30:35.002800Z

@jjttjj The problem is that java.awt.Window has two constructors that accept one argument and so Clojure can't tell which you want.

seancorfield 2019-01-02T05:31:32.003600Z

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] ...))

2019-01-02T05:38:22.004400Z

@seancorfield awesome thanks so much!