Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Hmmm... I could not get your code to work. When I made mods to get it to run I got the panel tightly wrapped by the frame.</p> <p>I'm assuming you want the top-panel in the middle of the larger frame with empty space on all sides. The usual way to do this would be to create a main panel with the size of the frame you want. Then, using a layout manager like BorderLayout, add additional JPanels to the main panel. The top-panel would be given the dimensions you want and surrounding panels would provide the "padding". If the surrounding panels are created with empty borders, it should look like the top-panel is surrounded by empty area.</p> <p><strong>EDIT</strong>:</p> <p>Here's something that may be a bit closer to your intention. The BorderLayout probably does not give the panel sizing priority you want. Maybe GridBagLayout?</p> <pre><code>(ns com.so.abspos (:import (javax.swing JFrame JPanel) (java.awt BorderLayout)) (:gen-class true)) (defn frame [] (let [ center-panel (doto (JPanel.) (.setOpaque true) (.setVisible true) (.setSize 225 50) ;(.setBounds 25 25 250 75) (.setBorder (javax.swing.border.LineBorder. (java.awt.Color. 255 0 0 255)))) top-panel (doto (JPanel.) (.setSize 625 25)) left-panel (doto (JPanel.) (.setSize 25 75)) bottom-panel (doto (JPanel.) (.setSize 625 300)) right-panel (doto (JPanel.) (.setSize 250 75)) main-panel (doto (JPanel.) (.setLayout (new BorderLayout)) (.add left-panel BorderLayout/WEST) (.add top-panel BorderLayout/NORTH) (.add center-panel BorderLayout/CENTER) (.add right-panel BorderLayout/EAST) (.add bottom-panel BorderLayout/SOUTH)) aframe (doto (JFrame.) (.setDefaultCloseOperation JFrame/EXIT_ON_CLOSE) (.setResizable false) (.setSize 300 625) (.setVisible true) (.setContentPane main-panel))])) (defn -main "Just create the frame and show it." [] (frame)) </code></pre>
    singulars
    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.
    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