Some issues with layout managers and scrollpanes, not showing objects?

Here's a working example with which to compare your code.

Here's a working example with which to compare your code. Import java.awt. Color; import java.awt.

Dimension; import java.awt. EventQueue; import java.awt. GridLayout; import javax.swing.

GroupLayout; import javax.swing. JFrame; import javax.swing. JLabel; import javax.swing.

JPanel; import javax.swing. JScrollPane; /** @http://stackoverflow.com/questions/7801870 */ public class ScrollGroup extends JPanel { private static final int N = 8; private static final int NN = N * N; private static final int GAP = 5; private static final int SIZE = 32; public ScrollGroup() { this. SetLayout(new GridLayout(N, N, GAP, GAP)); for (int I = 0; I SetOpaque(true); label.

SetBackground(Color. GetHSBColor((float) I / NN, 1, 1)); label. SetPreferredSize(new Dimension(SIZE, SIZE)); this.

Add(label); } } private void display() { JFrame f = new JFrame("ScrollGroup"); f. SetDefaultCloseOperation(JFrame. EXIT_ON_CLOSE); JScrollPane sp = new JScrollPane(this); GroupLayout layout = new GroupLayout(f.getContentPane()); f.

SetLayout(layout); layout. SetAutoCreateGaps(true); layout. SetAutoCreateContainerGaps(true); layout.

SetHorizontalGroup(layout. CreateSequentialGroup() . AddGroup(layout.

CreateParallelGroup(). AddComponent(sp))); layout. SetVerticalGroup(layout.

CreateSequentialGroup() . AddGroup(layout. CreateParallelGroup().

AddComponent(sp))); f.pack(); f. SetSize(N * SIZE, N * SIZE); f. SetLocationRelativeTo(null); f.

SetVisible(true); } public static void main(String args) { EventQueue. InvokeLater(new Runnable() { @Override public void run() { new ScrollGroup().display(); } }); } }.

3 In this case, GroupLayout behaves like BorderLayout.CENTER. If NetBeans' GUI designer is slowing you down, abandon it and use the time to learn layouts. – trashgod Oct 18 at 3:36 I'm going to try this later today.

I'm not sure what I did differently, other than your using a GroupLayout and I'm using a GridLayout. We'll see. Thanks in advance, this is helpful whether it helps me fix my problem or not.

:) – BitCrash Oct 18 at 17:58 I figured it out, many thanks. :) – BitCrash Oct 18 at 20:10 You're welcome. I used GroupLayout in the frame to mimic the NetBeans GUI designer default.

– trashgod Oct 18 at 22:06.

I wish to dynamically create ... When you add components to a visible GUI the basic code should be: panel. Add(...); panel.revalidate(); If you need more help then you need to post an SSCCE.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions