下面列出了javax.swing.BoxLayout#X_AXIS 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private Component getProxyHostArea() {
final Box checkBoxBox = new Box(BoxLayout.Y_AXIS);
checkBoxBox.setPreferredSize(new Dimension(600, 200));
checkBoxBox.add(this.bypassLocalCheckBox);
checkBoxBox.add(this.authenticatedCheckBox);
final Box checkBoxBoxExpander = new Box(BoxLayout.X_AXIS);
checkBoxBoxExpander.add(checkBoxBox);
checkBoxBoxExpander.add(Box.createHorizontalGlue());
final Box box = this.proxyHostArea;
box.setBorder(new EmptyBorder(8, 16, 8, 8));
box.add(this.hostPortPanel);
box.add(checkBoxBoxExpander);
box.add(this.authenticationPanel);
return box;
}
public AboutDialog(JFrame parent, String applicationName, String description, String version, String wpilibVersion) {
super(parent, applicationName);
Box aboutWindow = new Box(BoxLayout.Y_AXIS);
JLabel productName = new JLabel(applicationName);
Font defaultFont = productName.getFont();
productName.setFont(new Font(defaultFont.getName(), Font.BOLD, defaultFont.getSize() + 8));
aboutWindow.add(Box.createVerticalStrut(10));
aboutWindow.add(productName);
aboutWindow.add(new JLabel("Version " + version));
aboutWindow.add(Box.createVerticalStrut(15));
aboutWindow.add(new JLabel("Exports to WPILib Version " + wpilibVersion));
aboutWindow.add(Box.createVerticalStrut(15));
aboutWindow.add(new JLabel(description));
aboutWindow.add(Box.createVerticalStrut(15));
aboutWindow.add(new JLabel("FIRST/WPI Robotics Research Group"));
aboutWindow.add(Box.createVerticalStrut(5));
ButtonBox buttonBox = new ButtonBox(BoxLayout.X_AXIS);
JButton okButton = new JButton("OK");
this.getRootPane().setDefaultButton(okButton);
okButton.addActionListener(e -> setVisible(false));
buttonBox.add(okButton);
aboutWindow.add(buttonBox);
this.getContentPane().add(aboutWindow, "Center");
this.pack();
}
private Component getProxyBox() {
final Box radioBox = new Box(BoxLayout.Y_AXIS);
radioBox.setPreferredSize(new Dimension(600, 200));
radioBox.add(this.noProxyRadioButton);
radioBox.add(this.httpProxyRadioButton);
radioBox.add(this.socksProxyRadioButton);
final Box radioBoxExpander = new Box(BoxLayout.X_AXIS);
radioBoxExpander.add(radioBox);
radioBoxExpander.add(Box.createGlue());
final Box box = SwingTasks.createGroupBox(BoxLayout.Y_AXIS, "Proxy");
box.add(radioBoxExpander);
box.add(this.getProxyHostArea());
return box;
}
public void setOrientation(Object value) {
int axis;
String position;
if (value == HORIZONTAL) {
axis = BoxLayout.X_AXIS;
position = BorderLayout.LINE_START;
} else if (value == VERTICAL) {
axis = BoxLayout.Y_AXIS;
position = BorderLayout.NORTH;
} else {
throw new IllegalArgumentException();
}
this.remove(subpanel);
subpanel.setLayout(new BoxLayout(subpanel, axis));
this.add(subpanel, position);
this.orientation = value;
}
private Component getSearchEnginePane() {
final Box innerBox = new Box(BoxLayout.X_AXIS);
innerBox.add(new JLabel("Search Engines:"));
innerBox.add(this.searchEngineListControl);
final Box groupBox = SwingTasks.createGroupBox(BoxLayout.Y_AXIS, "Search");
groupBox.add(innerBox);
return groupBox;
}
private Component getStartupGroupBox() {
final Box startupGroupBox = new Box(BoxLayout.Y_AXIS);
startupGroupBox.setBorder(new TitledBorder(new EtchedBorder(), "Startup"));
final Box startupPagesBox = new Box(BoxLayout.X_AXIS);
final JLabel pagesLabel = new JLabel("Pages:");
pagesLabel.setToolTipText("Up to " + MAX_STARTUP_PAGES + " pages launched when you first run the browser.");
startupPagesBox.add(pagesLabel);
startupPagesBox.add(this.startupPagesStringListControl);
startupGroupBox.add(startupPagesBox);
return startupGroupBox;
}
public static void main(String args[]) {
javax.swing.JFrame frame = new javax.swing.JFrame("foo");
frame.setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE);
String[] dict = {"auto", "automobile", "autocrat", "graduation"};
JTextField field =
AutoCompleteDocument.createAutoCompleteTextField(dict);
BoxLayout layout = new BoxLayout(frame.getContentPane(),
BoxLayout.X_AXIS);
frame.getContentPane().setLayout(layout);
frame.getContentPane().add(new javax.swing.JLabel("Text Field: "));
frame.getContentPane().add(field);
frame.setVisible(true);
}
/** Not public, instances created using factory method createPanel */
FiltersComponent(FiltersDescription descr) {
super(BoxLayout.X_AXIS);
this.filtersDesc = descr;
// always create swing content in AWT thread
if (!SwingUtilities.isEventDispatchThread()) {
SwingUtilities.invokeLater(new Runnable () {
public void run () {
initPanel();
}
});
} else {
initPanel();
}
}
private Component getButtonsPanel() {
final JButton saveButton = this.saveButton;
saveButton.setAction(new SaveAction());
saveButton.setText("Save As...");
saveButton.setToolTipText("You must select a file before download begins.");
final JButton closeButton = this.closeButton;
closeButton.setAction(new CloseAction());
closeButton.setText("Cancel");
final JButton openButton = this.openButton;
openButton.setAction(new OpenAction());
openButton.setText("Open");
final JButton openFolderButton = this.openFolderButton;
openFolderButton.setAction(new OpenFolderAction());
openFolderButton.setText("Open Folder");
final Box box = new Box(BoxLayout.X_AXIS);
// box.setBorder(new BevelBorder(BevelBorder.RAISED));
box.add(Box.createGlue());
box.add(openButton);
box.add(Box.createHorizontalStrut(4));
box.add(openFolderButton);
box.add(Box.createHorizontalStrut(4));
box.add(saveButton);
box.add(Box.createHorizontalStrut(4));
box.add(closeButton);
return box;
}
private Component createButtonPanel() {
final Box panel = new Box(BoxLayout.X_AXIS);
panel.setPreferredSize(new Dimension(Short.MAX_VALUE, 0));
panel.setBorder(new EmptyBorder(4, 4, 4, 4));
panel.add(Box.createGlue());
panel.add(this.okButton);
panel.add(Box.createRigidArea(new Dimension(4, 1)));
panel.add(this.cancelButton);
panel.add(Box.createGlue());
return panel;
}
private JPanel getInfoJPanel(JLabel label) {
JPanel infoJPanel = new JPanel();
LayoutManager layout = new BoxLayout(infoJPanel, BoxLayout.X_AXIS);
infoJPanel.setLayout(layout);
Dimension dim = new Dimension(1, 30);
infoJPanel.add(Box.createHorizontalGlue());
infoJPanel.add(Box.createRigidArea(dim));
infoJPanel.add(label);
infoJPanel.add(Box.createHorizontalGlue());
infoJPanel.setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY, 1));
return infoJPanel;
}
public JdotxtStatusBar() {
super(BoxLayout.X_AXIS);
initGUI();
}
private void createUIComponents() {
setLayout(new BorderLayout());
Box box = new Box(BoxLayout.X_AXIS);
add(new JSeparator(), BorderLayout.NORTH);
box.setBorder(new EmptyBorder(new JBInsets(5, 10, 5, 10)));
backButton.setActionCommand(BACK_ACTION);
box.add(backButton);
box.add(Box.createHorizontalStrut(10));
nextButton.setActionCommand(NEXT_ACTION);
box.add(nextButton);
cancelButton.setActionCommand(CANCEL_ACTION);
box.add(Box.createHorizontalStrut(10));
box.add(cancelButton);
add(box, BorderLayout.EAST);
}
/** Constructs panel containing the main GUI components. */
private JPanel constructJComponent() {
// Selection panel
BoxLayout selectionPanelLayout = new BoxLayout(selectionPanel, BoxLayout.Y_AXIS);
selectionPanel.setLayout(selectionPanelLayout);
ButtonGroup radioButtons = new ButtonGroup();
if (optionsToSelect != null) {
for (int i = 0; i < optionsToSelect.size(); i++) {
JRadioButton radioButton = new JRadioButton(getI18n(optionsToSelect.get(i)));
radioButton.setHorizontalAlignment(JRadioButton.LEFT);
if (i == 0) {
radioButton.setSelected(true);
}
radioButtons.add(radioButton);
selectionPanel.add(radioButton);
}
}
// Checkbox panel
BoxLayout checkboxPanelLayout = new BoxLayout(checkboxPanel, BoxLayout.Y_AXIS);
checkboxPanel.setLayout(checkboxPanelLayout);
if (optionsToCheck != null) {
for (int i = 0; i < optionsToCheck.size(); i++) {
JCheckBox jCheckBox = new JCheckBox(getI18n(optionsToCheck.get(i)));
jCheckBox.setHorizontalAlignment(JCheckBox.LEFT);
checkboxPanel.add(jCheckBox);
}
}
// Overall panel
JPanel panel = new JPanel();
BoxLayout panelLayout = new BoxLayout(panel, BoxLayout.Y_AXIS);
panel.setLayout(panelLayout);
panel.add(selectionPanel);
if (optionsToSelect != null && !optionsToSelect.isEmpty() && optionsToCheck != null && !optionsToCheck.isEmpty()) {
panel.add(Box.createRigidArea(new Dimension(0, GAP_BETWEEN_SELECTIONS)));
}
panel.add(checkboxPanel);
JPanel leftMarginPanel = new JPanel();
BoxLayout leftMarginPanelLayout = new BoxLayout(leftMarginPanel, BoxLayout.X_AXIS);
leftMarginPanel.setLayout(leftMarginPanelLayout);
leftMarginPanel.add(Box.createRigidArea(new Dimension(getInfoIcon().getIconWidth() + BUTTON_DIALOG_LEFT_GAP, 0)));
leftMarginPanel.add(panel);
return leftMarginPanel;
}
public JdotxtStatusBar(String text) {
super(BoxLayout.X_AXIS);
initGUI();
setText(text);
}
public CustomToolbar() {
super(BoxLayout.X_AXIS);
initPanel();
}
protected Box createInstanceImpl() {
return new Box(BoxLayout.X_AXIS) {
public void layout() {}
public void setLayout(LayoutManager l) {}
};
}
MetadataComboBoxEditor() {
super(BoxLayout.X_AXIS);
keyEditField = new MetadataEditField(keyFieldWidth) {
protected String getDefaultText() {
return metadata==emptyMetadata? ToolsRes.getString("LibraryTreePanel.Metadata.Name"): null; //$NON-NLS-1$
}
protected Font getEmptyFont() {
return font.deriveFont(Font.BOLD+Font.ITALIC);
}
protected Font getDefaultFont() {
return font.deriveFont(Font.BOLD);
}
};
entryFields.add(keyEditField);
keyEditField.setHorizontalAlignment(SwingConstants.RIGHT);
keyEditField.setFont(keyEditField.getDefaultFont());
valueEditField = new MetadataEditField(0) {
protected String getDefaultText() {
return metadata==emptyMetadata? ToolsRes.getString("LibraryTreePanel.Metadata.Value"): null; //$NON-NLS-1$
}
protected Font getEmptyFont() {
return font.deriveFont(Font.ITALIC);
}
protected Font getDefaultFont() {
return font.deriveFont(Font.PLAIN);
}
};
entryFields.add(valueEditField);
Border border = BorderFactory.createCompoundBorder(keyEditField.getBorder(), BorderFactory.createEmptyBorder(0, 1, 0, 1));
keyEditField.setBorder(border);
valueEditField.setBorder(border);
spacer = new JLabel();
spacer.setBorder(BorderFactory.createEmptyBorder(0, 2, 0, 2));
add(keyEditField);
add(spacer);
add(valueEditField);
}
private BoxLayout getBoxLayout() {
boxLayout = new BoxLayout(getJPanel2(), BoxLayout.X_AXIS);
return boxLayout;
}
protected Box createInstanceImpl() {
return new Box(BoxLayout.X_AXIS) {
public void layout() {}
public void setLayout(LayoutManager l) {}
};
}