Java Code Examples for com.alee.laf.label.WebLabel#RIGHT

The following examples show how to use com.alee.laf.label.WebLabel#RIGHT . 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: TabPanelAssociatedPeople.java    From mars-sim with GNU General Public License v3.0 4 votes vote down vote up
public void initializeUI() {
		uiDone = true;
		
		WebPanel titlePane = new WebPanel(new FlowLayout(FlowLayout.CENTER));
		topContentPanel.add(titlePane);

		// Create associated people label
		WebLabel heading = new WebLabel(Msg.getString("TabPanelAssociatedPeople.title"), WebLabel.CENTER); //$NON-NLS-1$
		heading.setFont(new Font("Serif", Font.BOLD, 16));
		// heading.setForeground(new Color(102, 51, 0)); // dark brown
		titlePane.add(heading);

		// Prepare count spring layout panel.
		WebPanel countPanel = new WebPanel(new SpringLayout());//GridLayout(3, 1, 0, 0));
//		countPanel.setBorder(new MarsPanelBorder());
		topContentPanel.add(countPanel);

		// Create associate label
		WebLabel populationNumHeader = new WebLabel(Msg.getString("TabPanelAssociatedPeople.associated"),
				WebLabel.RIGHT); // $NON-NLS-1$
		countPanel.add(populationNumHeader);
		
		populationCitizensCache = settlement.getNumCitizens();
		populationCitizensLabel = new WebLabel(populationCitizensCache + "", WebLabel.LEFT);
		countPanel.add(populationCitizensLabel);

		// Create population indoor label
		WebLabel populationIndoorHeader = new WebLabel(Msg.getString("TabPanelAssociatedPeople.indoor"),
				WebLabel.RIGHT); // $NON-NLS-1$
		countPanel.add(populationIndoorHeader);
		
		populationIndoorCache = settlement.getIndoorPeopleCount();
		populationIndoorLabel = new WebLabel(populationIndoorCache + "", WebLabel.LEFT);
		countPanel.add(populationIndoorLabel);
		
		// Create population capacity label
		WebLabel populationCapacityHeader = new WebLabel(Msg.getString("TabPanelAssociatedPeople.capacity"),
				WebLabel.RIGHT); // $NON-NLS-1$
		countPanel.add(populationCapacityHeader);
		
		populationCapacityCache = settlement.getPopulationCapacity();
		populationCapacityLabel = new WebLabel(populationCapacityCache + "", WebLabel.RIGHT);
		countPanel.add(populationCapacityLabel);
		
		// Lay out the spring panel.
		SpringUtilities.makeCompactGrid(countPanel, 3, 2, // rows, cols
				25, 10, // initX, initY
				10, 10); // xPad, yPad
		
        UIManager.getDefaults().put("TitledBorder.titleColor", Color.darkGray);
        Border lowerEtched = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED);
        TitledBorder title = BorderFactory.createTitledBorder(lowerEtched, " " + Msg.getString("TabPanelAssociatedPeople.title") + " ");
//      title.setTitleJustification(TitledBorder.RIGHT);
        Font titleFont = UIManager.getFont("TitledBorder.font");
        title.setTitleFont( titleFont.deriveFont(Font.ITALIC + Font.BOLD));
        
		// Create spring layout population display panel
		WebPanel populationDisplayPanel = new WebPanel(new FlowLayout(FlowLayout.CENTER));
		populationDisplayPanel.setBorder(title);
//		populationDisplayPanel.setBorder(new MarsPanelBorder());
		topContentPanel.add(populationDisplayPanel);

		// Create scroll panel for population list.
		populationScrollPanel = new WebScrollPane();
		populationScrollPanel.setPreferredSize(new Dimension(200, 250));
		populationDisplayPanel.add(populationScrollPanel);

		// Create population list model
		populationListModel = new AssociatedPopulationListModel(settlement);

		// Create population list
		populationList = new JList<Person>(populationListModel);
		populationList.addMouseListener(this);
		populationScrollPanel.setViewportView(populationList);


		// Create population monitor button
		JButton monitorButton = new JButton(ImageLoader.getIcon(Msg.getString("img.monitor"))); //$NON-NLS-1$
		monitorButton.setMargin(new Insets(1, 1, 1, 1));
		monitorButton.addActionListener(this);
		monitorButton.setToolTipText(Msg.getString("TabPanelAssociatedPeople.tooltip.monitor")); //$NON-NLS-1$
		populationDisplayPanel.add(monitorButton);
		
//		WebPanel buttonPane = new WebPanel(new FlowLayout(FlowLayout.RIGHT));
////		buttonPane.setPreferredSize(new Dimension(25, 25));
//		buttonPane.add(monitorButton);
//		
//		populationDisplayPanel.add(buttonPane);

	}
 
Example 2
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 3
Source File: BuildingPanelPower.java    From mars-sim with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Constructor.
 * @param building the building the panel is for.
 * @param desktop The main desktop.
 */
public BuildingPanelPower(Building building, MainDesktopPane desktop) {

	// Use BuildingFunctionPanel constructor
	super(building, desktop);

	// Check if the building is a power producer.
	isProducer = building.hasFunction(FunctionType.POWER_GENERATION);
	generator = building.getPowerGeneration();
	
	// Set the layout
	setLayout(new BorderLayout());

	// 2014-11-21 Changed font type, size and color and label text
	WebLabel titleLabel = new WebLabel(
			Msg.getString("BuildingPanelPower.title"), //$NON-NLS-1$
			WebLabel.CENTER);		
	titleLabel.setFont(new Font("Serif", Font.BOLD, 16));
	//titleLabel.setForeground(new Color(102, 51, 0)); // dark brown
	add(titleLabel, BorderLayout.NORTH);
	
	WebPanel springPanel = new WebPanel(new SpringLayout());
	add(springPanel, BorderLayout.CENTER);
	
	// Prepare power status label.
	powerStatusCache = building.getPowerMode();
	powerStatusLabel = new WebLabel(
			Msg.getString("BuildingPanelPower.powerStatus"), //$NON-NLS-1$
			WebLabel.RIGHT);
	springPanel.add(powerStatusLabel);
	
	WebPanel wrapper1 = new WebPanel(new FlowLayout(0, 0, FlowLayout.LEADING));
	statusTF = new WebTextField(powerStatusCache.getName());
	statusTF.setEditable(false);
	statusTF.setColumns(7);
	statusTF.setPreferredSize(new Dimension(120, 25));
	wrapper1.add(statusTF);
	springPanel.add(wrapper1);

	// If power producer, prepare power producer label.
	if (isProducer) {
		//PowerGeneration generator = building.getPowerGeneration();//(PowerGeneration) building.getFunction(FunctionType.POWER_GENERATION);
		powerCache = generator.getGeneratedPower();
		powerLabel = new WebLabel(
			Msg.getString("BuildingPanelPower.powerProduced"), //$NON-NLS-1$
			WebLabel.RIGHT);
		
		springPanel.add(powerLabel);
		
		WebPanel wrapper2 = new WebPanel(new FlowLayout(0, 0, FlowLayout.LEADING));
		producedTF = new WebTextField(formatter.format(powerCache) + kW);
		producedTF.setEditable(false);
		producedTF.setColumns(7);
		producedTF.setPreferredSize(new Dimension(120, 25));
		wrapper2.add(producedTF);
		springPanel.add(wrapper2);
	}

	// Prepare power used label.
	if (powerStatusCache == PowerMode.FULL_POWER) 
		usedCache = building.getFullPowerRequired();
	else if (powerStatusCache == PowerMode.POWER_DOWN) 
		usedCache = building.getPoweredDownPowerRequired();
	else usedCache = 0D;
	
	usedLabel = new WebLabel(
		Msg.getString("BuildingPanelPower.powerUsed"), //$NON-NLS-1$
		WebLabel.RIGHT
	);
	
	springPanel.add(usedLabel);
	
	WebPanel wrapper3 = new WebPanel(new FlowLayout(0, 0, FlowLayout.LEADING));
	usedTF = new WebTextField(formatter.format(usedCache) + kW);
	usedTF.setEditable(false);
	usedTF.setColumns(7);
	usedTF.setPreferredSize(new Dimension(120, 25));
	wrapper3.add(usedTF);
	springPanel.add(wrapper3);
	
	//Lay out the spring panel.
	if (isProducer) {
		SpringUtilities.makeCompactGrid(springPanel,
	                                3, 2, //rows, cols
	                                75, 10,        //initX, initY
	                                3, 1);       //xPad, yPad
	}
	else
		SpringUtilities.makeCompactGrid(springPanel,
                   2, 2, //rows, cols
                   75, 10,        //initX, initY
                   3, 1);       //xPad, yPad
	}
 
Example 4
Source File: TabPanelPopulation.java    From mars-sim with GNU General Public License v3.0 4 votes vote down vote up
public void initializeUI() {
		uiDone = true;
		
		JPanel titlePane = new JPanel(new FlowLayout(FlowLayout.CENTER));
		topContentPanel.add(titlePane);

		JLabel heading = new JLabel(Msg.getString("TabPanelPopulation.title"), JLabel.CENTER); //$NON-NLS-1$
		heading.setFont(new Font("Serif", Font.BOLD, 16));
		//heading.setForeground(new Color(102, 51, 0)); // dark brown
		titlePane.add(heading);

		// Prepare count spring layout panel.
		WebPanel countPanel = new WebPanel(new SpringLayout());//GridLayout(3, 1, 0, 0));
//		countPanel.setBorder(new MarsPanelBorder());
		topContentPanel.add(countPanel);
		
		// Create population indoor label
		WebLabel populationIndoorHeader = new WebLabel(Msg.getString("TabPanelPopulation.indoor"),
				WebLabel.RIGHT); // $NON-NLS-1$
		countPanel.add(populationIndoorHeader);
		
		populationIndoorCache = settlement.getIndoorPeopleCount();
		populationIndoorLabel = new WebLabel(populationIndoorCache + "", WebLabel.LEFT);
		countPanel.add(populationIndoorLabel);
		
		// Create population capacity label
		WebLabel populationCapacityHeader = new WebLabel(Msg.getString("TabPanelPopulation.capacity"),
				WebLabel.RIGHT); // $NON-NLS-1$
		countPanel.add(populationCapacityHeader);
		
		populationCapacityCache = settlement.getPopulationCapacity();
		populationCapacityLabel = new WebLabel(populationCapacityCache + "", WebLabel.RIGHT);
		countPanel.add(populationCapacityLabel);
		
		// Lay out the spring panel.
		SpringUtilities.makeCompactGrid(countPanel, 2, 2, // rows, cols
				25, 10, // initX, initY
				10, 10); // xPad, yPad
		
        UIManager.getDefaults().put("TitledBorder.titleColor", Color.darkGray);
        Border lowerEtched = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED);
        TitledBorder title = BorderFactory.createTitledBorder(lowerEtched, " " + Msg.getString("TabPanelPopulation.title") + " ");
//      title.setTitleJustification(TitledBorder.RIGHT);
        Font titleFont = UIManager.getFont("TitledBorder.font");
        title.setTitleFont( titleFont.deriveFont(Font.ITALIC + Font.BOLD));
        
		// Create spring layout population display panel
		JPanel populationDisplayPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
		populationDisplayPanel.setBorder(title);
		topContentPanel.add(populationDisplayPanel);

		// Create scroll panel for population list.
		populationScrollPanel = new JScrollPane();
		populationScrollPanel.setPreferredSize(new Dimension(200, 250));
		populationDisplayPanel.add(populationScrollPanel);

		// Create population list model
		populationListModel = new PopulationListModel(settlement);

		// Create population list
		populationList = new JList<Person>(populationListModel);
		populationList.addMouseListener(this);
		populationScrollPanel.setViewportView(populationList);

		// Create population monitor button
		JButton monitorButton = new JButton(ImageLoader.getIcon(Msg.getString("img.monitor"))); //$NON-NLS-1$
		monitorButton.setMargin(new Insets(1, 1, 1, 1));
		monitorButton.addActionListener(this);
		monitorButton.setToolTipText(Msg.getString("TabPanelPopulation.tooltip.monitor")); //$NON-NLS-1$
		populationDisplayPanel.add(monitorButton);

	}
 
Example 5
Source File: RescueMissionCustomInfoPanel.java    From mars-sim with GNU General Public License v3.0 4 votes vote down vote up
RescueMissionCustomInfoPanel(MainDesktopPane desktop) {
      // Use MissionCustomInfoPanel constructor.
      super();

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

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

      // Create content panel.
      contentPanel = new WebPanel(new SpringLayout());//new GridLayout(3, 1));
      add(contentPanel, BorderLayout.NORTH);

      // Create rescue vehicle panel.
      WebPanel rescueVehiclePanel = new WebPanel(new FlowLayout(FlowLayout.RIGHT));
      contentPanel.add(rescueVehiclePanel);

      // Create rescue vehicle title label.
      WebLabel rescueVehicleTitleLabel = new WebLabel("Vehicle to Rescue : ", WebLabel.LEFT);
      rescueVehiclePanel.add(rescueVehicleTitleLabel);

      // Create rescue vehicle button.
      rescueVehicleButton = new WebButton("");
      WebPanel wrapper0 = new WebPanel(new FlowLayout(FlowLayout.LEFT));
wrapper0.add(rescueVehicleButton);
contentPanel.add(wrapper0);
      //contentPanel.add(rescueVehicleButton);
      rescueVehicleButton.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {
              // Open window for vehicle to be rescued.
              openRescueVehicleWindow();
          }
      });

      // Create status panel.
      WebPanel statusPanel = new WebPanel(new FlowLayout(FlowLayout.RIGHT));
      contentPanel.add(statusPanel);

      // Create vehicle status title label.
      WebLabel vehicleStatusTitleLabel = new WebLabel("Vehicle Status : ", WebLabel.RIGHT);
      statusPanel.add(vehicleStatusTitleLabel);

      // Create vehicle status value label.
      vehicleStatusValueLabel = new WebLabel("", WebLabel.LEFT);
      WebPanel wrapper1 = new WebPanel(new FlowLayout(FlowLayout.LEFT));
wrapper1.add(vehicleStatusValueLabel);
contentPanel.add(wrapper1);

      // Create malfunction panel.
WebPanel malfunctionPanel = new WebPanel(new FlowLayout(FlowLayout.RIGHT));
      contentPanel.add(malfunctionPanel);

      // Create malfunction title panel.
      WebLabel malfunctionTitleLabel = new WebLabel("Vehicle Malfunctions : ", WebLabel.RIGHT);
      malfunctionPanel.add(malfunctionTitleLabel);

      // Create malfunction list label.
      malfunctionListLabel = new WebLabel("", WebLabel.LEFT);
      WebPanel wrapper2 = new WebPanel(new FlowLayout(FlowLayout.LEFT));
wrapper2.add(malfunctionListLabel);
contentPanel.add(wrapper2);

// 2017-05-03 Prepare SpringLayout
SpringUtilities.makeCompactGrid(contentPanel,
                                3, 2, //rows, cols
                                15, 10,        //initX, initY
                                10, 2);       //xPad, yPad
  }