All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.netbeans.modules.welcome.ui.ShowNextTime Maven / Gradle / Ivy

The newest version!
/**
 * Copyright (C) 2008-2013 LimeTri. All rights reserved.
 *
 * AgroSense is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * There are special exceptions to the terms and conditions of the GPLv3 as it is applied to
 * this software, see the FLOSS License Exception
 * .
 *
 * AgroSense is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with AgroSense.  If not, see .
 */
package org.netbeans.modules.welcome.ui;

import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import javax.swing.JCheckBox;
import javax.swing.JPanel;
import org.netbeans.modules.welcome.WelcomeOptions;
import org.netbeans.modules.welcome.content.Constants;
import org.openide.util.NbBundle;

/**
 *
 * @author S. Aubrecht
 */
@NbBundle.Messages({"LBL ShowOnStartup=Show On Startup",
                    "ACN_ShowOnStartup=Show Welcome Screen on startup",
                    "ACD_ShowOnStartup=Checkbox to show or hide the Welcome Screen on next NetBeans startup"})
final class ShowNextTime extends JPanel
        implements ActionListener, Constants, PropertyChangeListener {

    private JCheckBox button;

    /** Creates a new instance of RecentProjects */
    public ShowNextTime() {
        super( new BorderLayout() );
        setOpaque(false);

        button = new JCheckBox(Bundle.LBL_ShowOnStartup()); 
        button.setSelected( WelcomeOptions.getDefault().isShowOnStartup() );
        button.setOpaque( false );
        button.getAccessibleContext().setAccessibleName(Bundle.ACN_ShowOnStartup());
        button.getAccessibleContext().setAccessibleDescription(Bundle.ACD_ShowOnStartup());
        
        add( button, BorderLayout.CENTER );
        button.addActionListener( this );
    }
    
    @Override
    public void actionPerformed(ActionEvent e) {
        WelcomeOptions.getDefault().setShowOnStartup( button.isSelected() );
    }

    @Override
    public void addNotify() {
        super.addNotify();
        WelcomeOptions.getDefault().addPropertyChangeListener( this );
    }

    @Override
    public void removeNotify() {
        super.removeNotify();
        WelcomeOptions.getDefault().removePropertyChangeListener( this );
    }

    @Override
    public void propertyChange(PropertyChangeEvent evt) {
        button.setSelected( WelcomeOptions.getDefault().isShowOnStartup() );
    }
    
    
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy