I’m writing a small app where I want absolute positioning – I can get what I want with seemingly an ugly workaround, however I would like to know how I can make this code cleaner maintaining the same functionality.
The problem is if I omit either (.setBounds ..) s-exprs then the JPanel fills the entire JFrame. Thanks in advance, here is working sample code:
...
(:import [javax.swing JFrame JPanel]
[javax.swing.border LineBorder]
[java.awt Color])
(defn frame []
(let [top-panel (doto (JPanel.)
(.setOpaque true)
(.setVisible true)
(.setBounds 25 25 250 75)
(.setBorder (LineBorder. (Color. 255 0 0 255))))
frame (doto (JFrame.)
(.setLayout nil)
(.setResizable false)
(.setSize 300 625)
(.setVisible true)
(.setContentPane top-panel))]
(.setBounds top-panel 25 25 250 75)))
This code gives me the functionality I was looking for, replacing .contentPane with .add