Java Code Examples for com.alee.laf.label.WebLabel#setBackground()

The following examples show how to use com.alee.laf.label.WebLabel#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: BuildingPanelInhabitable.java    From mars-sim with GNU General Public License v3.0 4 votes vote down vote up
/**
	 * Constructor.
	 * @param inhabitable The inhabitable building this panel is for.
	 * @param desktop The main desktop.
	 */
	public BuildingPanelInhabitable(LifeSupport inhabitable, MainDesktopPane desktop) {

		// Use BuildingFunctionPanel constructor
		super(inhabitable.getBuilding(), desktop);

		// Initialize data members.
		this.inhabitable = inhabitable;

		// Set panel layout
		setLayout(new BorderLayout());

		// Create label panel
		WebPanel labelPanel = new WebPanel(new GridLayout(3, 1, 0, 0));
		add(labelPanel, BorderLayout.NORTH);
		labelPanel.setOpaque(false);
		labelPanel.setBackground(new Color(0,0,0,128));

		// Create inhabitant label
		WebLabel inhabitantLabel = new WebLabel(Msg.getString("BuildingPanelInhabitable.title"), WebLabel.CENTER); //$NON-NLS-1$
		inhabitantLabel.setFont(new Font("Serif", Font.BOLD, 16));
		//inhabitantLabel.setForeground(new Color(102, 51, 0)); // dark brown
		labelPanel.add(inhabitantLabel);
		inhabitantLabel.setOpaque(false);
		inhabitantLabel.setBackground(new Color(0,0,0,128));

		// Create number label
		numberLabel = new WebLabel(Msg.getString("BuildingPanelInhabitable.number", inhabitable.getOccupantNumber()), WebLabel.CENTER); //$NON-NLS-1$
		labelPanel.add(numberLabel);
//		numberLabel.setOpaque(false);
//		numberLabel.setBackground(new Color(0,0,0,128));

		// Create capacity label
		WebLabel capacityLabel = new WebLabel(
			Msg.getString(
				"BuildingPanelInhabitable.capacity", //$NON-NLS-1$
				inhabitable.getOccupantCapacity()
			),WebLabel.CENTER
		);
		labelPanel.add(capacityLabel);
//		capacityLabel.setOpaque(false);
//		capacityLabel.setBackground(new Color(0,0,0,128));

		// Create inhabitant list panel
		WebPanel inhabitantListPanel = new WebPanel(new FlowLayout(FlowLayout.CENTER));
		add(inhabitantListPanel, BorderLayout.CENTER);

		// Create inhabitant list model
		inhabitantListModel = new DefaultListModel<Person>();
		inhabitantCache = new ArrayList<Person>(inhabitable.getOccupants());
		Iterator<Person> i = inhabitantCache.iterator();
		while (i.hasNext()) inhabitantListModel.addElement(i.next());

		// Create inhabitant list
		inhabitantList = new JList<Person>(inhabitantListModel);
		inhabitantList.addMouseListener(this);

	}
 
Example 2
Source File: BuildingPanelAstronomicalObservation.java    From mars-sim with GNU General Public License v3.0 4 votes vote down vote up
/**
	 * Constructor.
	 * @param observatory the astronomical observatory building function.
	 * @param desktop the main desktop.
	 */
	public BuildingPanelAstronomicalObservation(AstronomicalObservation observatory, 
			MainDesktopPane desktop) {
		// User BuildingFunctionPanel constructor.
		super(observatory.getBuilding(), desktop);

		function = observatory;
		currentObserversAmount = function.getObserverNum();

		// Set panel layout
		setLayout(new BorderLayout());
		
		// Prepare label panelAstronomicalObservation
		WebPanel labelPanel = new WebPanel(new GridLayout(5, 1, 0, 0));
		add(labelPanel, BorderLayout.NORTH);

		// Astronomy top label
		// 2014-11-21 Changed font type, size and color and label text
		WebLabel astronomyLabel = new WebLabel(Msg.getString("BuildingPanelAstronomicalObservation.title"), WebLabel.CENTER); //$NON-NLS-1$
		astronomyLabel.setFont(new Font("Serif", Font.BOLD, 16));
		//astronomyLabel.setForeground(new Color(102, 51, 0)); // dark brown
		labelPanel.add(astronomyLabel);

		// Observer number label
		// 2014-11-21 Fixed currentObserversAmount
		observersLabel = new WebLabel(Msg.getString("BuildingPanelAstronomicalObservation.numberOfObservers", currentObserversAmount), WebLabel.CENTER); //$NON-NLS-1$
		observersLabel.setHorizontalAlignment(WebLabel.CENTER);
		update();
		labelPanel.add(observersLabel);

		// Observer capacityLabel
		WebLabel observerCapacityLabel = new WebLabel(
			Msg.getString(
				"BuildingPanelAstronomicalObservation.observerCapacity", //$NON-NLS-1$
				function.getObservatoryCapacity()
			),WebLabel.CENTER
		);
		labelPanel.add(observerCapacityLabel);
		
		labelPanel.setOpaque(false);
		labelPanel.setBackground(new Color(0,0,0,128));
		astronomyLabel.setOpaque(false);
		astronomyLabel.setBackground(new Color(0,0,0,128));
		observersLabel.setOpaque(false);
		observersLabel.setBackground(new Color(0,0,0,128));
		
      	// Create the button panel.
		WebPanel buttonPane = new WebPanel(new FlowLayout(FlowLayout.CENTER));
		
		// Create the orbit viewer button.
		WebButton button = new WebButton("Orbit Viewer");
		
		//balloonToolTip.createBalloonTip(button, "Click to open the solar system orbit viewer"); 
		//button.setToolTipText("Click to open the solar system orbit viewer");
		button.addActionListener(
			new ActionListener() {
				public void actionPerformed(ActionEvent e) {
//					openOrbitViewer();
				}
			});
		buttonPane.add(button);
		labelPanel.add(buttonPane);
	}
 
Example 3
Source File: TabPanelBuildings.java    From mars-sim with GNU General Public License v3.0 4 votes vote down vote up
public void initializeUI() {
		uiDone = true;
						
		List<Building> buildings = settlement.getBuildingManager().getSortedBuildings();

		// Set building to the first element on the list
		// Add if-clause for opening the building panel via the right click popup menu
		if (building == null) {
			building = buildings.get(0);
			setCurrentBuilding(building);
		}

		// Create building select panel.
		// Add buildingInfoPanel & buildingTitleLabel
		WebPanel buildingInfoPanel = new WebPanel(new GridLayout(2, 1, 0, 0));
		// buildingInfoPanel.setBorder(new MarsPanelBorder());
		topContentPanel.add(buildingInfoPanel);
		panelList.add(buildingInfoPanel);

		WebLabel titleLabel = new WebLabel("Buildings", WebLabel.CENTER);
		titleLabel.setFont(new Font("Serif", Font.BOLD, 16));
		// titleLabel.setForeground(new Color(102, 51, 0)); // dark brown
		buildingInfoPanel.add(titleLabel);
		titleLabel.setOpaque(false);
		titleLabel.setBackground(new Color(0, 0, 0, 128));

		WebPanel buildingSelectPanel = new WebPanel(new FlowLayout(FlowLayout.CENTER));
		buildingInfoPanel.add(buildingSelectPanel);
		panelList.add(buildingSelectPanel);

		// Create building combo box model.
		comboBoxModel = new DefaultComboBoxModel<Building>();

		buildingsCache = new ArrayList<Building>(buildings);
		for (Building b : buildingsCache) {
			comboBoxModel.addElement(b);
		}
		// Create building list.
		comboBox = new JComboBoxMW<Building>(comboBoxModel);
//		comboBox.setRenderer(new PromptComboBoxRenderer("Select a Building"));
		// comboBox.setOpaque(false);
		// comboBox.setBackground(new Color(0,0,0,128));
		// comboBox.setBackground(new Color(255,229,204));
		// comboBox.setForeground(Color.orange);
		comboBox.addActionListener(this);
		comboBox.setMaximumRowCount(10);
		comboBox.setBorder(null);

		buildingSelectPanel.add(comboBox);

		// Create building display panel.
		buildingDisplayPanel = new WebPanel();
		buildingLayout = new CardLayout();
		buildingDisplayPanel.setLayout(buildingLayout);
//		buildingDisplayPanel.setBorder(new MarsPanelBorder());
		centerContentPanel.add(buildingDisplayPanel);
		panelList.add(buildingDisplayPanel);

		// Create building panels
		buildingPanels = new ArrayList<BuildingPanel>();
		count = 0;
		Iterator<Building> iter = buildings.iterator();
		while (iter.hasNext()) {
			BuildingPanel panel = new BuildingPanel(String.valueOf(count), iter.next(), desktop);
			buildingPanels.add(panel);
			buildingDisplayPanel.add(panel, panel.getPanelName());
			count++;
		}

		setPanelTranslucent();
	}