Java Code Examples for javax.swing.Box#add()

The following examples show how to use javax.swing.Box#add() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LanguageTableModel.java    From pcgen with GNU Lesser General Public License v2.1 6 votes vote down vote up
public Renderer()
{
	setLayout(cardLayout);
	Box box = Box.createHorizontalBox();
	box.add(Box.createHorizontalStrut(3));
	box.add(cellLabel);
	box.add(Box.createHorizontalGlue());
	box.add(removeButton);
	box.add(Box.createHorizontalStrut(2));
	add(box, REMOVE_ID);

	box = Box.createHorizontalBox();
	box.add(Box.createHorizontalGlue());
	box.add(addLabel);
	box.add(Box.createHorizontalStrut(3));
	box.add(addButton);
	box.add(Box.createHorizontalStrut(2));
	add(box, ADD_ID);
}
 
Example 2
Source File: KitSelectionDialog.java    From pcgen with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void initComponents()
{
	Container pane = getContentPane();
	pane.setLayout(new BorderLayout());

	pane.add(kitPanel, BorderLayout.CENTER);

	Button closeButton = new Button(LanguageBundle.getString("in_close"));
	closeButton.setOnAction(this::onClose);

	Box buttons = Box.createHorizontalBox();
	buttons.add(GuiUtility.wrapParentAsJFXPanel(closeButton));
	pane.add(buttons, BorderLayout.PAGE_END);

	Utility.installEscapeCloseOperation(this);
}
 
Example 3
Source File: ReplayInfoBox.java    From sc2gears with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a new ReplayInfoBox.
 * @param file replay file to be initially set.
 */
public ReplayInfoBox( final File file ) {
	final Box box = Box.createVerticalBox();
	box.setBorder( BorderFactory.createTitledBorder( Language.getText( "module.repAnalyzer.tab.gameInfo.title" ) ) );
	
	box.add( versionLabel );
	box.add( dateLabel );
	box.add( lengthLabel );
	box.add( speedLabel );
	box.add( typeLabel );
	box.add( formatLabel );
	box.add( gatewayLabel );
	box.add( mapLabel );
	box.add( playersLabel );
	box.add( mapPreviewLabel );
	
	box.setPreferredSize( new Dimension( 300, 440 ) );
	
	setViewportView( box );
	
	if ( file != null )
		setReplayFile( file );
}
 
Example 4
Source File: HubFrame.java    From HubPlayer with GNU General Public License v3.0 6 votes vote down vote up
private void buildLayout() {
	Box topBox = Box.createHorizontalBox();

	topBox.add(playPanel);
	topBox.add(searchPanel);

	Box bottomBox = Box.createHorizontalBox();
	bottomBox.add(toolBar);
	bottomBox.add(playListPanel);
	bottomBox.add(showPanel);

	Container mainPanel = getContentPane();
	mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));

	mainPanel.add(topBox);
	mainPanel.add(bottomBox);
	mainPanel.add(Box.createVerticalStrut(15));
}
 
Example 5
Source File: FrameDemo.java    From littleluck with Apache License 2.0 6 votes vote down vote up
protected JComponent createControlPanel() {
    Box controlPanel = Box.createVerticalBox();
    controlPanel.setBorder(new EmptyBorder(8, 8, 8, 8));

    // Create button to control visibility of frame
    JButton showButton = new JButton("Show JFrame...");
    showButton.addActionListener(new ShowActionListener());
    controlPanel.add(showButton);

    // Create checkbox to control busy state of frame
    JCheckBox busyCheckBox = new JCheckBox("Frame busy");
    busyCheckBox.setSelected(false);
    busyCheckBox.addChangeListener(new BusyChangeListener());
    controlPanel.add(busyCheckBox);

    return controlPanel;
}
 
Example 6
Source File: InstallerGUI.java    From EasyMPermission with MIT License 6 votes vote down vote up
void addLocation(final IdeLocation location) {
	if (locations.contains(location)) return;
	Box box = Box.createHorizontalBox();
	box.setBackground(Color.WHITE);
	final JCheckBox checkbox = new JCheckBox(location.getName());
	checkbox.setBackground(Color.WHITE);
	box.add(new JLabel(new ImageIcon(location.getIdeIcon())));
	box.add(checkbox);
	checkbox.setSelected(true);
	checkbox.addActionListener(new ActionListener() {
		@Override public void actionPerformed(ActionEvent e) {
			location.selected = checkbox.isSelected();
			fireSelectionChange();
		}
	});
	
	if (location.hasLombok()) {
		box.add(new JLabel(new ImageIcon(Installer.class.getResource("lombokIcon.png"))));
	}
	box.add(Box.createHorizontalGlue());
	locations.add(location);
	add(box);
	getParent().doLayout();
	fireSelectionChange();
}
 
Example 7
Source File: OperationMouseAdapter.java    From cstc with GNU General Public License v3.0 5 votes vote down vote up
private Container createPreview(String title) {
	Box previewBox = Box.createHorizontalBox();
	previewBox.setOpaque(true);
	previewBox.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
	previewBox.setBackground(new Color(127, 237, 247, 255));

	JLabel previewLbl = new JLabel(title);
	previewLbl.setForeground(new Color(58, 135, 173));

	previewBox.add(previewLbl);
	return previewBox;
}
 
Example 8
Source File: BoxLayoutBuilder.java    From triplea with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Adds {@code component} to the panel and ensures it will be left-justified in the final layout.
 * Primarily for use with vertical box layouts.
 */
public BoxLayoutBuilder addLeftJustified(final Component component) {
  final Box box = Box.createHorizontalBox();
  box.add(component);
  box.add(Box.createHorizontalGlue());
  components.add(box);
  return this;
}
 
Example 9
Source File: SymmetryGui.java    From biojava with GNU Lesser General Public License v2.1 5 votes vote down vote up
private Box setupAlgorithm() {

		String[] algorithms = {"JCE-symmetry"};
		JLabel algoLabel = new JLabel("Symmetry algorithm: ");

		JComboBox algorithmList = new JComboBox(algorithms);
		algorithmList.setSelectedIndex(0);

		Action paramAction = new AbstractAction("Parameters") {
			public static final long serialVersionUID = 0l;
			// This method is called when the button is pressed
			@Override
			public void actionPerformed(ActionEvent evt) {
				// Perform action...
				configureParameters();
			}
		};

		JButton parameterButton = new JButton(paramAction);

		Box hBoxAlgo = Box.createHorizontalBox();
		hBoxAlgo.add(Box.createGlue());
		hBoxAlgo.add(algoLabel);
		hBoxAlgo.add(algorithmList);
		hBoxAlgo.add(Box.createGlue());
		hBoxAlgo.add(parameterButton);
		hBoxAlgo.add(Box.createGlue());
		return hBoxAlgo;
	}
 
Example 10
Source File: TimeLeftDialog.java    From FancyBing with GNU General Public License v3.0 5 votes vote down vote up
private TimeLeftDialog(ConstClock clock)
{
    Box box = Box.createVerticalBox();
    m_white = createPlayerTime(WHITE, clock);
    m_white.m_box.setAlignmentX(Component.LEFT_ALIGNMENT);
    box.add(m_white.m_box);
    box.add(GuiUtil.createFiller());
    m_black = createPlayerTime(BLACK, clock);
    m_black.m_box.setAlignmentX(Component.LEFT_ALIGNMENT);
    box.add(m_black.m_box);
    setMessage(box);
    setOptionType(OK_CANCEL_OPTION);
}
 
Example 11
Source File: SimpleTextEditDialog.java    From LoboBrowser with MIT License 5 votes vote down vote up
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;
}
 
Example 12
Source File: LanguageTableModel.java    From pcgen with GNU Lesser General Public License v2.1 5 votes vote down vote up
public Editor()
{
	cellPanel.setLayout(cardLayout);
	cellPanel.setOpaque(true);

	JButton addButton = Utilities.createSignButton(Sign.Plus);
	JButton removeButton = Utilities.createSignButton(Sign.Minus);
	addButton.setActionCommand(ADD_ID);
	removeButton.setActionCommand(REMOVE_ID);
	addButton.setFocusable(false);
	removeButton.setFocusable(false);
	addButton.addActionListener(this);
	removeButton.addActionListener(this);
	Box box = Box.createHorizontalBox();
	box.add(Box.createHorizontalGlue());
	box.add(addLabel);
	box.add(Box.createHorizontalStrut(3));
	box.add(addButton);
	box.add(Box.createHorizontalStrut(2));
	cellPanel.add(box, ADD_ID);

	box = Box.createHorizontalBox();
	box.add(Box.createHorizontalStrut(3));
	box.add(cellLabel);
	box.add(Box.createHorizontalGlue());
	box.add(removeButton);
	box.add(Box.createHorizontalStrut(2));
	cellPanel.add(box, REMOVE_ID);
}
 
Example 13
Source File: UiUtil.java    From intellij with Apache License 2.0 5 votes vote down vote up
public static Box createHorizontalBox(int gap, Iterable<Component> components) {
  Box box = Box.createHorizontalBox();
  for (Component component : components) {
    box.add(component);
    box.add(Box.createRigidArea(new Dimension(gap, 0)));
  }
  return box;
}
 
Example 14
Source File: TomatoKNNClassifierDemo.java    From COMP3204 with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public Component getComponent(final int width, final int height) throws IOException {
	points = new ArrayList<double[]>();
	classes = new ArrayList<Integer>();
	k = 1;

	circle = new Circle(VIDEO_WIDTH / 2, VIDEO_HEIGHT / 2, VIDEO_HEIGHT / 8);

	vc = new VideoCaptureComponent(VIDEO_WIDTH, VIDEO_HEIGHT);

	vc.getDisplay().addVideoListener(this);

	// the main panel
	final JPanel base = new JPanel() {
		private static final long serialVersionUID = 1L;

		@Override
		protected void paintComponent(Graphics g) {
			((Graphics2D) g).setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);

			super.paintComponent(g);

			if (bgImage != null)
				g.drawImage(bgImage, 0, 0, width, height, null);
		}
	};
	base.setOpaque(false);
	base.setPreferredSize(new Dimension(width, height));
	base.setLayout(new GridBagLayout());

	// left hand side (video, features)
	final Box videoCtrls = Box.createVerticalBox();
	videoCtrls.add(vc);
	videoCtrls.add(Box.createVerticalStrut(10));
	final JPanel colourspacesPanel = createColourSpaceButtons();
	videoCtrls.add(colourspacesPanel);
	createFeatureField();
	videoCtrls.add(Box.createVerticalStrut(10));
	videoCtrls.add(featureField);
	base.add(videoCtrls);

	// right hand box
	final Box rightPanel = Box.createVerticalBox();
	rightPanel.setOpaque(false);

	guess = new JTextField(8);
	guess.setOpaque(false);
	guess.setFont(Font.decode("Monaco-48"));
	guess.setHorizontalAlignment(JTextField.CENTER);
	guess.setEditable(false);
	rightPanel.add(guess);

	image = new MBFImage(GRAPH_WIDTH, GRAPH_HEIGHT, ColourSpace.RGB);
	image.fill(RGBColour.WHITE);
	imageComp = new DisplayUtilities.ImageComponent(true, false);
	imageComp.setShowPixelColours(false);
	imageComp.setShowXYPosition(false);
	imageComp.setAllowZoom(false);
	imageComp.setAllowPanning(false);
	rightPanel.add(imageComp);
	final JPanel classCtrlsCnt = new JPanel(new GridLayout(1, 2));
	classCtrlsCnt.setOpaque(false);

	// learning controls
	final JPanel learnCtrls = new JPanel(new GridLayout(0, 1));
	learnCtrls.setOpaque(false);
	classType = new JComboBox<String>();
	for (final String c : CLASSES)
		classType.addItem(c);
	learnCtrls.add(classType);
	final JButton learnButton = new JButton("Learn");
	learnButton.setActionCommand("button.learn");
	learnButton.addActionListener(this);
	learnCtrls.add(learnButton);
	classCtrlsCnt.add(learnCtrls);

	// classification controls
	final JPanel classCtrls = new JPanel(new GridLayout(0, 1));
	classCtrls.setOpaque(false);
	final JPanel cnt = new JPanel();
	cnt.setOpaque(false);
	cnt.add(new JLabel("K:"));
	final JSpinner kField = new JSpinner(new SpinnerNumberModel(k, 1, 10, 1));
	kField.addChangeListener(this);
	cnt.add(kField);
	classCtrls.add(cnt);
	classCtrlsCnt.add(classCtrls);

	rightPanel.add(classCtrlsCnt);

	base.add(rightPanel);

	redraw();
	return base;
}
 
Example 15
Source File: ColorPropertiesPanel.java    From bigtable-sql with Apache License 2.0 4 votes vote down vote up
private Box createInfoPanel()
{
	final Box pnl = new Box(BoxLayout.X_AXIS);
	pnl.add(new MultipleLineLabel(i18n.INSTRUCTIONS));
	return pnl;
}
 
Example 16
Source File: PrintPreviewDialog.java    From pcgen with GNU Lesser General Public License v2.1 4 votes vote down vote up
private void initLayout()
{
	Container pane = getContentPane();
	pane.setLayout(new BorderLayout());
	{//layout top bar
		JPanel bar = new JPanel(new GridBagLayout());
		GridBagConstraints gbc = new GridBagConstraints();
		gbc.fill = GridBagConstraints.HORIZONTAL;
		gbc.anchor = GridBagConstraints.BASELINE;
		gbc.insets = new Insets(8, 6, 8, 2);
		bar.add(new JLabel("Select Template:"), gbc);
		gbc.insets = new Insets(8, 2, 8, 6);
		gbc.weightx = 1;
		bar.add(sheetBox, gbc);
		pane.add(bar, BorderLayout.NORTH);
	}
	{
		Box vbox = Box.createVerticalBox();
		previewPanelParent.setPreferredSize(new Dimension(600, 800));
		vbox.add(previewPanelParent);
		vbox.add(progressBar);
		pane.add(vbox, BorderLayout.CENTER);
	}
	{
		Box hbox = Box.createHorizontalBox();
		hbox.add(new JLabel("Page:"));
		hbox.add(Box.createHorizontalStrut(4));
		hbox.add(pageBox);
		hbox.add(Box.createHorizontalStrut(10));
		hbox.add(new JLabel("Zoom:"));
		hbox.add(Box.createHorizontalStrut(4));
		hbox.add(zoomBox);
		hbox.add(Box.createHorizontalStrut(5));
		hbox.add(zoomInButton);
		hbox.add(Box.createHorizontalStrut(5));
		hbox.add(zoomOutButton);
		hbox.add(Box.createHorizontalGlue());
		hbox.add(printButton);
		hbox.add(Box.createHorizontalStrut(5));
		hbox.add(cancelButton);
		hbox.setBorder(BorderFactory.createEmptyBorder(8, 5, 8, 5));
		pane.add(hbox, BorderLayout.SOUTH);
	}
}
 
Example 17
Source File: SelectPDBPanel.java    From biojava with GNU Lesser General Public License v2.1 4 votes vote down vote up
private Box getPDBFilePanel(int pos ,JTextField f, JTextField c, JTextField r){

		//JPanel panel = new JPanel();
		//panel.setBorder(BorderFactory.createLineBorder(Color.black));

		JLabel l01 = new JLabel("PDB code ");

		//panel.add(l01);
		Box hBox = Box.createHorizontalBox();
		hBox.add(Box.createGlue());
		hBox.add(l01);

		JLabel l11 = new JLabel(pos + ":");
		f.setMaximumSize(new Dimension(Short.MAX_VALUE,30));
		f.setToolTipText("Provide 4-character PDB code here. Example: 4hhb");
		hBox.add(l11);
		hBox.add(Box.createVerticalGlue());
		hBox.add(f, BorderLayout.CENTER);
		hBox.add(Box.createGlue());

		//panel.add(hBox11);

		//Box hBox21 = Box.createHorizontalBox();
		JLabel l21 = new JLabel("Chain" + pos + ":");
		hBox.add(l21);

		c.setMaximumSize(new Dimension(Short.MAX_VALUE,30));
		//hBox.add(Box.createGlue());
		hBox.add(c, BorderLayout.CENTER);

		String msg1 = "Both chainID and range specification are optional. If both are provided, range has preference.";
		l21.setToolTipText(msg1);
		c.setToolTipText(msg1);

		JLabel rangeL = new JLabel(" Range " + pos + ":");
		hBox.add(Box.createGlue());
		hBox.add(rangeL);
		r.setMaximumSize(new Dimension(Short.MAX_VALUE,30));

		// set help text:
		String msg ="Syntax example: A:407-495,A:582-686";
		rangeL.setToolTipText(msg);
		r.setToolTipText(msg);

		//hBox.add(Box.createGlue());
		hBox.add(r,BorderLayout.CENTER);

		//hBox21.add(Box.createGlue());

		//panel.add(hBox21);



		return hBox;
	}
 
Example 18
Source File: RecipeStepPanel.java    From cstc with GNU General Public License v3.0 4 votes vote down vote up
public RecipeStepPanel(String title, ChangeListener changelistener) {
	this.changeListener = changelistener;
	this.setLayout(new BorderLayout());
	this.setPreferredSize(new Dimension(300, 0));

	// header
	Box headerBox = Box.createHorizontalBox();
	// add borders
	Border margin = BorderFactory.createEmptyBorder(10, 10, 10, 10);
	MatteBorder lineBorder = new MatteBorder(0, 0, 2, 0, Color.DARK_GRAY);
	CompoundBorder border = new CompoundBorder(lineBorder, margin);
	headerBox.setBorder(border);

	JTextField contentTextField = new JTextField();
	contentTextField.setBorder(null);
	contentTextField.setBackground(new Color(0, 0, 0, 0));
	contentTextField.setText(title);
	headerBox.add(contentTextField);

	this.add(headerBox, BorderLayout.NORTH);

	// body
	operationsLine = new JPanel(new GridBagLayout());

	GridBagConstraints gbc = new GridBagConstraints();
	gbc.gridwidth = GridBagConstraints.REMAINDER;
	gbc.gridheight = GridBagConstraints.REMAINDER;
	gbc.weightx = 1;
	gbc.weighty = 1;
	gbc.fill = GridBagConstraints.BOTH;

	JPanel dummyPanel = new JPanel();
	operationsLine.add(dummyPanel, gbc);

	this.addContraints = new GridBagConstraints();
	this.addContraints.gridwidth = GridBagConstraints.REMAINDER;
	this.addContraints.weightx = 1;
	this.addContraints.fill = GridBagConstraints.HORIZONTAL;

	JScrollPane scrollPane = new JScrollPane(operationsLine);
	scrollPane.setBorder(new MatteBorder(0, 2, 0, 0, Color.DARK_GRAY));
	scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
	scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
	scrollPane.getVerticalScrollBar().setUnitIncrement(16);

	this.add(scrollPane, BorderLayout.CENTER);
}
 
Example 19
Source File: TemplateInfoTab.java    From pcgen with GNU Lesser General Public License v2.1 4 votes vote down vote up
private void initComponents()
{
	FlippingSplitPane topPane = new FlippingSplitPane();
	setTopComponent(topPane);
	setOrientation(VERTICAL_SPLIT);

	JPanel availPanel = new JPanel(new BorderLayout());
	FilterBar<CharacterFacade, PCTemplate> bar = new FilterBar<>();
	bar.addDisplayableFilter(new SearchFilterPanel());
	qFilterButton.setText(LanguageBundle.getString("in_igQualFilter")); //$NON-NLS-1$
	bar.addDisplayableFilter(qFilterButton);
	availPanel.add(bar, BorderLayout.NORTH);

	availableTable.setDisplayableFilter(bar);
	availableTable.setTreeCellRenderer(qualifiedRenderer);
	availPanel.add(new JScrollPane(availableTable), BorderLayout.CENTER);

	Box box = Box.createHorizontalBox();
	box.add(Box.createHorizontalGlue());
	addButton.setHorizontalTextPosition(SwingConstants.LEADING);
	box.add(addButton);
	box.add(Box.createHorizontalStrut(5));
	box.setBorder(new EmptyBorder(0, 0, 5, 0));
	availPanel.add(box, BorderLayout.SOUTH);

	topPane.setLeftComponent(availPanel);

	JPanel selPanel = new JPanel(new BorderLayout());
	FilterBar<CharacterFacade, PCTemplate> filterBar = new FilterBar<>();
	filterBar.addDisplayableFilter(new SearchFilterPanel());

	selectedTable.setDisplayableFilter(filterBar);
	selectedTable.setTreeCellRenderer(qualifiedRenderer);
	selPanel.add(new JScrollPane(selectedTable), BorderLayout.CENTER);

	box = Box.createHorizontalBox();
	box.add(Box.createHorizontalStrut(5));
	box.add(removeButton);
	box.add(Box.createHorizontalGlue());
	box.setBorder(new EmptyBorder(0, 0, 5, 0));
	selPanel.add(box, BorderLayout.SOUTH);

	topPane.setRightComponent(selPanel);
	setBottomComponent(infoPane);
	setResizeWeight(0.75);
}
 
Example 20
Source File: SelectMultiplePanel.java    From biojava with GNU Lesser General Public License v2.1 3 votes vote down vote up
public SelectMultiplePanel(boolean show2boxes){

		Box vBox = Box.createVerticalBox();

		input = new JTextField("1mbc 1hlb 1dlw 1ith.A 1thb.A 1kr7.A_0-109");
		Box b = getDomainPanel(input);
		vBox.add(b);

		this.add(vBox);
	}