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

The following examples show how to use javax.swing.Box#setOpaque() . 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: 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 2
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 3
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 4
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);
    }
 
Example 5
Source File: LibraryPanel.java    From HubPlayer with GNU General Public License v3.0 4 votes vote down vote up
/**
 * This method is called from within the constructor to initialize the form.
 * WARNING: Do NOT modify this code. The content of this method is always
 * regenerated by the Form Editor.
 */
@SuppressWarnings({ "unchecked", "serial" })
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {

	aScrollPanel = new JScrollPane();
	dataTable = new JTable();
	libraryTableModel = new LibraryTableModel();
	libraryOperation = new LibraryOperation();

	aToolBar = new JToolBar();
	moreSearch = new JButton();

	setLayout(new BorderLayout());

	aScrollPanel
			.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
	aScrollPanel
			.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
	aScrollPanel.setMaximumSize(new Dimension(615, 481));

	// 设置20行空数据
	dataTable.setModel(libraryTableModel);
	libraryTableModel.setLibraryOperation(libraryOperation);

	// 定义"操作栏"的渲染器 显示按钮
	dataTable.getColumn("操作").setCellRenderer(
			new DefaultTableCellRenderer() {

				@Override
				public Component getTableCellRendererComponent(
						JTable table, Object value, boolean isSelected,
						boolean hasFocus, int row, int column) {

					return value instanceof JPanel ? (JPanel) value : super
							.getTableCellRendererComponent(table, value,
									isSelected, hasFocus, row, column);
				}
			});
	// 定义"操作栏"的编辑器 响应按钮事件
	dataTable.getColumn("操作").setCellEditor(new CellEditor());

	dataTable.setColumnSelectionAllowed(true);
	dataTable.setRowHeight(23);
	aScrollPanel.setViewportView(dataTable);
	dataTable.getColumnModel().getSelectionModel()
			.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

	add(aScrollPanel, BorderLayout.CENTER);

	aToolBar.setFloatable(false);
	aToolBar.setRollover(true);
	aToolBar.setOpaque(false);

	moreSearch.setText("更多数据");
	moreSearch.setFocusable(false);
	moreSearch.setHorizontalTextPosition(SwingConstants.CENTER);
	moreSearch.setVerticalTextPosition(SwingConstants.BOTTOM);
	// moreSearch.setEnabled(false);
	aToolBar.add(moreSearch);

	Box box = Box.createVerticalBox();
	box.setBorder(BorderFactory.createLineBorder(Color.BLACK));
	box.setOpaque(true);
	box.add(aToolBar);

	add(box, BorderLayout.SOUTH);

}
 
Example 6
Source File: TomatoLinearClassifierDemo.java    From COMP3204 with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public Component getComponent(int width, int height) throws IOException {
	points = new ArrayList<double[]>();
	classes = new ArrayList<Integer>();
	classifier = new SimplePerceptron();

	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();
	base.setOpaque(false);
	base.setPreferredSize(new Dimension(width, height));
	base.setLayout(new GridBagLayout());

	// left hand side (video, features)
	final Box videoCtrls = Box.createVerticalBox();
	videoCtrls.setOpaque(false);
	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);
	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));

	// learning controls
	final JPanel learnCtrls = new JPanel(new GridLayout(0, 1));
	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);
	guess = new JTextField(8);
	guess.setOpaque(false);
	guess.setFont(Font.decode("Monaco-24"));
	guess.setHorizontalAlignment(JTextField.CENTER);
	guess.setEditable(false);
	classCtrls.add(guess);
	classCtrlsCnt.add(classCtrls);

	rightPanel.add(classCtrlsCnt);

	base.add(rightPanel);

	redraw();
	return base;
}
 
Example 7
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 8
Source File: LinearClassifierDemo.java    From COMP3204 with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public Component getComponent(int width, int height) throws IOException {
	points = new ArrayList<double[]>();
	classes = new ArrayList<Integer>();
	classifier = new SimplePerceptron();

	vc = new VideoCaptureComponent(VIDEO_WIDTH, VIDEO_HEIGHT);
	vc.getDisplay().addVideoListener(this);

	// the main panel
	final JPanel base = new JPanel();
	base.setOpaque(false);
	base.setPreferredSize(new Dimension(width, height));
	base.setLayout(new GridBagLayout());

	// left hand side (video, features)
	final Box videoCtrls = Box.createVerticalBox();
	videoCtrls.setOpaque(false);
	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);
	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));

	// learning controls
	final JPanel learnCtrls = new JPanel(new GridLayout(0, 1));
	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);
	guess = new JTextField(8);
	guess.setOpaque(false);
	guess.setFont(Font.decode("Monaco-24"));
	guess.setHorizontalAlignment(JTextField.CENTER);
	guess.setEditable(false);
	classCtrls.add(guess);
	classCtrlsCnt.add(classCtrls);

	rightPanel.add(classCtrlsCnt);

	base.add(rightPanel);

	redraw();
	return base;
}
 
Example 9
Source File: KNNDemo.java    From COMP3204 with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public Component getComponent(int width, int height) throws IOException {
	points = new ArrayList<double[]>();
	classes = new ArrayList<Integer>();
	k = 1;

	vc = new VideoCaptureComponent(VIDEO_WIDTH, VIDEO_HEIGHT);
	vc.getDisplay().addVideoListener(this);

	// the main panel
	final JPanel base = new JPanel();
	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);
	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));

	// 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.add(new JLabel("K:"));
	final JSpinner kField = new JSpinner(new SpinnerNumberModel(k, 1, 10, 1));
	kField.addChangeListener(this);
	cnt.add(kField);
	classCtrls.add(cnt);
	guess = new JTextField(8);
	guess.setOpaque(false);
	guess.setFont(Font.decode("Monaco-24"));
	guess.setHorizontalAlignment(JTextField.CENTER);
	guess.setEditable(false);
	classCtrls.add(guess);
	classCtrlsCnt.add(classCtrls);

	rightPanel.add(classCtrlsCnt);

	base.add(rightPanel);

	redraw();
	return base;
}