下面列出了javax.swing.JSpinner#setVisible ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
WidthHeightPanel(boolean showWidth, boolean showHeight) {
ResourceBundle bundle = NbBundle.getBundle(BoxFillerInitializer.class);
JLabel widthLabel = new JLabel(bundle.getString("BoxFillerInitializer.width")); // NOI18N
JLabel heightLabel = new JLabel(bundle.getString("BoxFillerInitializer.height")); // NOI18N
widthField = new JSpinner(new SpinnerNumberModel());
heightField = new JSpinner(new SpinnerNumberModel());
GroupLayout layout = new GroupLayout(this);
setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.TRAILING)
.addComponent(widthLabel)
.addComponent(heightLabel))
.addPreferredGap(ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(widthField)
.addComponent(heightField))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(widthLabel)
.addComponent(widthField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addPreferredGap(ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(heightLabel)
.addComponent(heightField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
widthLabel.setVisible(showWidth);
heightLabel.setVisible(showHeight);
widthField.setVisible(showWidth);
heightField.setVisible(showHeight);
}