本文整理匯總了Java中javax.swing.LayoutStyle.ComponentPlacement類的典型用法代碼示例。如果您正苦於以下問題:Java ComponentPlacement類的具體用法?Java ComponentPlacement怎麽用?Java ComponentPlacement使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ComponentPlacement類屬於javax.swing.LayoutStyle包,在下文中一共展示了ComponentPlacement類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: configureVerticalLayout
import javax.swing.LayoutStyle.ComponentPlacement; //導入依賴的package包/類
private void configureVerticalLayout(GroupLayout groupLayout) {
groupLayout.setVerticalGroup(
groupLayout.createParallelGroup(Alignment.LEADING)
.addGroup(groupLayout.createSequentialGroup()
.addContainerGap()
.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE)
.addComponent(projectLbl, GroupLayout.DEFAULT_SIZE, 37, Short.MAX_VALUE)
.addComponent(projectBox, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addPreferredGap(ComponentPlacement.RELATED)
.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE)
.addComponent(editTagLbl, GroupLayout.PREFERRED_SIZE, 37, GroupLayout.PREFERRED_SIZE)
.addComponent(tagSelectBox, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addPreferredGap(ComponentPlacement.UNRELATED)
.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE)
.addComponent(tagEditLbl, GroupLayout.PREFERRED_SIZE, 29, GroupLayout.PREFERRED_SIZE)
.addComponent(editTagTxtField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addGap(18)
.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE)
.addComponent(saveBtn, GroupLayout.PREFERRED_SIZE, 39, GroupLayout.PREFERRED_SIZE)
.addComponent(removeBtn, GroupLayout.PREFERRED_SIZE, 38, GroupLayout.PREFERRED_SIZE))
.addGap(11))
);
}
示例2: TextPanel
import javax.swing.LayoutStyle.ComponentPlacement; //導入依賴的package包/類
/**
* Create the panel.
*/
public TextPanel(String text) {
JLabel lblUpdateChangelog = new JLabel("Update description/change-log:");
JScrollPane scrollPane = new JScrollPane();
JLabel lblDoYouWant = new JLabel("Do you want to install this update?");
lblDoYouWant.setFont(new Font("Tahoma", Font.PLAIN, 15));
lblDoYouWant.setHorizontalAlignment(SwingConstants.CENTER);
GroupLayout groupLayout = new GroupLayout(this);
groupLayout.setHorizontalGroup(
groupLayout.createParallelGroup(Alignment.TRAILING)
.addGroup(groupLayout.createSequentialGroup()
.addContainerGap()
.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
.addComponent(scrollPane, GroupLayout.DEFAULT_SIZE, 430, Short.MAX_VALUE)
.addComponent(lblUpdateChangelog, GroupLayout.DEFAULT_SIZE, 430, Short.MAX_VALUE)
.addComponent(lblDoYouWant, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 430, Short.MAX_VALUE))
.addContainerGap())
);
groupLayout.setVerticalGroup(
groupLayout.createParallelGroup(Alignment.LEADING)
.addGroup(groupLayout.createSequentialGroup()
.addContainerGap()
.addComponent(lblUpdateChangelog)
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(scrollPane, GroupLayout.DEFAULT_SIZE, 249, Short.MAX_VALUE)
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(lblDoYouWant)
.addContainerGap())
);
JTextArea textArea = new JTextArea();
scrollPane.setViewportView(textArea);
setLayout(groupLayout);
textArea.setEditable(false);
textArea.setText(text);
}
示例3: getPreferredGap
import javax.swing.LayoutStyle.ComponentPlacement; //導入依賴的package包/類
@Override
public int getPreferredGap(JComponent component1, JComponent component2,
ComponentPlacement type, int position, Container parent) {
if (component1 == null || component2 == null || type == null) {
throw new NullPointerException();
}
checkPosition(position);
if (type == ComponentPlacement.INDENT &&
(position == SwingConstants.EAST ||
position == SwingConstants.WEST)) {
int indent = getIndent(component1, position);
if (indent > 0) {
return indent;
}
}
return (type == ComponentPlacement.UNRELATED) ? 12 : 6;
}
示例4: initComponents
import javax.swing.LayoutStyle.ComponentPlacement; //導入依賴的package包/類
private void initComponents()
{
digitalPanel = new JPanel();
analogPanel = new JPanel();
GroupLayout groupLayout = new GroupLayout(this);
groupLayout.setHorizontalGroup(groupLayout.createParallelGroup(Alignment.LEADING)
.addGroup(groupLayout.createSequentialGroup()
.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
.addComponent(analogPanel, GroupLayout.DEFAULT_SIZE, 450, Short.MAX_VALUE).addComponent(digitalPanel,
GroupLayout.DEFAULT_SIZE, 450, Short.MAX_VALUE))
.addGap(0)));
groupLayout.setVerticalGroup(groupLayout.createParallelGroup(Alignment.LEADING)
.addGroup(groupLayout.createSequentialGroup().addComponent(analogPanel, GroupLayout.DEFAULT_SIZE, 91, Short.MAX_VALUE)
.addPreferredGap(ComponentPlacement.RELATED).addComponent(digitalPanel, GroupLayout.DEFAULT_SIZE, 178, Short.MAX_VALUE)
.addGap(0)));
setLayout(groupLayout);
}
示例5: JKeyBindingPanel
import javax.swing.LayoutStyle.ComponentPlacement; //導入依賴的package包/類
public JKeyBindingPanel(FrameKeyBindings parent, KeyBinding.Type type, KeyBinding binding) {
this.parent = parent;
JLabel label = new JLabel(" " + type.toString());
label.setPreferredSize(new Dimension(5000, 50));
label.setBorder(BorderFactory.createLineBorder(Color.gray));
btn = new JKeyBindingButton(this, type, binding);
GroupLayout groupLayout = new GroupLayout(this);
groupLayout.setHorizontalGroup(
groupLayout.createParallelGroup(Alignment.LEADING)
.addGroup(groupLayout.createSequentialGroup()
.addComponent(label, GroupLayout.PREFERRED_SIZE, 152, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(btn, GroupLayout.DEFAULT_SIZE, 294, Short.MAX_VALUE))
);
groupLayout.setVerticalGroup(
groupLayout.createParallelGroup(Alignment.LEADING)
.addComponent(label, GroupLayout.DEFAULT_SIZE, 34, Short.MAX_VALUE)
.addComponent(btn, GroupLayout.DEFAULT_SIZE, 34, Short.MAX_VALUE)
);
setLayout(groupLayout);
}
示例6: getPreferredGap
import javax.swing.LayoutStyle.ComponentPlacement; //導入依賴的package包/類
@Override
public int getPreferredGap(JComponent component1, JComponent component2,
ComponentPlacement type, int position, Container parent) {
if (component1 == null || component2 == null || type == null) {
throw new NullPointerException();
}
if (type == ComponentPlacement.INDENT &&
(position == SwingConstants.EAST ||
position == SwingConstants.WEST)) {
int indent = getIndent(component1, position);
if (indent > 0) {
return indent;
}
}
return (type == ComponentPlacement.UNRELATED) ? 12 : 6;
}
示例7: getPanelPregunta
import javax.swing.LayoutStyle.ComponentPlacement; //導入依賴的package包/類
public JPanel getPanelPregunta() {
if (panelPregunta == null) {
panelPregunta = new JPanel();
panelPregunta.setBorder(new EmptyBorder(4, 6, 4, 6));
GroupLayout gl_panelPregunta = new GroupLayout(panelPregunta);
gl_panelPregunta
.setHorizontalGroup(gl_panelPregunta.createParallelGroup(Alignment.LEADING)
.addGroup(gl_panelPregunta.createSequentialGroup()
.addComponent(getPanelLetra(), GroupLayout.PREFERRED_SIZE, 58,
GroupLayout.PREFERRED_SIZE)
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(getScrollPane(), GroupLayout.DEFAULT_SIZE, 403, Short.MAX_VALUE)
.addGap(1)));
gl_panelPregunta.setVerticalGroup(gl_panelPregunta.createParallelGroup(Alignment.LEADING)
.addGroup(gl_panelPregunta.createSequentialGroup()
.addGroup(gl_panelPregunta.createParallelGroup(Alignment.LEADING)
.addComponent(getPanelLetra(), GroupLayout.PREFERRED_SIZE, 48,
GroupLayout.PREFERRED_SIZE)
.addComponent(getScrollPane(), GroupLayout.PREFERRED_SIZE, 48, GroupLayout.PREFERRED_SIZE))
.addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
panelPregunta.setLayout(gl_panelPregunta);
}
return panelPregunta;
}
示例8: initialize
import javax.swing.LayoutStyle.ComponentPlacement; //導入依賴的package包/類
private void initialize() {
setBorder(new TitledBorder(null, "RS422", TitledBorder.LEADING, TitledBorder.TOP, null, null));
GroupLayout groupLayout = new GroupLayout(this);
groupLayout.setHorizontalGroup(
groupLayout.createParallelGroup(Alignment.LEADING)
.addGroup(groupLayout.createSequentialGroup()
.addContainerGap()
.addComponent(getLblPort())
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(getComboBox(), 0, 404, Short.MAX_VALUE)
.addContainerGap())
);
groupLayout.setVerticalGroup(
groupLayout.createParallelGroup(Alignment.LEADING)
.addGroup(groupLayout.createSequentialGroup()
.addContainerGap()
.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE)
.addComponent(getLblPort())
.addComponent(getComboBox(), GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addContainerGap(280, Short.MAX_VALUE))
);
setLayout(groupLayout);
}
示例9: StaticShadowPanel
import javax.swing.LayoutStyle.ComponentPlacement; //導入依賴的package包/類
public StaticShadowPanel() {
TitledBorder border = new TitledBorder(new LineBorder(new Color(128, 128, 128)), Resources.get("panel_staticShadow"), TitledBorder.LEADING, TitledBorder.TOP, null, null);
border.setTitleFont(border.getTitleFont().deriveFont(Font.BOLD));
setBorder(border);
JLabel lblShadowType = new JLabel(Resources.get("panel_shadowType"));
comboBoxShadowType = new JComboBox<>();
comboBoxShadowType.setModel(new DefaultComboBoxModel<StaticShadowType>(StaticShadowType.values()));
GroupLayout groupLayout = new GroupLayout(this);
groupLayout.setHorizontalGroup(
groupLayout.createParallelGroup(Alignment.LEADING)
.addGroup(groupLayout.createSequentialGroup()
.addContainerGap()
.addComponent(lblShadowType, GroupLayout.PREFERRED_SIZE, 51, GroupLayout.PREFERRED_SIZE)
.addGap(10)
.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
.addGroup(groupLayout.createSequentialGroup()
.addComponent(comboBoxShadowType, 0, 95, Short.MAX_VALUE)
.addGap(4)))));
groupLayout.setVerticalGroup(
groupLayout.createParallelGroup(Alignment.LEADING)
.addGroup(groupLayout.createSequentialGroup()
.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE)
.addComponent(comboBoxShadowType, GroupLayout.PREFERRED_SIZE, 19, GroupLayout.PREFERRED_SIZE)
.addComponent(lblShadowType, GroupLayout.PREFERRED_SIZE, 13, GroupLayout.PREFERRED_SIZE))
.addPreferredGap(ComponentPlacement.UNRELATED)
.addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
setLayout(groupLayout);
this.setupChangedListeners();
}
示例10: EmitterPanel
import javax.swing.LayoutStyle.ComponentPlacement; //導入依賴的package包/類
public EmitterPanel() {
TitledBorder border = new TitledBorder(new LineBorder(new Color(128, 128, 128)), Resources.get("panel_emitter"), TitledBorder.LEADING, TitledBorder.TOP, null, null);
border.setTitleFont(border.getTitleFont().deriveFont(Font.BOLD));
setBorder(border);
JLabel lblShadowType = new JLabel(Resources.get("panel_emitterType"));
textFieldType = new JTextField();
textFieldType.setColumns(10);
GroupLayout groupLayout = new GroupLayout(this);
groupLayout.setHorizontalGroup(
groupLayout.createParallelGroup(Alignment.LEADING)
.addGroup(groupLayout.createSequentialGroup()
.addContainerGap()
.addComponent(lblShadowType, GroupLayout.PREFERRED_SIZE, 51, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(textFieldType, GroupLayout.DEFAULT_SIZE, 95, Short.MAX_VALUE)
.addContainerGap()));
groupLayout.setVerticalGroup(
groupLayout.createParallelGroup(Alignment.LEADING)
.addGroup(groupLayout.createSequentialGroup()
.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE)
.addComponent(lblShadowType, GroupLayout.PREFERRED_SIZE, 13, GroupLayout.PREFERRED_SIZE)
.addComponent(textFieldType, GroupLayout.PREFERRED_SIZE, 19, GroupLayout.PREFERRED_SIZE))
.addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
setLayout(groupLayout);
this.setupChangedListeners();
}
示例11: GridEditPanel
import javax.swing.LayoutStyle.ComponentPlacement; //導入依賴的package包/類
public GridEditPanel(int rasterSize) {
JLabel lblSize = new JLabel("size (px)");
lblSize.setFont(Program.TEXT_FONT.deriveFont(Font.BOLD).deriveFont(10f));
textField = new JFormattedTextField(NumberFormat.getIntegerInstance());
textField.setText("16");
textField.setFont(Program.TEXT_FONT.deriveFont(10f));
textField.setColumns(10);
textField.setValue(rasterSize);
GroupLayout groupLayout = new GroupLayout(this);
groupLayout.setHorizontalGroup(
groupLayout.createParallelGroup(Alignment.LEADING)
.addGroup(groupLayout.createSequentialGroup()
.addContainerGap()
.addComponent(lblSize, GroupLayout.PREFERRED_SIZE, 44, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(textField, GroupLayout.DEFAULT_SIZE, 166, Short.MAX_VALUE)
.addGap(34)));
groupLayout.setVerticalGroup(
groupLayout.createParallelGroup(Alignment.LEADING)
.addGroup(groupLayout.createSequentialGroup()
.addContainerGap()
.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE)
.addComponent(lblSize, GroupLayout.PREFERRED_SIZE, 13, GroupLayout.PREFERRED_SIZE)
.addComponent(textField, GroupLayout.PREFERRED_SIZE, 19, GroupLayout.PREFERRED_SIZE))
.addContainerGap(46, Short.MAX_VALUE)));
setLayout(groupLayout);
}
示例12: WidthHeightPanel
import javax.swing.LayoutStyle.ComponentPlacement; //導入依賴的package包/類
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);
}
示例13: makeVerticalStrut
import javax.swing.LayoutStyle.ComponentPlacement; //導入依賴的package包/類
static Component makeVerticalStrut(JComponent compA,
JComponent compB,
ComponentPlacement relatedUnrelated,
JPanel parent) {
int height = LayoutStyle.getInstance().getPreferredGap(
compA,
compB,
relatedUnrelated,
SOUTH,
parent);
return Box.createVerticalStrut(height);
}
示例14: makeHorizontalStrut
import javax.swing.LayoutStyle.ComponentPlacement; //導入依賴的package包/類
static Component makeHorizontalStrut(JComponent compA,
JComponent compB,
ComponentPlacement relatedUnrelated,
JPanel parent) {
int width = LayoutStyle.getInstance().getPreferredGap(
compA,
compB,
relatedUnrelated,
WEST,
parent);
return Box.createHorizontalStrut(width);
}
示例15: ProgressDialog
import javax.swing.LayoutStyle.ComponentPlacement; //導入依賴的package包/類
/**
* Create the dialog.
*/
public ProgressDialog() {
setBounds(100, 100, 450, 141);
getContentPane().setLayout(new BorderLayout());
contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
getContentPane().add(contentPanel, BorderLayout.CENTER);
lblStatus = new JLabel("Status: Initializing");
lblStatus.setFont(new Font("Tahoma", Font.PLAIN, 12));
pb = new JProgressBar();
GroupLayout gl_contentPanel = new GroupLayout(contentPanel);
gl_contentPanel
.setHorizontalGroup(gl_contentPanel.createParallelGroup(Alignment.LEADING).addGroup(Alignment.TRAILING,
gl_contentPanel.createSequentialGroup().addContainerGap()
.addGroup(gl_contentPanel.createParallelGroup(Alignment.TRAILING)
.addComponent(pb, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 404,
Short.MAX_VALUE)
.addComponent(lblStatus, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 404,
Short.MAX_VALUE))
.addContainerGap()));
gl_contentPanel.setVerticalGroup(gl_contentPanel.createParallelGroup(Alignment.LEADING)
.addGroup(gl_contentPanel.createSequentialGroup().addContainerGap().addComponent(lblStatus)
.addPreferredGap(ComponentPlacement.RELATED).addComponent(pb, GroupLayout.DEFAULT_SIZE, 28,
Short.MAX_VALUE)));
contentPanel.setLayout(gl_contentPanel);
{
JPanel buttonPane = new JPanel();
buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
getContentPane().add(buttonPane, BorderLayout.SOUTH);
{
JButton cancelButton = new JButton("Cancel");
cancelButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
dispose();
}
});
cancelButton.setActionCommand("Cancel");
buttonPane.add(cancelButton);
}
}
}