/ / मेरे कोड का ग्रिडबैग लेआउट स्पष्टीकरण - जावा, स्विंग, ग्रिडबैगेलआउट

मेरे कोड के ग्रिडबैग लेआउट स्पष्टीकरण - जावा, स्विंग, ग्रिडबैगआउट

this.getContentPanel().add(sortOrderScrollPane, new GridBagConstraints(0, 0, 5, 5, 0.0, 0.0,
GridBagConstraints.EAST, GridBagConstraints.BOTH, new Insets(5, 5, 10,10), 0, 0));
this.getContentPanel().add(toFirstSortButton, new GridBagConstraints(5, 4, 1, 1, 0.0, 0.0,
GridBagConstraints.EAST, GridBagConstraints.BOTH, new Insets(0, 5, 5, 10), 0, 0));

The toFirstSortButton पूरा कॉलम ले रहा है । किसी को समझा सकते है क्यों?

उत्तर:

उत्तर № 1 के लिए 1

परिवर्तन GridBagConstraints.BOTH सेवा मेरे GridBagConstraints.NONE

इसके अलावा मैं का उपयोग करने की सिफारिश करेंगे GridBagLayout जैसे कि निंनलिखित उदाहरण में । यह आसान है पढ़ने के लिए और गलतियों को रोकता है क्योंकि आप डॉन ' टी के लिए सही पैरामीटर के लिए खोज की जरूरत है अब और ।

this.getContentPanel().setLayout(new GridBagLayout());

GridBagConstraints gbc = new GridBagConstraints();
gbc.fill = GridBagConstraints.NONE;
gbc.gridx = 0;
gbc.gridy = 0;
gbc.weightx = 1;
gbc.weighty = 1;
gbc.gridwidth = 1;
gbc.insets = new Insets(0, 0, 0, 0);
this.getContentPanel().add(sortOrderScrollPane, gbc);
//etc..