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

The following examples show how to use javax.swing.Box#setBackground() . 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: 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 2
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 3
Source File: PaginatorView.java    From jdal with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected JComponent buildPanel() {
	pageSizeCombo = new JComboBox(pageSizes);
	pageSizeCombo.addItemListener(new PageSizeComboListener());
	nextPageButton = new JButton(new NextPageAction());
	previousPageButton = new JButton(new PreviousPageAction());
	lastPageButton = new JButton(new LastPageAction());
	firstPageButton = new JButton(new FirstPageAction());
	statusLabel = new JLabel();
	countLabel = new JLabel();
	JLabel numberPagesLabel =  new JLabel(getMessage("PaginatorView.pageSize") +  " ");
	pageSizeCombo.setMaximumSize(new Dimension(70, 30));
	numberPagesLabel.setAlignmentX(Container.RIGHT_ALIGNMENT);
	
	Box box = Box.createHorizontalBox();
	box.setBackground(Color.LIGHT_GRAY);
	box.setOpaque(true);
	box.add(countLabel);
	box.add(Box.createHorizontalStrut( 100 	/*180 + numberPagesLabel.getSize().width */));
	box.add(Box.createHorizontalGlue());
	box.add(firstPageButton);
	box.add(previousPageButton);
	box.add(Box.createHorizontalStrut(5));
	box.add(statusLabel);
	box.add(Box.createHorizontalStrut(5));
	box.add(nextPageButton);
	box.add(lastPageButton);
	box.add(Box.createHorizontalGlue());
	box.add(numberPagesLabel);
	box.add(pageSizeCombo);
	box.add(Box.createHorizontalStrut(30));
	
	// set page size from combo box
	String pageSize = (String) pageSizeCombo.getSelectedItem();
	paginator.setPageSize(parsePageSize(pageSize));
	
	return box;
}
 
Example 4
Source File: MainWindow.java    From xdm with GNU General Public License v2.0 4 votes vote down vote up
private JPanel createToolbar() {
	JPanel p = new JPanel(new BorderLayout());
	Box toolBox = Box.createHorizontalBox();
	toolBox.add(Box.createRigidArea(new Dimension(scale(20), scale(60))));
	toolBox.setBackground(ColorResource.getTitleColor());
	toolBox.setOpaque(true);

	JButton btn1 = createToolButton("ADD_URL", "tool_add.png");
	btn1.setToolTipText(StringResource.get("MENU_ADD_URL"));
	toolBox.add(btn1);

	toolBox.add(Box.createRigidArea(new Dimension(scale(10), scale(10))));

	JButton btn2 = createToolButton("DELETE", "tool_del.png");
	btn2.setToolTipText(StringResource.get("MENU_DELETE_DWN"));
	toolBox.add(btn2);

	toolBox.add(Box.createRigidArea(new Dimension(scale(10), scale(10))));

	JButton btn3 = createToolButton("PAUSE", "tool_pause.png");
	btn3.setToolTipText(StringResource.get("MENU_PAUSE"));
	toolBox.add(btn3);

	toolBox.add(Box.createRigidArea(new Dimension(scale(10), scale(10))));

	JButton btn4 = createToolButton("RESUME", "tool_resume.png");
	btn4.setToolTipText(StringResource.get("MENU_RESUME"));
	toolBox.add(btn4);

	toolBox.add(Box.createRigidArea(new Dimension(scale(10), scale(10))));

	JButton btn5 = createToolButton("OPTIONS", "tool_settings.png");
	btn5.setToolTipText(StringResource.get("TITLE_SETTINGS"));
	toolBox.add(btn5);

	toolBox.add(Box.createRigidArea(new Dimension(scale(10), scale(10))));

	JButton btn6 = createToolButton("MENU_VIDEO_DWN", "tool_video.png");
	btn6.setToolTipText(StringResource.get("MENU_VIDEO_DWN"));
	toolBox.add(btn6);

	toolBox.add(Box.createRigidArea(new Dimension(scale(10), scale(10))));

	JButton btn7 = createToolButton("MENU_MEDIA_CONVERTER", "tool_convert.png");
	btn7.setToolTipText(StringResource.get("MENU_MEDIA_CONVERTER"));
	toolBox.add(btn7);
	toolBox.add(Box.createHorizontalGlue());

	btnMonitoring = new JLabel(ImageResource.getIcon("on.png", 85, 21));
	// btnMonitoring.setForeground(Color.WHITE);
	btnMonitoring.setIconTextGap(scale(15));
	btnMonitoring.putClientProperty("xdmbutton.norollover", "true");
	// btnMonitoring.setBackground(ColorResource.getTitleColor());
	btnMonitoring.setName("BROWSER_MONITORING");
	btnMonitoring.setText(StringResource.get("BROWSER_MONITORING"));
	btnMonitoring.setHorizontalTextPosition(JButton.LEADING);
	btnMonitoring.setFont(FontResource.getBigFont());

	btnMonitoring
			.setIcon(Config.getInstance().isBrowserMonitoringEnabled() ? ImageResource.getIcon("on.png", 85, 21)
					: ImageResource.getIcon("off.png", 85, 21));

	btnMonitoring.addMouseListener(new MouseAdapter() {
		@Override
		public void mouseReleased(MouseEvent e) {
			toggleMonitoring((JLabel) e.getSource());
		}
	});
	toolBox.add(btnMonitoring);
	toolBox.add(Box.createRigidArea(new Dimension(scale(25), scale(10))));
	p.add(toolBox);
	return p;
}
 
Example 5
Source File: SettlementTransparentPanel.java    From mars-sim with GNU General Public License v3.0 4 votes vote down vote up
public void createAndShowGUI() {

	    emptyLabel = new JLabel("  ") {
	    	@Override
	    	public Dimension getMinimumSize() {
	    		return new Dimension(50, 100);
	    	};
	    	@Override
	    	public Dimension getPreferredSize() {
	    		return new Dimension(50, 100);
	    	};
	    };

        buildLabelPane();
        buildSettlementNameComboBox();
        buildInfoP();
        buildrenameBtn();
        buildZoomSlider();
        buildButtonPane();

		nameBtnPane = new JPanel(new FlowLayout());
		nameBtnPane.setBackground(new Color(0,0,0));
        nameBtnPane.setOpaque(false);

      	nameBtnPane.add(infoP);
       	nameBtnPane.add(renameP);
       	nameBtnPane.add(new JLabel(""));

		settlementPanel = new JPanel();//new BorderLayout());
		settlementPanel.setBackground(new Color(0,0,0,128));
		settlementPanel.setOpaque(false);
		settlementPanel.add(settlementListBox);//, BorderLayout.CENTER);

		Box box = new Box(BoxLayout.Y_AXIS);
	    box.add(Box.createVerticalGlue());
	    box.setAlignmentX(JComponent.CENTER_ALIGNMENT);
	    //box.setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY));
	    box.add(Box.createVerticalGlue());
		box.setBackground(new Color(0,0,0,128));
		box.setOpaque(false);
	    box.add(settlementPanel);
	    box.add(nameBtnPane);

	    mapPanel.add(box, BorderLayout.NORTH);

	    controlCenterPane = new JPanel(new FlowLayout(FlowLayout.CENTER));
	    controlCenterPane.setBackground(new Color(0,0,0,128));//,0));
	    controlCenterPane.setOpaque(false);
        controlCenterPane.setPreferredSize(new Dimension(50, 200));
        controlCenterPane.setSize(new Dimension(50, 200));
        controlCenterPane.add(zoomSlider);

	    controlPane = new JPanel(new BorderLayout());//GridLayout(2,1,10,2));
	    controlPane.setBackground(new Color(0,0,0,128));//,0));
		controlPane.setOpaque(false);
       	controlPane.add(buttonPane, BorderLayout.NORTH);
	    controlPane.add(labelPane, BorderLayout.SOUTH);
       	controlPane.add(controlCenterPane, BorderLayout.CENTER);

	    eastPane = new JPanel(new BorderLayout());//GridLayout(3,1,10,2));
		eastPane.setBackground(new Color(0,0,0,15));
		eastPane.setBackground(new Color(0,0,0));//,0));
		eastPane.setOpaque(false);
        eastPane.add(emptyLabel, BorderLayout.EAST);
        eastPane.add(emptyLabel, BorderLayout.WEST);
        eastPane.add(emptyLabel, BorderLayout.NORTH);
        eastPane.add(emptyLabel, BorderLayout.SOUTH);
        eastPane.add(controlPane, BorderLayout.CENTER);

        mapPanel.add(eastPane, BorderLayout.EAST);
        // Make panel drag-able
//  	ComponentMover cmZoom = new ComponentMover(zoomPane);
		//cmZoom.registerComponent(rightPane);
//		cmZoom.registerComponent(zoomPane);
        mapPanel.setVisible(true);
    }