import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.ScrollPane;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
/**
*
* @author tha_specializt
*/
public class testklasse {
/** Creates a new instance of testklasse */
public testklasse() {
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel panel = new JPanel();
GridBagLayout layout = new GridBagLayout();
panel.setLayout(layout);
ScrollPane scrollpane = new ScrollPane();
frame.setContentPane(scrollpane);
scrollpane.add(panel);
int spalte = 1;
int zeile = 1;
Insets keine = new Insets(0,0,0,0);
String text = "DUMMYTEXT";
while(true) {
if(zeile > 100)
break;
if(spalte > 6) {
spalte = 1;
zeile++;
}
int padx = 50;
if(spalte == 1)
padx = 0;
GridBagConstraints constr = new GridBagConstraints( spalte,zeile,
1,1,
0.0,0.0,
GridBagConstraints.WEST,0,
keine,padx,0);
// int gridx, int gridy,
// int gridwidth, int gridheight,
// double weightx, double weighty,
// int anchor, int fill,
// Insets insets, int ipadx, int ipady) {
if(spalte == 1)
panel.add(new JButton(text), constr);
else
panel.add(new JLabel(text), constr);
spalte++;
}
panel.setVisible(true);
scrollpane.setVisible(true);
frame.setVisible(true);
frame.setPreferredSize(new Dimension(500,500));
frame.pack();
}
public static void main(String[] args) {
new testklasse();
}
}