Note that there are some explanatory texts on larger screens.

plurals
  1. POIsn't Swing's JPanel pretty much like AWT's Panel? The former's widget is not showing up
    primarykey
    data
    text
    <p>I'm changing a program from AWT to Swing, as proposed on the second chapter of Java Swing's book, and the panel just disappears when I do the change from Panel to JPanel. The same doesn't happen when I change from Button to JButton.</p> <p>It seems to be a bug, since it appears to be trivially simple to do so - just adding an extra J to the name - but I'm not sure where the problem is - with my VM (Sun JDK), with my WM (xmonad) or with the way I'm programming (Clojure's Java Support). Any idea?</p> <p>As previously stated, I'm writing it in Clojure (a lisp-like language for the JDK). Here is my code:</p> <pre> (defn main [] (let [toolbar-frame (Frame. "Toolbar Example (Swing)") cut-button (JButton. "Cut") copy-button (JButton. "Copy") paste-button (JButton. "Paste") java-button (JButton. "Java") windows-button (JButton. "Windows") mac-button (JButton. "Mac") motif-button (JButton. "Motif") <b>lnf-panel (JPanel.)</b> toolbar-panel (Panel.) print-listener (proxy [ActionListener] [] (actionPerformed [evt] (.getActionCommand evt))) ] (.addWindowListener toolbar-frame (proxy [WindowAdapter] [] (windowClosing [e] (System/exit 0)))) ;(doto windows-button (.addActionListener lnf-listener)) ;(doto motif-button (.addActionListener lnf-listener)) ;(doto mac-button (.addActionListener lnf-listener)) ;(doto java-button (.addActionListener lnf-listener)) (doto cut-button (.addActionListener print-listener)) (doto copy-button (.addActionListener print-listener)) (doto paste-button (.addActionListener print-listener)) (doto lnf-panel (.add windows-button) (.add java-button) (.add mac-button) (.add motif-button) (.setLayout (FlowLayout. FlowLayout/LEFT))) (doto toolbar-panel (.add cut-button) (.add copy-button) (.add paste-button) (.setLayout (FlowLayout. FlowLayout/LEFT))) (doto toolbar-frame (.add toolbar-panel BorderLayout/NORTH) (.add lnf-panel BorderLayout/SOUTH) (.setSize 450 250) (.setVisible true)))) </pre> <p>Thanks</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload