Java Code Examples for com.alee.laf.button.WebButton#addActionListener()

The following examples show how to use com.alee.laf.button.WebButton#addActionListener() . 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: WebNotificationExample.java    From weblaf with GNU General Public License v3.0 6 votes vote down vote up
@NotNull
@Override
protected List<? extends JComponent> createPreviewElements ()
{
    final WebButton button = new WebButton ( getExampleLanguagePrefix () + "show" );
    button.addActionListener ( new ActionListener ()
    {
        @Override
        public void actionPerformed ( final ActionEvent e )
        {
            final WebLabel title = new WebLabel ( getPreviewLanguagePrefix () + "text", WebLabel.CENTER );
            final WebImage logo = new WebImage ( WebLookAndFeel.getIcon ( 256 ) );
            final GroupPanel content = new GroupPanel ( 15, false, title, logo );
            NotificationManager.showNotification ( button, content, ( Icon ) null );
        }
    } );
    return CollectionUtils.asList ( button );
}
 
Example 2
Source File: WebNotificationExample.java    From weblaf with GNU General Public License v3.0 6 votes vote down vote up
@NotNull
@Override
protected List<? extends JComponent> createPreviewElements ()
{
    final WebButton button = new WebButton ( getExampleLanguagePrefix () + "show" );
    button.addActionListener ( new ActionListener ()
    {
        @Override
        public void actionPerformed ( final ActionEvent e )
        {
            final String title = getPreviewLanguagePrefix () + "text";
            NotificationManager.showNotification ( button, title, NotificationIcon.question.getIcon (),
                    NotificationOption.yes, NotificationOption.no, NotificationOption.retry );
        }
    } );
    return CollectionUtils.asList ( button );
}
 
Example 3
Source File: WebNotificationExample.java    From weblaf with GNU General Public License v3.0 6 votes vote down vote up
@NotNull
@Override
protected List<? extends JComponent> createPreviewElements ()
{
    final WebButton button = new WebButton ( getExampleLanguagePrefix () + "show" );
    button.addActionListener ( new ActionListener ()
    {
        @Override
        public void actionPerformed ( final ActionEvent e )
        {
            final String title = getPreviewLanguagePrefix () + "text";
            NotificationManager.showNotification ( button, title );
        }
    } );
    return CollectionUtils.asList ( button );
}
 
Example 4
Source File: WebCustomTooltipExample.java    From weblaf with GNU General Public License v3.0 6 votes vote down vote up
@NotNull
@Override
protected List<? extends JComponent> createPreviewElements ()
{
    final WebButton button = new WebButton ();
    button.setLanguage ( getPreviewLanguagePrefix () + "text", 0 );
    button.addHotkey ( Hotkey.CTRL_D );
    button.setToolTip ( getPreviewLanguagePrefix () + "tip" );
    button.addActionListener ( new ActionListener ()
    {
        private int counter = 0;

        @Override
        public void actionPerformed ( final ActionEvent e )
        {
            counter++;
            button.updateLanguage ( counter );
        }
    } );
    return CollectionUtils.asList ( button );
}
 
Example 5
Source File: JFrameExample.java    From weblaf with GNU General Public License v3.0 6 votes vote down vote up
@NotNull
@Override
protected List<? extends JComponent> createPreviewElements ()
{
    final WebButton button = new WebButton ( getExampleLanguagePrefix () + "show" );
    button.addActionListener ( new ActionListener ()
    {
        @Override
        public void actionPerformed ( final ActionEvent e )
        {
            final String title = getExampleLanguagePrefix () + "content";
            final JFrame frame = new JFrame ();
            UILanguageManager.registerComponent ( frame.getRootPane (), title );
            frame.getRootPane ().putClientProperty ( StyleId.STYLE_PROPERTY, getStyleId () );
            frame.setIconImages ( WebLookAndFeel.getImages () );
            frame.add ( new WebLabel ( title, WebLabel.CENTER ) );
            frame.setAlwaysOnTop ( true );
            frame.setSize ( 500, 400 );
            frame.setLocationRelativeTo ( DemoApplication.getInstance () );
            frame.setDefaultCloseOperation ( WindowConstants.DISPOSE_ON_CLOSE );
            frame.setVisible ( true );
        }
    } );
    return CollectionUtils.asList ( button );
}
 
Example 6
Source File: WebProgressOverlayExample.java    From weblaf with GNU General Public License v3.0 5 votes vote down vote up
@NotNull
@Override
protected List<? extends JComponent> createPreviewElements ()
{
    final WebProgressOverlay overlay = new WebProgressOverlay ( getStyleId () );

    final WebButton button = new WebButton ( getPreviewLanguageKey ( "show" ) );
    button.setPreferredWidth ( 250 );
    button.addActionListener ( new ActionListener ()
    {
        @Override
        public void actionPerformed ( @NotNull final ActionEvent e )
        {
            if ( overlay.isProgressDisplayed () )
            {
                overlay.hideProgress ();
                button.setLanguage ( getPreviewLanguageKey ( "show" ) );
            }
            else
            {
                overlay.displayProgress ();
                button.setLanguage ( getPreviewLanguageKey ( "hide" ) );
            }
        }
    } );
    overlay.setContent ( button );

    return CollectionUtils.asList ( overlay );
}
 
Example 7
Source File: WebPopupExample.java    From weblaf with GNU General Public License v3.0 5 votes vote down vote up
@NotNull
@Override
protected List<? extends JComponent> createPreviewElements ()
{
    final WebButton button = new WebButton ( getExampleLanguagePrefix () + "show" );
    button.addActionListener ( new ActionListener ()
    {
        @Override
        public void actionPerformed ( final ActionEvent e )
        {
            final WebPopup popup = new WebPopup ( getStyleId (), new AlignLayout () );
            popup.setPadding ( 10 );
            popup.setResizable ( true );
            popup.setDraggable ( true );

            final WebPanel container = new WebPanel ( StyleId.panelTransparent, new BorderLayout ( 5, 5 ) );

            final WebLabel label = new WebLabel ( getExampleLanguagePrefix () + "label", WebLabel.CENTER );
            container.add ( label, BorderLayout.NORTH );

            final String text = LM.get ( getExampleLanguagePrefix () + "text" );
            final WebTextField field = new WebTextField ( text, 20 );
            field.setHorizontalAlignment ( WebTextField.CENTER );
            container.add ( field, BorderLayout.CENTER );

            popup.add ( container );

            popup.pack ();
            popup.setResizable ( true );
            popup.showPopup ( button, 0, button.getHeight () );
        }
    } );
    return CollectionUtils.asList ( button );
}
 
Example 8
Source File: WebPopOverExample.java    From weblaf with GNU General Public License v3.0 5 votes vote down vote up
@NotNull
@Override
protected List<? extends JComponent> createPreviewElements ()
{
    final WebButton button = new WebButton ( getExampleLanguagePrefix () + "show" );
    button.addActionListener ( new ActionListener ()
    {
        @Override
        public void actionPerformed ( final ActionEvent e )
        {
            final Window parent = CoreSwingUtils.getNonNullWindowAncestor ( button );
            final WebPopOver popOver = new WebPopOver ( getStyleId (), parent );
            popOver.setIconImages ( WebLookAndFeel.getImages () );
            popOver.setCloseOnFocusLoss ( true );
            popOver.setPadding ( 10 );

            final WebPanel container = new WebPanel ( StyleId.panelTransparent, new BorderLayout ( 5, 5 ) );

            final WebLabel label = new WebLabel ( getExampleLanguagePrefix () + "label", WebLabel.CENTER );
            container.add ( label, BorderLayout.NORTH );

            final String text = LM.get ( getExampleLanguagePrefix () + "text" );
            final WebTextField field = new WebTextField ( text, 20 );
            field.setHorizontalAlignment ( WebTextField.CENTER );
            container.add ( field, BorderLayout.CENTER );

            popOver.add ( container );

            popOver.show ( button, PopOverDirection.down );
        }
    } );
    return CollectionUtils.asList ( button );
}
 
Example 9
Source File: WebCustomTooltipExample.java    From weblaf with GNU General Public License v3.0 5 votes vote down vote up
@NotNull
@Override
protected List<? extends JComponent> createPreviewElements ()
{
    final WebButton button = new WebButton ( getPreviewLanguagePrefix () + "text" );
    button.addActionListener ( new ActionListener ()
    {
        @Override
        public void actionPerformed ( final ActionEvent e )
        {
            TooltipManager.showOneTimeTooltip ( button, null, getPreviewLanguagePrefix () + "tip", TooltipWay.down );
        }
    } );
    return CollectionUtils.asList ( button );
}
 
Example 10
Source File: WebOverlayExample.java    From weblaf with GNU General Public License v3.0 5 votes vote down vote up
@NotNull
@Override
protected List<? extends JComponent> createPreviewElements ()
{
    final WebOverlay overlay = new WebOverlay ( getStyleId (), SampleInterface.createAuthForm () );

    final WebStyledLabel blockingOverlay = new WebStyledLabel (
            DemoStyles.blockingLayerLabel,
            getPreviewLanguageKey ( "overlay.text" ),
            SwingConstants.CENTER
    );
    NoOpMouseListener.install ( blockingOverlay );
    NoOpKeyListener.install ( blockingOverlay );

    final WebButton control = new WebButton ( getPreviewLanguageKey ( "overlay.show" ) );
    control.addActionListener ( new ActionListener ()
    {
        @Override
        public void actionPerformed ( @NotNull final ActionEvent e )
        {
            if ( blockingOverlay.isShowing () )
            {
                overlay.removeOverlay ( blockingOverlay );
                control.setLanguage ( getPreviewLanguageKey ( "overlay.show" ) );
            }
            else
            {
                overlay.addOverlay ( new FillOverlay ( blockingOverlay ) );
                control.setLanguage ( getPreviewLanguageKey ( "overlay.hide" ) );
            }
        }
    } );

    return CollectionUtils.asList ( overlay, new AlignPanel ( control, SwingConstants.CENTER, SwingConstants.CENTER ) );
}
 
Example 11
Source File: ExplorationSitesPanel.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Constructor.
 * 
 * @param siteNum the exploration site's number.
 * @param site    the exploration site coordinates.
 */
SitePanel(int siteNum, Coordinates site) {
	// Use WebPanel constructor.
	super();

	// Initialize data members.
	this.siteNum = siteNum;
	this.site = site;

	// Set the layout.
	setLayout(new GridLayout(1, 3));

	// Set the border.
	setBorder(new MarsPanelBorder());

	// Create the site number label.
	siteNumLabel = new WebLabel(" Site " + (siteNum + 1));
	add(siteNumLabel);

	// Create the site location label.
	siteLocationLabel = new WebLabel(site.getFormattedString());
	add(siteLocationLabel);

	if (siteNum > 0) {
		// Create the remove button.
		WebButton removeButton = new WebButton("Remove");
		removeButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				// Remove this site panel from the site list.
				setVisible(false);
				siteListPane.remove(getSiteNum());
				updateSiteNumbers();
				siteListPane.validate();
			}
		});
		add(removeButton);
	} else
		add(new WebPanel());
}
 
Example 12
Source File: WebTreeFilterField.java    From weblaf with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Initializes filter icon.
 */
protected void initFilterIcon ()
{
    filterIcon = new WebButton ( StyleId.treefilterfieldSettings.at ( this ), Icons.filter, Icons.filterHover );
    filterIcon.setCursor ( Cursor.getDefaultCursor () );
    filterIcon.addActionListener ( new ActionListener ()
    {
        @Override
        public void actionPerformed ( @NotNull final ActionEvent e )
        {
            settingsMenu.showBelowStart ( filterIcon );
        }
    } );
    setLeadingComponent ( filterIcon );
}
 
Example 13
Source File: ConstructionMissionCustomInfoPanel.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 ConstructionMissionCustomInfoPanel(MainDesktopPane desktop) {
    // Use MissionCustomInfoPanel constructor.
    super();

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

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

    WebPanel contentsPanel = new WebPanel(new GridLayout(4, 1));
    add(contentsPanel, BorderLayout.NORTH);

    WebPanel titlePanel = new WebPanel(new FlowLayout(FlowLayout.CENTER));
    contentsPanel.add(titlePanel);

    String titleLabelString = Msg.getString("ConstructionMissionCustomInfoPanel.titleLabel"); //$NON-NLS-1$
    WebLabel titleLabel = new WebLabel(titleLabelString);
    titlePanel.add(titleLabel);

    WebPanel settlementPanel = new WebPanel(new FlowLayout(FlowLayout.LEFT));
    contentsPanel.add(settlementPanel);

    String settlementLabelString = Msg.getString("ConstructionMissionCustomInfoPanel.settlementLabel"); //$NON-NLS-1$
    WebLabel settlementLabel = new WebLabel(settlementLabelString);
    settlementPanel.add(settlementLabel);

    settlementButton = new WebButton("   ");
    settlementPanel.add(settlementButton);
    settlementButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (mission != null) {
                Settlement settlement = mission.getAssociatedSettlement();
                if (settlement != null) getDesktop().openUnitWindow(settlement, false);
            }
        }
    });

    WebPanel stagePanel = new WebPanel(new FlowLayout(FlowLayout.LEFT));
    contentsPanel.add(stagePanel);

    String stageLabelString = Msg.getString("ConstructionMissionCustomInfoPanel.stageLabel"); //$NON-NLS-1$
    stageLabel = new WebLabel(stageLabelString);
    stagePanel.add(stageLabel);

    WebPanel progressBarPanel = new WebPanel(new FlowLayout(FlowLayout.LEFT));
    contentsPanel.add(progressBarPanel);

    WebProgressBar progressBar = new WebProgressBar();
    progressBarModel = progressBar.getModel();
    progressBar.setStringPainted(true);
    progressBarPanel.add(progressBar);

    WebPanel lowerContentsPanel = new WebPanel(new BorderLayout(0, 0));
    add(lowerContentsPanel, BorderLayout.CENTER);
    
    // Create remaining construction materials label panel.
    WebPanel remainingMaterialsLabelPane = new WebPanel(new FlowLayout(FlowLayout.LEFT));
    lowerContentsPanel.add(remainingMaterialsLabelPane, BorderLayout.NORTH);

    // Create remaining construction materials label.
    String remainingMaterialsLabelString = Msg.getString("ConstructionMissionCustomInfoPanel.remainingMaterialsLabel"); //$NON-NLS-1$
    WebLabel remainingMaterialsLabel = new WebLabel(remainingMaterialsLabelString);
    remainingMaterialsLabelPane.add(remainingMaterialsLabel);

    // Create a scroll pane for the remaining construction materials table.
    WebScrollPane remainingMaterialsScrollPane = new WebScrollPane();
    remainingMaterialsScrollPane.setPreferredSize(new Dimension(-1, -1));
    lowerContentsPanel.add(remainingMaterialsScrollPane, BorderLayout.CENTER);

    // Create the remaining construction materials table and model.
    remainingMaterialsTableModel = new RemainingMaterialsTableModel();
    WebTable remainingMaterialsTable = new WebTable(remainingMaterialsTableModel);
    remainingMaterialsScrollPane.setViewportView(remainingMaterialsTable);

    // Add tooltip.
    setToolTipText(getToolTipString());
}
 
Example 14
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
  }
 
Example 15
Source File: MiningMissionCustomInfoPanel.java    From mars-sim with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Constructor
 * 
 * @param desktop the main desktop.
 */
MiningMissionCustomInfoPanel(MainDesktopPane desktop) {
	// Use JPanel constructor
	super();

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

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

	// Create LUV panel.
	WebPanel luvPane = new WebPanel(new FlowLayout(FlowLayout.LEFT));
	add(luvPane, BorderLayout.NORTH);

	// Create LUV label.
	WebLabel luvLabel = new WebLabel("Light Utility Vehicle: ");
	luvPane.add(luvLabel);

	// Create LUV button.
	luvButton = new WebButton("   ");
	luvButton.setVisible(false);
	luvButton.addActionListener(new ActionListener() {
		public void actionPerformed(ActionEvent e) {
			// Open window for light utility vehicle.
			LightUtilityVehicle luv = mission.getLightUtilityVehicle();
			if (luv != null)
				getDesktop().openUnitWindow(luv, false);
		}
	});
	luvPane.add(luvButton);

	// Create center panel.
	WebPanel centerPane = new WebPanel(new GridLayout(2, 1));
	add(centerPane, BorderLayout.CENTER);

	// Create concentration panel.
	WebPanel concentrationPane = new WebPanel(new BorderLayout());
	centerPane.add(concentrationPane);

	// Create concentration label.
	WebButton concentrationLabel = new WebButton("Mineral Concentrations at Site:");
	concentrationPane.add(concentrationLabel, BorderLayout.NORTH);

	// Create concentration scroll panel.
	WebScrollPane concentrationScrollPane = new WebScrollPane();
	concentrationScrollPane.setPreferredSize(new Dimension(-1, -1));
	concentrationPane.add(concentrationScrollPane, BorderLayout.CENTER);

	// Create concentration table.
	concentrationTableModel = new ConcentrationTableModel();
	WebTable concentrationTable = new WebTable(concentrationTableModel);
	concentrationTable.setDefaultRenderer(Double.class, new NumberCellRenderer(1));
	concentrationScrollPane.setViewportView(concentrationTable);

	// Create excavation panel.
	WebPanel excavationPane = new WebPanel(new BorderLayout());
	centerPane.add(excavationPane);

	// Create excavation label.
	WebLabel excavationLabel = new WebLabel("Minerals Excavated at Site:");
	excavationPane.add(excavationLabel, BorderLayout.NORTH);

	// Create excavation scroll panel.
	WebScrollPane excavationScrollPane = new WebScrollPane();
	excavationScrollPane.setPreferredSize(new Dimension(-1, -1));
	excavationPane.add(excavationScrollPane, BorderLayout.CENTER);

	// Create excavation tabel.
	excavationTableModel = new ExcavationTableModel();
	WebTable excavationTable = new WebTable(excavationTableModel);
	excavationTable.setDefaultRenderer(Double.class, new NumberCellRenderer(2));
	excavationScrollPane.setViewportView(excavationTable);
}
 
Example 16
Source File: MeteorologyStudyFieldMissionCustomInfoPanel.java    From mars-sim with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Constructor.
 * 
 * @param desktop the main desktop pane.
 */
public MeteorologyStudyFieldMissionCustomInfoPanel(MainDesktopPane desktop) {
	// Use MissionCustomInfoPanel constructor.
	super();

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

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

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

	// Create study panel.
	WebPanel studyPanel = new WebPanel(new FlowLayout(FlowLayout.LEFT));
	contentPanel.add(studyPanel);

	// Create science tool button.
	WebButton scienceToolButton = new WebButton(ImageLoader.getIcon(Msg.getString("img.science"))); //$NON-NLS-1$
	scienceToolButton.setMargin(new Insets(1, 1, 1, 1));
	scienceToolButton
			.setToolTipText(Msg.getString("MeteorologyStudyFieldMissionCustomInfoPanel.tooltip.openInScienceTool")); //$NON-NLS-1$
	scienceToolButton.addActionListener(new ActionListener() {
		public void actionPerformed(ActionEvent arg0) {
			displayStudyInScienceTool();
		}
	});
	studyPanel.add(scienceToolButton);

	// Create study title label.
	WebLabel studyTitleLabel = new WebLabel(
			Msg.getString("MeteorologyStudyFieldMissionCustomInfoPanel.meteorologyFieldStudy")); //$NON-NLS-1$
	studyPanel.add(studyTitleLabel);

	// Create study name label.
	studyNameLabel = new WebLabel(""); //$NON-NLS-1$
	studyPanel.add(studyNameLabel);

	// Create researcher panel.
	WebPanel researcherPanel = new WebPanel(new FlowLayout(FlowLayout.LEFT));
	contentPanel.add(researcherPanel);

	// Create researcher title label.
	WebLabel researcherTitleLabel = new WebLabel(
			Msg.getString("MeteorologyStudyFieldMissionCustomInfoPanel.leadResearcher")); //$NON-NLS-1$
	researcherPanel.add(researcherTitleLabel);

	// Create researcher name label.
	researcherNameLabel = new WebLabel(""); //$NON-NLS-1$
	researcherPanel.add(researcherNameLabel);

	// Create study research panel.
	WebPanel studyResearchPanel = new WebPanel(new FlowLayout(FlowLayout.LEFT));
	contentPanel.add(studyResearchPanel);

	// Create study research title label.
	WebLabel studyResearchTitleLabel = new WebLabel(
			Msg.getString("MeteorologyStudyFieldMissionCustomInfoPanel.researchCompletion")); //$NON-NLS-1$
	studyResearchPanel.add(studyResearchTitleLabel);

	// Create study research progress bar.
	studyResearchBar = new WebProgressBar(0, 100);
	studyResearchBar.setStringPainted(true);
	studyResearchPanel.add(studyResearchBar);
}
 
Example 17
Source File: ModifyTransportItemDialog.java    From mars-sim with GNU General Public License v3.0 4 votes vote down vote up
/**
	 * Constructor.
	 * @param owner the owner of this dialog.
	 * @param title title of dialog.
	 * @param transportItem the transport item to modify.
	 */
	public ModifyTransportItemDialog(MainDesktopPane desktop, ResupplyWindow resupplyWindow, String title, Transportable transportItem) {// , boolean isFX) {

		// Use ModalInternalFrame constructor
        super("Modify Mission");

		// Initialize data members.
		this.transportItem = transportItem;
		this.resupplyWindow = resupplyWindow;

		this.setSize(560,500);

		 // Create main panel
        WebPanel mainPane = new WebPanel(new BorderLayout());
        setContentPane(mainPane);

        initEditingPanel();

		mainPane.add(editingPanel, BorderLayout.CENTER);

		// Create the button pane.
		WebPanel buttonPane = new WebPanel(new FlowLayout(FlowLayout.CENTER, 10, 5));

		mainPane.add(buttonPane, BorderLayout.SOUTH);

		// Create commit button.
		// Change button text from "Modify" to "Commit Changes"
		commitButton = new WebButton("Commit Changes");
		commitButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent evt) {
				// Modify transport item and close dialog.
				modifyTransportItem();
			}
		});
		buttonPane.add(commitButton);

		// Create cancel button.
		// Change button text from "Cancel"  to "Discard Changes"
		WebButton cancelButton = new WebButton("Discard Changes");
		cancelButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				// Close dialog.
				dispose();
			}

		});
		buttonPane.add(cancelButton);

        // Add to its own tab pane
//        if (desktop.getMainScene() != null)
//        	desktop.add(this);
//        	//desktop.getMainScene().getDesktops().get(2).add(this);
//        else 
        	desktop.add(this);    

		Dimension desktopSize = desktop.getParent().getSize();
	    Dimension jInternalFrameSize = this.getSize();
	    int width = (desktopSize.width - jInternalFrameSize.width) / 2;
	    int height = (desktopSize.height - jInternalFrameSize.height) / 2;

	    setLocation(width, height);
	    setModal(true);
	    setVisible(true);
	}
 
Example 18
Source File: TabPanelCrew.java    From mars-sim with GNU General Public License v3.0 4 votes vote down vote up
public void initializeUI() {
		uiDone = true;
		
		// Prepare title label.
		WebPanel titlePanel = new WebPanel(new FlowLayout(FlowLayout.CENTER));
		WebLabel titleLabel = new WebLabel(Msg.getString("TabPanelCrew.title"), WebLabel.CENTER); //$NON-NLS-1$
		titleLabel.setFont(new Font("Serif", Font.BOLD, 16));
		titlePanel.add(titleLabel);
		topContentPanel.add(titlePanel);

		// Create crew count panel
		WebPanel crewCountPanel = new WebPanel(new GridLayout(2, 1, 0, 0));
//		crewCountPanel.setBorder(new MarsPanelBorder());
		topContentPanel.add(crewCountPanel);

		// Create crew num label
		crewNumCache = crewable.getCrewNum();
		crewNumLabel = new WebLabel(Msg.getString("TabPanelCrew.crew", crewNumCache), WebLabel.CENTER); //$NON-NLS-1$
		crewCountPanel.add(crewNumLabel);

		// Create crew capacity label
		crewCapacityCache = crewable.getCrewCapacity();
		crewCapLabel = new WebLabel(Msg.getString("TabPanelCrew.crewCapacity", crewCapacityCache), WebLabel.CENTER); //$NON-NLS-1$
		crewCountPanel.add(crewCapLabel);

		// Create crew display panel
		WebPanel crewDisplayPanel = new WebPanel(new FlowLayout(FlowLayout.LEFT));
//		crewDisplayPanel.setBorder(new MarsPanelBorder());
		topContentPanel.add(crewDisplayPanel);

		// Create scroll panel for crew list.
		WebScrollPane crewScrollPanel = new WebScrollPane();
		crewScrollPanel.setPreferredSize(new Dimension(175, 200));
		crewDisplayPanel.add(crewScrollPanel);

		// Create crew list model
		crewListModel = new DefaultListModel<Person>();
		//crewListModel = new DefaultListModel<Unit>();
		crewCache = crewable.getCrew();
		//crewCache = crewable.getUnitCrew();
		Iterator<Person> i = crewCache.iterator();
		//Iterator<Unit> i = crewCache.iterator();
		while (i.hasNext()) crewListModel.addElement(i.next());

		// Create crew list
		crewList = new JList<Person>(crewListModel);
		//crewList = new JList<Unit>(crewListModel);
		crewList.addMouseListener(this);
		crewScrollPanel.setViewportView(crewList);

		// Create crew monitor button
		WebButton monitorButton = new WebButton(ImageLoader.getIcon(Msg.getString("img.monitor"))); //$NON-NLS-1$
		monitorButton.setMargin(new Insets(1, 1, 1, 1));
		monitorButton.addActionListener(this);
		monitorButton.setToolTipText(Msg.getString("TabPanelCrew.tooltip.monitor")); //$NON-NLS-1$
		crewDisplayPanel.add(monitorButton);
	}
 
Example 19
Source File: TabPanelBots.java    From mars-sim with GNU General Public License v3.0 4 votes vote down vote up
public void initializeUI() {
		uiDone = true;

		// Prepare title label.
		WebPanel titlePanel = new WebPanel(new FlowLayout(FlowLayout.CENTER));
		WebLabel titleLabel = new WebLabel(Msg.getString("TabPanelBots.title"), WebLabel.CENTER); //$NON-NLS-1$
		titleLabel.setFont(new Font("Serif", Font.BOLD, 16));
		titlePanel.add(titleLabel);
		topContentPanel.add(titlePanel);
		
		// Create crew count panel
		WebPanel crewCountPanel = new WebPanel(new GridLayout(2, 1, 0, 0));
//		crewCountPanel.setBorder(new MarsPanelBorder());
		topContentPanel.add(crewCountPanel);

		// Create crew num label
		crewNumCache = crewable.getRobotCrewNum();
		crewNumLabel = new WebLabel(Msg.getString("TabPanelBots.crew", crewNumCache), WebLabel.CENTER); //$NON-NLS-1$
		crewCountPanel.add(crewNumLabel);

		// Create crew capacity label
		crewCapacityCache = crewable.getRobotCrewCapacity();
		crewCapLabel = new WebLabel(Msg.getString("TabPanelBots.crewCapacity", crewCapacityCache), WebLabel.CENTER); //$NON-NLS-1$
		crewCountPanel.add(crewCapLabel);

		// Create crew display panel
		WebPanel crewDisplayPanel = new WebPanel(new FlowLayout(FlowLayout.LEFT));
//		crewDisplayPanel.setBorder(new MarsPanelBorder());
		topContentPanel.add(crewDisplayPanel);

		// Create scroll panel for crew list.
		WebScrollPane crewScrollPanel = new WebScrollPane();
		crewScrollPanel.setPreferredSize(new Dimension(175, 100));
		crewDisplayPanel.add(crewScrollPanel);

		// Create crew list model
		crewListModel = new DefaultListModel<Robot>();
		//crewListModel = new DefaultListModel<Unit>();
		crewCache = crewable.getRobotCrew();
		//crewCache = crewable.getUnitCrew();
		Iterator<Robot> i = crewCache.iterator();
		//Iterator<Unit> i = crewCache.iterator();
		while (i.hasNext()) crewListModel.addElement(i.next());

		// Create crew list
		crewList = new JList<Robot>(crewListModel);
		//crewList = new JList<Unit>(crewListModel);
		crewList.addMouseListener(this);
		crewScrollPanel.setViewportView(crewList);

		// Create crew monitor button
		WebButton monitorButton = new WebButton(ImageLoader.getIcon(Msg.getString("img.monitor"))); //$NON-NLS-1$
		monitorButton.setMargin(new Insets(1, 1, 1, 1));
		monitorButton.addActionListener(this);
		monitorButton.setToolTipText(Msg.getString("TabPanelBots.tooltip.monitor")); //$NON-NLS-1$
		crewDisplayPanel.add(monitorButton);
	}
 
Example 20
Source File: TabPanelBots.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);

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

		// Create robot count panel
		WebPanel countPanel = new WebPanel(new GridLayout(3, 1, 0, 0));
//		countPanel.setBorder(new MarsPanelBorder());
		topContentPanel.add(countPanel);

		// Create robot num label
		robotNumCache = settlement.getNumBots();
		robotNumLabel = new WebLabel(Msg.getString("TabPanelBots.associated", robotNumCache), WebLabel.CENTER); // $NON-NLS-1$
		countPanel.add(robotNumLabel);

		// Create robot indoor label
		robotIndoorCache = settlement.getNumBots();
		robotIndoorLabel = new WebLabel(Msg.getString("TabPanelBots.indoor", robotIndoorCache),
				WebLabel.CENTER); // $NON-NLS-1$
		countPanel.add(robotIndoorLabel);
		
		// Create robot capacity label
		robotCapacityCache = settlement.getRobotCapacity();
		robotCapLabel = new WebLabel(Msg.getString("TabPanelBots.capacity", robotCapacityCache), WebLabel.CENTER); // $NON-NLS-1$
		countPanel.add(robotCapLabel);

		// Create spring layout robot display panel
		WebPanel robotDisplayPanel = new WebPanel(new SpringLayout());// FlowLayout(FlowLayout.LEFT));
//		robotDisplayPanel.setBorder(new MarsPanelBorder());
		topContentPanel.add(robotDisplayPanel);

		// Create scroll panel for robot list.
		robotScrollPanel = new WebScrollPane();
		robotScrollPanel.setPreferredSize(new Dimension(120, 250));
		robotDisplayPanel.add(robotScrollPanel);

		// Create robot list model
		robotListModel = new RobotListModel(settlement);

		// Create robot list
		robotList = new JList<Robot>(robotListModel);
		robotList.addMouseListener(this);
		robotScrollPanel.setViewportView(robotList);

		// Create robot monitor button
		WebButton monitorButton = new WebButton(ImageLoader.getIcon(Msg.getString("img.monitor"))); //$NON-NLS-1$
		monitorButton.setMargin(new Insets(1, 1, 1, 1));
		monitorButton.addActionListener(this);
		monitorButton.setToolTipText(Msg.getString("TabPanelBots.tooltip.monitor")); //$NON-NLS-1$

		WebPanel buttonPane = new WebPanel(new FlowLayout(FlowLayout.CENTER));
//		buttonPane.setPreferredSize(new Dimension(25, 25));
		buttonPane.add(monitorButton);
		
		robotDisplayPanel.add(buttonPane);
		
		// Lay out the spring panel.
		SpringUtilities.makeCompactGrid(robotDisplayPanel, 2, 1, // rows, cols
				30, 10, // initX, initY
				10, 10); // xPad, yPad
	}