Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You overrode the frame's <code>paint</code> method...</p> <pre><code>public void paint(Graphics g) { } </code></pre> <p>But failed to call <code>super.paint(g)</code>....</p> <p>One of the responsibilities of <code>paint</code> is to paint the child components...</p> <p><strong>UPDATED</strong></p> <p>Also, the call to <code>this.setLayout(new BorderLayout())</code> is messing with your layout as the constraints have being discarded, meaning that the layout manager doesn't know what should go where</p> <p><strong>UPDATED Example</strong></p> <p>I was able to produce this...</p> <p><img src="https://i.stack.imgur.com/jwziT.png" alt="enter image description here"></p> <p>With this</p> <pre><code>public class Elevator02 { public static void main(String[] args) { new Elevator02(); } public Elevator02() { EventQueue.invokeLater(new Runnable() { @Override public void run() { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (ClassNotFoundException ex) { } catch (InstantiationException ex) { } catch (IllegalAccessException ex) { } catch (UnsupportedLookAndFeelException ex) { } UI ui = new UI(); ui.setLocationRelativeTo(null); } }); } public class UI extends JFrame implements ActionListener { ArrayList&lt;Button&gt; buttonList = new ArrayList(); JPanel buttonPanel; public UI() { super("Elevators"); setSize(200, 400); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setVisible(true); JPanel mainPanel = new JPanel(); mainPanel.setLayout(new GridLayout(1, 3)); buttonPanel = new JPanel(); buttonPanel.setLayout(new GridLayout(12, 1)); add(mainPanel); for (int i = 0; i &lt; 12; i++) { buttonList.add(new Button("" + i)); buttonPanel.add(buttonList.get(i)); buttonList.get(i).addActionListener(this); } setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); mainPanel.add(buttonPanel); } // public void paint(Graphics g) { // } public void actionPerformed(ActionEvent e) { } } } </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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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