本文整理了Java中javax.swing.Box
类的一些代码示例,展示了Box
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Box
类的具体详情如下:
包路径:javax.swing.Box
类名称:Box
暂无
代码示例来源:origin: stackoverflow.com
import javax.swing.*;
public class JOptionPaneMultiInput {
public static void main(String[] args) {
JTextField xField = new JTextField(5);
JTextField yField = new JTextField(5);
JPanel myPanel = new JPanel();
myPanel.add(new JLabel("x:"));
myPanel.add(xField);
myPanel.add(Box.createHorizontalStrut(15)); // a spacer
myPanel.add(new JLabel("y:"));
myPanel.add(yField);
int result = JOptionPane.showConfirmDialog(null, myPanel,
"Please Enter X and Y Values", JOptionPane.OK_CANCEL_OPTION);
if (result == JOptionPane.OK_OPTION) {
System.out.println("x value: " + xField.getText());
System.out.println("y value: " + yField.getText());
}
}
}
代码示例来源:origin: skylot/jadx
@NotNull
protected JPanel initButtonsPanel() {
progressPane = new ProgressPanel(mainWindow, false);
JButton cancelButton = new JButton(NLS.str("search_dialog.cancel"));
cancelButton.addActionListener(event -> dispose());
JButton openBtn = new JButton(NLS.str("search_dialog.open"));
openBtn.addActionListener(event -> openSelectedItem());
getRootPane().setDefaultButton(openBtn);
JPanel buttonPane = new JPanel();
buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS));
buttonPane.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10));
buttonPane.add(progressPane);
buttonPane.add(Box.createRigidArea(new Dimension(5, 0)));
buttonPane.add(Box.createHorizontalGlue());
buttonPane.add(openBtn);
buttonPane.add(Box.createRigidArea(new Dimension(10, 0)));
buttonPane.add(cancelButton);
return buttonPane;
}
代码示例来源:origin: stanfordnlp/CoreNLP
private JPanel makeFoundStatsBox() {
JPanel foundStatsBox = new JPanel();
foundStatsBox.setLayout(new GridBagLayout());
Box labelBox = Box.createHorizontalBox();
foundStats = new JLabel(" ");
labelBox.add(foundStats);
historyButton = new JButton("Statistics");
historyButton.setEnabled(false);
historyButton.addActionListener(this);
GridBagConstraints c = new GridBagConstraints();
c.fill = GridBagConstraints.BOTH;
c.weightx = 1.7;
foundStatsBox.add(labelBox,c);
c.weightx = .3;
c.gridwidth = 1;
foundStatsBox.add(historyButton);
return foundStatsBox;
}
代码示例来源:origin: stanfordnlp/CoreNLP
private static Box getNewFilter() {
Box filter = Box.createHorizontalBox();
FilterType[] filterTypeOptions = FilterType.values();
JComboBox filterTypes = new JComboBox(filterTypeOptions );
filterTypes.setEditable(false);
filter.add(filterTypes);
filter.add(Box.createHorizontalGlue());
JTextField filterInput = new JTextField();
//filterInput.setMaximumSize(new Dimension(50,50));
filterInput.setEditable(true);
filter.add(filterInput);
return filter;
}
代码示例来源:origin: stanfordnlp/CoreNLP
private Box makeTSurgeonScriptArea() {
Box tsurgeonBox = Box.createHorizontalBox();
scriptLabel = new JLabel("Tsurgeon script: ");
tsurgeonScript = new JTextArea();
tsurgeonScript.setBorder(BorderFactory.createEmptyBorder());
tsurgeonScript.setFocusTraversalKeysEnabled(true);
JScrollPane scriptScroller = new JScrollPane(tsurgeonScript);
scriptScroller.setBorder(BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
//scriptScroller.setEnabled(tsurgeonEnabled);
tsurgeonBox.add(scriptLabel);
tsurgeonBox.add(scriptScroller);
//tsurgeonBox.setBorder(BorderFactory.createEtchedBorder());
return tsurgeonBox;
}
代码示例来源:origin: nodebox/nodebox
setLayout(new BorderLayout(5, 5));
JPanel mainPanel = new JPanel();
mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.PAGE_AXIS));
mainPanel.setBorder(new Theme.InsetsBorder(10, 10, 10, 10));
add(mainPanel, BorderLayout.CENTER);
filePanel.add(new JLabel("File: "));
fileField = new JTextField(20);
JButton chooseButton = new JButton("...");
chooseButton.putClientProperty("JButton.buttonType", "gradient");
chooseButton.setPreferredSize(new Dimension(30, 27));
mainPanel.add(Box.createVerticalStrut(10));
formatPanel.add(new JLabel("Format/Device: "));
mainPanel.add(Box.createVerticalStrut(10));
rangePanel.add(new JLabel("From:"));
mainPanel.add(Box.createVerticalGlue());
mainPanel.add(Box.createVerticalStrut(10));
代码示例来源:origin: nodebox/nodebox
JPanel iconPanel = new JPanel();
iconPanel.setLayout(new BoxLayout(iconPanel, BoxLayout.Y_AXIS));
icon.paintIcon(this, g, 0, 0);
ImageIcon scaledIcon = new ImageIcon(img);
JLabel iconLabel = new JLabel(scaledIcon);
iconPanel.add(Box.createVerticalGlue());
controlsPanel.setLayout(new BoxLayout(controlsPanel, BoxLayout.Y_AXIS));
controlsPanel.setMaximumSize(new Dimension(Short.MAX_VALUE, Short.MAX_VALUE));
JLabel alert = new JLabel("<html><b>Checking for Updates...</b></html>");
alert.setAlignmentX(Component.LEFT_ALIGNMENT);
alert.setPreferredSize(new Dimension(Short.MAX_VALUE, 80));
controlsPanel.add(Box.createVerticalStrut(5));
controlsPanel.add(Box.createVerticalStrut(5));
buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS));
JButton cancelButton = new JButton("Cancel");
cancelButton.addActionListener(this);
buttonPanel.add(Box.createHorizontalGlue());
代码示例来源:origin: stanfordnlp/CoreNLP
private void doEncodingPrompt(final String encoding, final String oldEncoding) {
final JPanel encodingPanel = new JPanel();
encodingPanel.setLayout(new BoxLayout(encodingPanel, BoxLayout.PAGE_AXIS));
JLabel text = new JLabel("<html>A head finder or tree reader was selected that has the default encoding " + encoding
+ "; this differs from " + oldEncoding + ", which was being used. If the encoding is changed, all newly loaded" +
"treebanks will be read using the new encoding. Choosing an encoding that is not the true encoding of your tree " +
"files may cause errors and unexpected behavior.</html>");
text.setAlignmentX(SwingConstants.LEADING);
JPanel textPanel = new JPanel(new BorderLayout());
textPanel.setPreferredSize(new Dimension(100,100));
textPanel.add(text);
encodingPanel.add(textPanel);
encodingPanel.add(Box.createVerticalStrut(5));
final JOptionPane fileFilterDialog = new JOptionPane();
fileFilterDialog.setMessage(encodingPanel);
JButton[] options = new JButton[3];
JButton useNewEncoding = new JButton("Use " + encoding);
JButton useOldEncoding = new JButton("Use " + oldEncoding);
JButton useAnotherEncoding = new JButton("Use encoding...");
代码示例来源:origin: redwarp/9-Patch-Resizer
private JPanel createInputPanel() {
JPanel inputPanel = new JPanel();
inputPanel.setPreferredSize(new Dimension(10, 140));
JPanel optionPanel = new JPanel();
optionPanel.setLayout(new BoxLayout(optionPanel, BoxLayout.PAGE_AXIS));
optionPanel.add(Box.createVerticalGlue());
optionPanel.add(inputDensityChoice);
optionPanel.add(Box.createVerticalGlue());
JLabel outputLabel = new JLabel(Localization.get("output_density"));
optionPanel.add(box);
optionPanel.add(Box.createVerticalGlue());
optionPanel.add(keepDensity);
optionPanel.add(Box.createVerticalGlue());
final JButton saveButton = new JButton(Localization.get("save"));
saveButton.setToolTipText(Localization.get("save_tooltip"));
optionPanel.add(saveButton);
optionPanel.add(Box.createVerticalGlue());
optionPanel.setBorder(BorderFactory
代码示例来源:origin: nodebox/nodebox
public PreferencesDialog() {
super((Frame) null, "Preferences");
setLocationRelativeTo(null);
JPanel rootPanel = new JPanel();
rootPanel.setLayout(new BoxLayout(rootPanel, BoxLayout.Y_AXIS));
rootPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
JLabel label = new JLabel("<html><i>No preferences yet.</i></html>");
rootPanel.add(label);
rootPanel.add(Box.createVerticalStrut(10));
JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.TRAILING, 10, 10));
JButton cancelButton = new JButton("Cancel");
cancelButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent actionEvent) {
doCancel();
buttonPanel.add(cancelButton);
rootPanel.add(buttonPanel);
JButton saveButton = new JButton("Save");
saveButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent actionEvent) {
代码示例来源:origin: skylot/jadx
public final void initUI() {
Font font = new Font("Serif", Font.BOLD, 13);
JLabel name = new JLabel("jadx");
name.setFont(font);
name.setAlignmentX(0.5f);
JLabel desc = new JLabel("Dex to Java decompiler");
version.setAlignmentX(0.5f);
JPanel textPane = new JPanel();
textPane.setBorder(BorderFactory.createEmptyBorder(15, 15, 15, 15));
textPane.setLayout(new BoxLayout(textPane, BoxLayout.PAGE_AXIS));
textPane.add(Box.createRigidArea(new Dimension(0, 10)));
textPane.add(name);
textPane.add(Box.createRigidArea(new Dimension(0, 10)));
textPane.add(desc);
textPane.add(Box.createRigidArea(new Dimension(0, 10)));
textPane.add(version);
textPane.add(Box.createRigidArea(new Dimension(0, 20)));
JButton close = new JButton(NLS.str("tabs.close"));
close.addActionListener(event -> dispose());
close.setAlignmentX(0.5f);
代码示例来源:origin: runelite/runelite
setLayout(new BorderLayout());
final JPanel layoutPanel = new JPanel();
layoutPanel.setLayout(new BoxLayout(layoutPanel, BoxLayout.Y_AXIS));
add(layoutPanel, BorderLayout.NORTH);
actionsContainer.setLayout(new BorderLayout());
actionsContainer.setBackground(ColorScheme.DARKER_GRAY_COLOR);
actionsContainer.setPreferredSize(new Dimension(0, 30));
actionsContainer.setBorder(new EmptyBorder(5, 5, 5, 10));
actionsContainer.setVisible(false);
viewControls.setBackground(ColorScheme.DARKER_GRAY_COLOR);
singleLootBtn.setIcon(SINGLE_LOOT_VIEW);
singleLootBtn.setToolTipText("Show each kill separately");
singleLootBtn.addMouseListener(new MouseAdapter()
changeItemHiding(true);
final JPanel leftTitleContainer = new JPanel(new BorderLayout(5, 0));
leftTitleContainer.setBackground(ColorScheme.DARKER_GRAY_COLOR);
logsContainer.setLayout(new BoxLayout(logsContainer, BoxLayout.Y_AXIS));
layoutPanel.add(actionsContainer);
layoutPanel.add(Box.createRigidArea(new Dimension(0, 5)));
layoutPanel.add(overallPanel);
layoutPanel.add(logsContainer);
代码示例来源:origin: apache/pdfbox
private void createView()
panel.setLayout(new GridBagLayout());
panel.setPreferredSize(new Dimension(300, 500));
JLabel flagLabel = new JLabel(flagHeader);
flagLabel.setAlignmentX(Component.CENTER_ALIGNMENT);
flagLabel.setFont(new Font(Font.MONOSPACED, Font.BOLD, 30));
JPanel flagLabelPanel = new JPanel();
flagLabelPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
flagLabelPanel.add(flagLabel);
scrollPane.setAlignmentX(Component.LEFT_ALIGNMENT);
Box box = Box.createVerticalBox();
box.add(flagValueLabel);
box.add(scrollPane);
box.setAlignmentX(Component.LEFT_ALIGNMENT);
代码示例来源:origin: geotools/geotools
JButton cancelButton = new JButton("Cancel");
cancelButton.addActionListener(this);
final JButton setButton = new JButton("Select");
setButton.setActionCommand("Select");
setButton.addActionListener(this);
listScroller.setPreferredSize(new Dimension(400, 280));
JPanel listPane = new JPanel();
listPane.setLayout(new BoxLayout(listPane, BoxLayout.PAGE_AXIS));
JLabel label = new JLabel("Layers");
label.setLabelFor(list);
listPane.add(label);
listPane.add(Box.createRigidArea(new Dimension(0, 5)));
listPane.add(listScroller);
listPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
JPanel buttonPane = new JPanel();
buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS));
buttonPane.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10));
buttonPane.add(Box.createHorizontalGlue());
buttonPane.add(cancelButton);
buttonPane.add(Box.createRigidArea(new Dimension(10, 0)));
buttonPane.add(setButton);
代码示例来源:origin: apache/pdfbox
searchField.getDocument().addDocumentListener(documentListener);
counterLabel = new JLabel();
counterLabel.setVisible(false);
JButton nextButton = new JButton();
nextButton.setAction(nextAction);
nextButton.setText("Next");
JButton previousButton = new JButton();
closeAction.setEnabled(false);
panel = new JPanel();
panel.setBorder(BorderFactory.createMatteBorder(1, 0, 0, 0, Color.LIGHT_GRAY));
panel.setBackground(new Color(230, 230, 230));
panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
panel.add(Box.createHorizontalGlue());
panel.add(searchField);
panel.add(counterLabel);
panel.add(nextButton);
panel.add(caseSensitive);
panel.add(Box.createRigidArea(new Dimension(5, 0)));
panel.add(crossButton);
代码示例来源:origin: jshiell/checkstyle-idea
public void initialise() {
setLayout(new BorderLayout());
setMinimumSize(new Dimension(WIDTH, HEIGHT));
setModal(true);
commitButton = new JButton(new NextAction());
previousButton = new JButton(new PreviousAction());
final JButton cancelButton = new JButton(new CancelAction());
final JPanel bottomPanel = new JPanel(new GridBagLayout());
bottomPanel.setBorder(JBUI.Borders.empty(4, 8, 8, 8));
bottomPanel.add(cancelButton, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,
GridBagConstraints.WEST, GridBagConstraints.NONE, COMPONENT_INSETS, 0, 0));
bottomPanel.add(Box.createHorizontalGlue(), new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0,
GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, COMPONENT_INSETS, 0, 0));
} else {
bottomPanel.add(Box.createHorizontalGlue(), new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0,
GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, COMPONENT_INSETS, 0, 0));
bottomPanel.add(cancelButton, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0,
代码示例来源:origin: nodebox/nodebox
final JPanel formatPanel = new JPanel(new FlowLayout(FlowLayout.LEADING, 10, 10));
formatPanel.add(new JLabel("Format:"));
formatBox = new JComboBox<>();
formatBox.addItem("SVG");
final JPanel delimiterPanel = new JPanel(new FlowLayout(FlowLayout.LEADING, 10, 10));
delimiterPanel.add(new JLabel("Delimiter:"));
delimiterBox = new JComboBox<>();
delimiterBox.addItem(new Delimiter(',', ","));
final JPanel quotesPanel = new JPanel(new FlowLayout(FlowLayout.LEADING, 10, 10));
quotesPanel.add(new JLabel("Quotes:"));
quotesBox = new JCheckBox("Escape output using quotes", true);
quotesPanel.add(quotesBox);
quotesPanel.setVisible(false);
mainPanel.add(Box.createVerticalGlue());
mainPanel.add(Box.createVerticalStrut(10));
JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.TRAILING, 10, 0));
JButton cancelButton = new JButton("Cancel");
cancelButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
代码示例来源:origin: skylot/jadx
private void initUI() {
JLabel findLabel = new JLabel(NLS.str("search_dialog.open_by_name"));
searchField = new JTextField();
searchField.setAlignmentX(LEFT_ALIGNMENT);
JCheckBox codeChBox = makeOptionsCheckBox(NLS.str("search_dialog.code"), SearchOptions.CODE);
JPanel searchInPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
searchInPanel.setBorder(BorderFactory.createTitledBorder(NLS.str("search_dialog.search_in")));
searchInPanel.add(clsChBox);
searchInPanel.add(mthChBox);
searchInPanel.add(fldChBox);
searchOptions.add(caseChBox);
Box box = Box.createHorizontalBox();
box.setAlignmentX(LEFT_ALIGNMENT);
box.add(searchInPanel);
box.add(searchOptions);
JPanel searchPane = new JPanel();
searchPane.setLayout(new BoxLayout(searchPane, BoxLayout.PAGE_AXIS));
findLabel.setLabelFor(searchField);
searchPane.add(findLabel);
searchPane.add(Box.createRigidArea(new Dimension(0, 5)));
searchPane.add(searchField);
searchPane.add(Box.createRigidArea(new Dimension(0, 5)));
searchPane.add(box);
searchPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
代码示例来源:origin: nodebox/nodebox
public AudioInputDeviceControl(AudioInputDeviceHandler deviceHandler) {
super(deviceHandler);
setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
deviceNameLabel = new JLabel(deviceHandler.getName());
add(Box.createHorizontalStrut(10));
add(deviceNameLabel);
add(Box.createHorizontalStrut(5));
stopButton = new JButton("Stop");
stopButton.addActionListener(new ActionListener() {
@Override
JPanel startStopPanel = new JPanel();
startStopPanel.setLayout(new BoxLayout(startStopPanel, BoxLayout.X_AXIS));
startStopPanel.add(syncWithTimelineCheck);
startStopPanel.add(Box.createHorizontalStrut(5));
startStopPanel.add(startButton);
startStopPanel.add(Box.createHorizontalStrut(5));
startStopPanel.add(stopButton);
startStopPanel.add(Box.createHorizontalGlue());
JPanel mainPanel = new JPanel();
mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
mainPanel.add(startStopPanel);
add(Box.createHorizontalGlue());
代码示例来源:origin: stanfordnlp/CoreNLP
Box displayPrefs = Box.createVerticalBox();
displayPrefs.setBorder(BorderFactory.createTitledBorder("Display"));
JPanel displayOptions = new JPanel();
displayOptions.setLayout(new GridLayout(3,2,0,2));
displayOptions.add(historySizeField);
displayOptions.add(maxMatchesSizeField);
JLabel highlightLabel = new JLabel("Highlight color:");
highlightButton = makeColorButton("Pick a new highlight color: ",
Preferences.getHighlightColor(), prefPanel);
highlightButton.putClientProperty("JButton.buttonType","icon");
displayOptions.add(highlightLabel);
displayOptions.add(highlightButton);
displayPrefs.add(displayOptions);
Box treeDisplayPrefs = Box.createVerticalBox();
treeDisplayPrefs.setBorder(BorderFactory.createTitledBorder("Tree Display"));
JPanel treeDisplayOptions = new JPanel();
treeDisplayOptions.setLayout(new GridLayout(4,2));
treeDisplayPrefs.add(treeDisplayOptions);
JButton okay = new JButton("Okay");
JButton cancel = new JButton("Cancel");
内容来源于网络,如有侵权,请联系作者删除!