G
Guest
Gast
morgen,
also ich habe das problem das der abstand zwischen den buttons nicht gleich ist.wenn ich ein leerezeichen einfüge ist er unterschiedlich wenn ich keines reinmache, ist gar kein abstand sichtbar.vielleicht kann mir ja jemand helfen hier der code.
hier dei methode addComponent
vielen dank schon mal!
grüße
also ich habe das problem das der abstand zwischen den buttons nicht gleich ist.wenn ich ein leerezeichen einfüge ist er unterschiedlich wenn ich keines reinmache, ist gar kein abstand sichtbar.vielleicht kann mir ja jemand helfen hier der code.
Code:
Container buttons = new Container();
GridBagLayout gbl4 = new GridBagLayout();
buttons.setLayout( gbl4 );
content.add(buttons);
JLabel spacer1 = new JLabel("");
addComponent( buttons, gbl4,spacer1, 0,0,19,1,0,0 );
spacer1.setSize(19, 1);
JLabel spacer2 = new JLabel("");
addComponent( buttons, gbl4,spacer2, 0,1, 1,5,0,0 );
spacer2.setSize(1,5);
JLabel spacer3 = new JLabel("");
addComponent( buttons, gbl4,spacer3, 9,1, 1,5,0,0 );
spacer3.setSize(1,5);
JLabel spacer4 = new JLabel("");
addComponent( buttons, gbl4,spacer4,18,1, 1,5,0,0 );
spacer4.setSize(1,5);
JLabel spacer5 = new JLabel("");
addComponent( buttons, gbl4,spacer5, 1,3, 8,1,0,0 );
spacer5.setSize(8,1);
JLabel spacer6 = new JLabel("");
addComponent( buttons, gbl4,spacer6,10,3, 8,1,0,0 );
spacer6.setSize(8,1);
JLabel spacer7 = new JLabel("");
addComponent( buttons, gbl4,spacer7, 0,6,19,1,0,0 );
spacer3.setSize(19,1);
JButton buttonFind = new JButton("Find");
addComponent( buttons, gbl4,buttonFind,1,1,8,2,1.0,0);
buttonFind.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
updatePropertyStates();
actions.find(properties);
}
});
JButton buttonReplaceFind = new JButton("Replace/Find");
addComponent( buttons, gbl4,buttonReplaceFind,10,1,8,2,1.0,0);
buttonReplaceFind.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
updatePropertyStates();
actions.findReplace(properties);
}
});
JButton buttonReplace = new JButton("Replace");
addComponent( buttons, gbl4,buttonReplace,1,4,8,2,1.0,0);
buttonReplace.setSize(20,5);
buttonReplace.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
updatePropertyStates();
actions.replace(properties);
}
});
JButton buttonReplaceAll = new JButton("Replace/All");
addComponent( buttons, gbl4,buttonReplaceAll,10,4,8,2,1.0,0);
buttonReplaceAll.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
updatePropertyStates();
actions.replaceAll(properties);
}
});
Code:
public static void addComponent( Container cont,
GridBagLayout gbl,
Component c,
int x, int y,
int width, int height,
double weightx, double weighty ) {
GridBagConstraints gbc = new GridBagConstraints();
gbc.fill = GridBagConstraints.BOTH;
gbc.gridx = x; gbc.gridy = y;
gbc.gridwidth = width; gbc.gridheight = height;
gbc.weightx = weightx; gbc.weighty = weighty;
gbl.setConstraints( c, gbc );
cont.add( c );
}
grüße