Java Code Examples for com.alee.laf.panel.WebPanel#setBackground()

The following examples show how to use com.alee.laf.panel.WebPanel#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: ExplorationSitesPanel.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,
		int row, int column) {

	if ((value != null) && (value instanceof Color)) {
		Color color = (Color) value;
		WebPanel colorPanel = new WebPanel();
		colorPanel.setOpaque(true);
		colorPanel.setBackground(color);
		return colorPanel;
	} else
		return null;

}
 
Example 2
Source File: MiningSitePanel.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,
		int row, int column) {

	if ((value != null) && (value instanceof Color)) {
		Color color = (Color) value;
		WebPanel colorPanel = new WebPanel();
		colorPanel.setOpaque(true);
		colorPanel.setBackground(color);
		return colorPanel;
	} else
		return null;

}
 
Example 3
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 4
Source File: BuildingPanelVehicleMaintenance.java    From mars-sim with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Constructor.
 * @param garage the vehicle maintenance function
 * @param desktop the main desktop
 */
public BuildingPanelVehicleMaintenance(VehicleMaintenance garage, MainDesktopPane desktop) {

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

	// Initialize data members
	this.garage = garage;

	// 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 vehicle maintenance label
	// 2014-11-21 Changed font type, size and color and label text
	// 2014-11-21 Added internationalization for labels
	WebLabel vehicleMaintenanceLabel = new WebLabel(Msg.getString("BuildingPanelVehicleMaintenance.title"), WebLabel.CENTER);
	vehicleMaintenanceLabel.setFont(new Font("Serif", Font.BOLD, 16));
	//vehicleMaintenanceLabel.setForeground(new Color(102, 51, 0)); // dark brown
	labelPanel.add(vehicleMaintenanceLabel);

	// Create vehicle number label
	vehicleNumberCache = garage.getCurrentVehicleNumber();
	vehicleNumberLabel = new WebLabel(Msg.getString("BuildingPanelVehicleMaintenance.numberOfVehicles",
			vehicleNumberCache), WebLabel.CENTER);
	labelPanel.add(vehicleNumberLabel);

	// Create vehicle capacity label
	int vehicleCapacity = garage.getVehicleCapacity();
	WebLabel vehicleCapacityLabel = new WebLabel(Msg.getString("BuildingPanelVehicleMaintenance.vehicleCapacity",
			vehicleCapacity), WebLabel.CENTER);
	labelPanel.add(vehicleCapacityLabel);	

	// Create vehicle list panel
	WebPanel vehicleListPanel = new WebPanel(new FlowLayout(FlowLayout.CENTER));
	add(vehicleListPanel, BorderLayout.CENTER);
	vehicleListPanel.setOpaque(false);
	vehicleListPanel.setBackground(new Color(0,0,0,128));
	
	// Create scroll panel for vehicle list
	WebScrollPane vehicleScrollPanel = new WebScrollPane();
	vehicleScrollPanel.setPreferredSize(new Dimension(160, 60));
	vehicleListPanel.add(vehicleScrollPanel);
	vehicleScrollPanel.setOpaque(false);
	vehicleScrollPanel.setBackground(new Color(0,0,0,128));
	vehicleScrollPanel.getViewport().setOpaque(false);
	vehicleScrollPanel.getViewport().setBackground(new Color(0,0,0,128));
	
	// Create vehicle list model
	vehicleListModel = new DefaultListModel<Vehicle>();
	vehicleCache = new ArrayList<Vehicle>(garage.getVehicles());
	Iterator<Vehicle> i = vehicleCache.iterator();
	while (i.hasNext()) vehicleListModel.addElement(i.next());

	// Create vehicle list
	vehicleList = new JList<Vehicle>(vehicleListModel);
	vehicleList.addMouseListener(this);
	vehicleScrollPanel.setViewportView(vehicleList);
}
 
Example 5
Source File: BuildingPanelResearch.java    From mars-sim with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Constructor.
 * @param lab the research building this panel is for.
 * @param desktop The main desktop.
 */
public BuildingPanelResearch(Research lab, MainDesktopPane desktop) {

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

	// Initialize data members
	this.lab = lab;

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

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

	// Prepare research label
	WebLabel researchLabel = new WebLabel(Msg.getString("BuildingPanelResearch.title"), WebLabel.CENTER); //$NON-NLS-1$
	researchLabel.setFont(new Font("Serif", Font.BOLD, 16));
	//researchLabel.setForeground(new Color(102, 51, 0)); // dark brown
	labelPanel.add(researchLabel);

	// Prepare researcher number label
	researchersCache = lab.getResearcherNum();
	researchersLabel = new WebLabel(Msg.getString("BuildingPanelResearch.numberOfResearchers", researchersCache), WebLabel.CENTER);
	labelPanel.add(researchersLabel);

	// Prepare researcher capacityLabel
	WebLabel researcherCapacityLabel = new WebLabel(Msg.getString("BuildingPanelResearch.researcherCapacity",
			lab.getLaboratorySize()),
			WebLabel.CENTER);
	labelPanel.add(researcherCapacityLabel);

	// Prepare specialties label
	WebLabel specialtiesLabel = new WebLabel(Msg.getString("BuildingPanelResearch.namesOfSpecialties"), WebLabel.CENTER);
	labelPanel.add(specialtiesLabel);

	// Get the research specialties of the building.
	ScienceType[] specialties = lab.getTechSpecialties();
	int size = specialties.length;

	WebTextArea specialtyTA = new WebTextArea();
	specialtyTA.setEditable(false);
	specialtyTA.setFont(new Font("SansSerif", Font.ITALIC, 12));
	specialtyTA.setColumns(7);

	// For each specialty, add specialty name panel.
	for (ScienceType specialty : specialties) {
		specialtyTA.append(" " + specialty.getName()+ " ");
		if (!specialty.equals(specialties[size-1]))
			//if it's NOT the last one
			specialtyTA.append("\n");
	}

	WebPanel listPanel = new WebPanel(new FlowLayout(FlowLayout.CENTER));
	listPanel.add(specialtyTA);
	specialtyTA.setBorder(new MarsPanelBorder());

	add(listPanel, BorderLayout.CENTER);
	listPanel.setOpaque(false);
	listPanel.setBackground(new Color(0,0,0,128));

}
 
Example 6
Source File: BuildingPanelMedicalCare.java    From mars-sim with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Constructor.
 * @param medical the medical care building this panel is for.
 * @param desktop The main desktop.
 */
public BuildingPanelMedicalCare(MedicalCare medical, MainDesktopPane desktop) {

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

	// Initialize data members
	this.medical = medical;

	// 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 medical care label
	// 2014-11-21 Changed font type, size and color and label text
	// 2014-11-21 Added internationalization for labels
	WebLabel medicalCareLabel = new WebLabel(Msg.getString("BuildingPanelMedicalCare.title"), WebLabel.CENTER);
	medicalCareLabel.setFont(new Font("Serif", Font.BOLD, 16));
	//medicalCareLabel.setForeground(new Color(102, 51, 0)); // dark brown
	labelPanel.add(medicalCareLabel);

	// Create sick bed label
	WebLabel sickBedLabel = new WebLabel(Msg.getString("BuildingPanelMedicalCare.numberOfsickBeds",
			medical.getSickBedNum()), WebLabel.CENTER);
	labelPanel.add(sickBedLabel);

	// Create physician label
	physicianCache = medical.getPhysicianNum();
	physicianLabel = new WebLabel(Msg.getString("BuildingPanelMedicalCare.numberOfPhysicians",
			physicianCache), WebLabel.CENTER);
	labelPanel.add(physicianLabel);

	// Create scroll panel for medical table
	WebScrollPane scrollPanel = new WebScrollPane();
	scrollPanel.setPreferredSize(new Dimension(160, 80));
	add(scrollPanel, BorderLayout.CENTER);
    scrollPanel.getViewport().setOpaque(false);
    scrollPanel.getViewport().setBackground(new Color(0, 0, 0, 0));
    scrollPanel.setOpaque(false);
    scrollPanel.setBackground(new Color(0, 0, 0, 0));
       //scrollPanel.setBorder( BorderFactory.createLineBorder(Color.orange) );


	// Prepare medical table model
	medicalTableModel = new MedicalTableModel(medical);

	// Prepare medical table
	JTable medicalTable = new ZebraJTable(medicalTableModel);
	medicalTable.setCellSelectionEnabled(false);
	scrollPanel.setViewportView(medicalTable);
}
 
Example 7
Source File: BuildingPanelStorage.java    From mars-sim with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Constructor.
 * @param storage the storage building function.
 * @param desktop the main desktop.
 */
public BuildingPanelStorage(Storage storage, MainDesktopPane desktop) {

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

	setLayout(new BorderLayout(0, 0));

	// Create storage label.
	WebLabel storageLabel = new WebLabel(Msg.getString("BuildingPanelStorage.title"), WebLabel.CENTER);
	storageLabel.setFont(new Font("Serif", Font.BOLD, 16));
	//storageLabel.setForeground(new Color(102, 51, 0)); // dark brown

	WebPanel titlePanel = new WebPanel(new GridLayout(2,1,0,0));
	add(titlePanel, BorderLayout.NORTH);
	titlePanel.add(storageLabel);
	titlePanel.setOpaque(false);
	titlePanel.setBackground(new Color(0,0,0,128));

	WebLabel maxCapLabel = new WebLabel(Msg.getString("BuildingPanelStorage.maxCap"), WebLabel.CENTER);
	titlePanel.add(maxCapLabel);

	Map<Integer, Double> resourceStorage = storage.getResourceStorageCapacity();

	// Create resource storage panel.
	WebPanel resourceStoragePanel = new WebPanel(new GridLayout(resourceStorage.size(), 2, 0, 0));
	add(resourceStoragePanel, BorderLayout.CENTER);
	resourceStoragePanel.setOpaque(false);
	resourceStoragePanel.setBackground(new Color(0,0,0,128));

	SortedSet<Integer> keys = new TreeSet<Integer>(resourceStorage.keySet());
	for (Integer resource : keys) { 
		// Create resource label.
		WebLabel resourceLabel = new WebLabel(
				Conversion.capitalize(ResourceUtil.findAmountResourceName(resource)) 
				+ ":", WebLabel.LEFT);
		resourceStoragePanel.add(resourceLabel);

		double capacity = resourceStorage.get(resource);
		WebLabel capacityLabel = new WebLabel((int) capacity + " kg", WebLabel.RIGHT);
		resourceStoragePanel.add(capacityLabel);
	}
}
 
Example 8
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 9
Source File: TabPanelBuildings.java    From mars-sim with GNU General Public License v3.0 4 votes vote down vote up
public void setPanelStyle(WebPanel p) {
	// if (isTranslucent) {
	p.setOpaque(false);
	p.setBackground(new Color(0, 0, 0, 128));
	// }
}
 
Example 10
Source File: SettlementWindow.java    From mars-sim with GNU General Public License v3.0 4 votes vote down vote up
/**
	 * Constructor.
	 * 
	 * @param desktop the main desktop panel.
	 */
	public SettlementWindow(MainDesktopPane desktop) {
		// Use ToolWindow constructor
		super(NAME, desktop);
		this.desktop = desktop;
		
		if (marsClock == null)
			marsClock = Simulation.instance().getMasterClock().getMarsClock();

//			// setTitleName(null);
//			// Remove title bar
//			putClientProperty("JInternalFrame.isPalette", Boolean.TRUE);
//			getRootPane().setWindowDecorationStyle(JRootPane.NONE);
//			BasicInternalFrameUI bi = (BasicInternalFrameUI) super.getUI();
//			bi.setNorthPane(null);
//			setBorder(null);

		setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);

		// getRootPane().setOpaque(false);
		// getRootPane().setBackground(new Color(0,0,0,128));

		setBackground(Color.BLACK);
		// setOpaque(false);
		// setBackground(new Color(0,0,0,128));

		WebPanel mainPanel = new WebPanel(new BorderLayout());
		// mainPanel.setOpaque(false);
		// mainPanel.setBackground(new Color(0,0,0,128));
		setContentPane(mainPanel);

		// Creates the status bar for showing the x/y coordinates and population
        statusBar = new WebStatusBar();//JStatusBar(3, 3, 18);
        mainPanel.add(statusBar, BorderLayout.SOUTH);

		Font font = new Font("Times New Roman", Font.BOLD, 12);

        popLabel = new WebStyledLabel(StyleId.styledlabelShadow);
        popLabel.setFont(font);
        popLabel.setForeground(Color.GRAY);
	    buildingXYLabel = new WebStyledLabel(StyleId.styledlabelShadow);
	    buildingXYLabel.setFont(font);
	    buildingXYLabel.setForeground(Color.GRAY);
	    mapXYLabel = new WebStyledLabel(StyleId.styledlabelShadow);
	    mapXYLabel.setFont(font);
	    mapXYLabel.setForeground(Color.GRAY);
	    
//        statusBar.addLeftComponent(mapXYLabel, false);  
//        statusBar.addCenterComponent(popLabel, false);
//        statusBar.addRightComponent(buildingXYLabel, false);
//		statusBar.addRightCorner();
        statusBar.add(mapXYLabel);  
        statusBar.addToMiddle(popLabel);
        statusBar.addToEnd(buildingXYLabel);
//		statusBar.addRightCorner();
		
        // Create subPanel for housing the settlement map
		subPanel = new WebPanel(new BorderLayout());
		mainPanel.add(subPanel, BorderLayout.CENTER);
		// subPanel.setOpaque(false);
		// subPanel.setBackground(new Color(0,0,0,128));
		subPanel.setBackground(Color.BLACK);

		mapPanel = new SettlementMapPanel(desktop, this);
		mapPanel.createUI();
		
		// Added SpotlightLayerUI
		LayerUI<WebPanel> layerUI = new SpotlightLayerUI(mapPanel);
		JLayer<WebPanel> jlayer = new JLayer<WebPanel>(mapPanel, layerUI);
		subPanel.add(jlayer, BorderLayout.CENTER);
		// subPanel.add(mapPanel, BorderLayout.CENTER);
		
		setSize(new Dimension(HORIZONTAL, VERTICAL));
		setPreferredSize(new Dimension(HORIZONTAL, VERTICAL));
		setMinimumSize(new Dimension(HORIZONTAL / 2, VERTICAL / 2));
		setClosable(true);
		setResizable(false);
		setMaximizable(true);

		setVisible(true);

		pack();

	}