Java Code Examples for com.alee.laf.WebLookAndFeel

The following examples show how to use com.alee.laf.WebLookAndFeel. These examples are extracted from open source projects. 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 Project: mars-sim   Source File: MainWindow.java    License: GNU General Public License v3.0 7 votes vote down vote up
public void initializeWeblaf() {

		try {
			// use the weblaf skin
//			UIManager.setLookAndFeel(new WebLookAndFeel());
//				WebLookAndFeel.setForceSingleEventsThread ( true );
			WebLookAndFeel.install();
			UIManagers.initialize();
			
			// Installing our extension for default skin
//	        StyleManager.addExtensions ( new XmlSkinExtension ( MainWindow.class, "SimpleExtension.xml" ) );

            // They contain all custom styles demo application uses
//            StyleManager.addExtensions ( new AdaptiveExtension (), new LightSkinExtension (), new DarkSkinExtension () );

		} catch (Exception e) {
			logger.log(Level.WARNING, Msg.getString("MainWindow.log.lookAndFeelError"), e); //$NON-NLS-1$
		}

	}
 
Example 2
Source Project: JByteMod-Beta   Source File: LookUtils.java    License: GNU General Public License v2.0 6 votes vote down vote up
public static void setLAF() {
  try {
    JByteMod.LOGGER.log("Setting default Look and Feel");
    if (JByteMod.ops.get("use_weblaf").getBoolean()) {
      WebLookAndFeel.install();
    } else {
      if (!changeLAF("javax.swing.plaf.nimbus.NimbusLookAndFeel")) {
        JByteMod.LOGGER.err("Failed to set Nimbus Look and Feel, trying to use WebLaF");
        WebLookAndFeel.install();
      }
    }
  } catch (Throwable t) {
    t.printStackTrace();
    JByteMod.LOGGER.err("Failed to set Look and Feel");
  }
}
 
Example 3
Source Project: mars-sim   Source File: TexturedText.java    License: GNU General Public License v3.0 6 votes vote down vote up
public static void main(String[] args) {
	    JFrame f = new JFrame();
	    WebLookAndFeel.install();
	    JPanel panel = new JPanel(new GridLayout(1, 17));
	    f.getContentPane().add(panel);
//	for (int i=0; i<17; i++) {
//		WebStyledLabel icon = new WebStyledLabel (WebLookAndFeel.getIcon(i));
//		panel.add(icon);
//	}
   

//    f.getContentPane().add(new TexturedText());
	
    f.setSize(800, 200);
    f.show();

  }
 
Example 4
/**
 * Initializes {@link WebLookAndFeel}.
 */
@BeforeClass
public static void initialize ()
{
    if ( !SystemUtils.isHeadlessEnvironment () )
    {
        CoreSwingUtils.invokeAndWait ( new Runnable ()
        {
            @Override
            public void run ()
            {
                WebLookAndFeel.setForceSingleEventsThread ( true );
                WebLookAndFeel.install ();
                LanguageManager.addDictionary ( new Dictionary (
                        new ClassResource ( ComponentInstantiationTest.class, "resources/language.xml" )
                ) );
            }
        } );
    }
}
 
Example 5
@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 6
Source Project: weblaf   Source File: JDialogExample.java    License: 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 Window parent = CoreSwingUtils.getNonNullWindowAncestor ( button );
            final String title = getExampleLanguagePrefix () + "content";
            final JDialog dialog = new JDialog ( parent );
            UILanguageManager.registerComponent ( dialog.getRootPane (), title );
            dialog.getRootPane ().putClientProperty ( StyleId.STYLE_PROPERTY, getStyleId () );
            dialog.setIconImages ( WebLookAndFeel.getImages () );
            dialog.add ( new WebLabel ( title, WebLabel.CENTER ) );
            dialog.setSize ( 500, 400 );
            dialog.setLocationRelativeTo ( DemoApplication.getInstance () );
            dialog.setDefaultCloseOperation ( WindowConstants.DISPOSE_ON_CLOSE );
            dialog.setVisible ( true );
        }
    } );
    return CollectionUtils.asList ( button );
}
 
Example 7
Source Project: weblaf   Source File: WebSplitButtonExample.java    License: GNU General Public License v3.0 6 votes vote down vote up
@NotNull
@Override
protected List<? extends JComponent> createPreviewElements ()
{
    final WebSplitButton button = new WebSplitButton ( getStyleId (), "Select one..." );
    button.setPopupMenu ( createSamplePopupMenu ( button, false, true ) );

    final WebSplitButton first = new WebSplitButton ( getStyleId (), "Select one..." );
    first.setMenuIcon ( DemoIcons.menu16 );
    first.setPopupMenu ( createSamplePopupMenu ( first, false, true ) );

    final WebSplitButton second = new WebSplitButton ( getStyleId (), "Select one...", WebLookAndFeel.getIcon ( 16 ) );
    second.setPopupMenu ( createSamplePopupMenu ( second, true, true ) );

    final WebSplitButton icon = new WebSplitButton ( getStyleId (), "Select one...", WebLookAndFeel.getIcon ( 16 ) );
    icon.setMenuIcon ( DemoIcons.menu16 );
    icon.setPopupMenu ( createSamplePopupMenu ( icon, true, true ) );

    return CollectionUtils.asList ( button, new GroupPane ( first, second ), icon );
}
 
Example 8
Source Project: weblaf   Source File: JButtonExample.java    License: GNU General Public License v3.0 6 votes vote down vote up
@NotNull
@Override
protected List<? extends JComponent> createPreviewElements ()
{
    final JButton basic = new JButton ();
    basic.putClientProperty ( StyleId.STYLE_PROPERTY, getStyleId () );
    UILanguageManager.registerComponent ( basic, getExampleLanguageKey ( "plain.text.basic" ) );

    final JButton group1 = new JButton ();
    group1.putClientProperty ( StyleId.STYLE_PROPERTY, getStyleId () );
    UILanguageManager.registerComponent ( group1, getExampleLanguageKey ( "plain.text.group1" ) );

    final JButton group2 = new JButton ();
    group2.putClientProperty ( StyleId.STYLE_PROPERTY, getStyleId () );
    UILanguageManager.registerComponent ( group2, getExampleLanguageKey ( "plain.text.group2" ) );

    final JButton group3 = new JButton ();
    group3.putClientProperty ( StyleId.STYLE_PROPERTY, getStyleId () );
    UILanguageManager.registerComponent ( group3, getExampleLanguageKey ( "plain.text.group3" ) );

    final JButton icon = new JButton ( WebLookAndFeel.getIcon ( 16 ) );
    icon.putClientProperty ( StyleId.STYLE_PROPERTY, getStyleId () );
    UILanguageManager.registerComponent ( icon, getExampleLanguageKey ( "plain.text.icon" ) );

    return CollectionUtils.asList ( basic, new GroupPane ( group1, group2, group3 ), icon );
}
 
Example 9
Source Project: weblaf   Source File: JButtonExample.java    License: GNU General Public License v3.0 6 votes vote down vote up
@NotNull
@Override
protected List<? extends JComponent> createPreviewElements ()
{
    final JButton basic = new JButton ( WebLookAndFeel.getIcon ( 16 ) );
    basic.putClientProperty ( StyleId.STYLE_PROPERTY, getStyleId () );

    final JButton group1 = new JButton ( WebLookAndFeel.getIcon ( 16 ) );
    group1.putClientProperty ( StyleId.STYLE_PROPERTY, getStyleId () );

    final JButton group2 = new JButton ( WebLookAndFeel.getIcon ( 16 ) );
    group2.putClientProperty ( StyleId.STYLE_PROPERTY, getStyleId () );

    final JButton group3 = new JButton ( WebLookAndFeel.getIcon ( 16 ) );
    group3.putClientProperty ( StyleId.STYLE_PROPERTY, getStyleId () );

    return CollectionUtils.asList ( basic, new GroupPane ( group1, group2, group3 ) );
}
 
Example 10
Source Project: weblaf   Source File: JButtonExample.java    License: GNU General Public License v3.0 6 votes vote down vote up
@NotNull
@Override
protected List<? extends JComponent> createPreviewElements ()
{
    final JButton basic = new JButton ();
    basic.putClientProperty ( StyleId.STYLE_PROPERTY, getStyleId () );
    UILanguageManager.registerComponent ( basic, getExampleLanguageKey ( "styled.text.basic" ) );

    final JButton group1 = new JButton ();
    group1.putClientProperty ( StyleId.STYLE_PROPERTY, getStyleId () );
    UILanguageManager.registerComponent ( group1, getExampleLanguageKey ( "styled.text.group1" ) );

    final JButton group2 = new JButton ();
    group2.putClientProperty ( StyleId.STYLE_PROPERTY, getStyleId () );
    UILanguageManager.registerComponent ( group2, getExampleLanguageKey ( "styled.text.group2" ) );

    final JButton group3 = new JButton ();
    group3.putClientProperty ( StyleId.STYLE_PROPERTY, getStyleId () );
    UILanguageManager.registerComponent ( group3, getExampleLanguageKey ( "styled.text.group3" ) );

    final JButton icon = new JButton ( WebLookAndFeel.getIcon ( 16 ) );
    icon.putClientProperty ( StyleId.STYLE_PROPERTY, getStyleId () );
    UILanguageManager.registerComponent ( icon, getExampleLanguageKey ( "styled.text.icon" ) );

    return CollectionUtils.asList ( basic, new GroupPane ( group1, group2, group3 ), icon );
}
 
Example 11
Source Project: weblaf   Source File: JToggleButtonExample.java    License: GNU General Public License v3.0 6 votes vote down vote up
@NotNull
@Override
protected List<? extends JComponent> createPreviewElements ()
{
    final JToggleButton basic = new JToggleButton ( "", true );
    basic.putClientProperty ( StyleId.STYLE_PROPERTY, getStyleId () );
    UILanguageManager.registerComponent ( basic, getExampleLanguageKey ( "plain.text.basic" ) );

    final JToggleButton group1 = new JToggleButton ( "", true );
    group1.putClientProperty ( StyleId.STYLE_PROPERTY, getStyleId () );
    UILanguageManager.registerComponent ( group1, getExampleLanguageKey ( "plain.text.group1" ) );

    final JToggleButton group2 = new JToggleButton ();
    group2.putClientProperty ( StyleId.STYLE_PROPERTY, getStyleId () );
    UILanguageManager.registerComponent ( group2, getExampleLanguageKey ( "plain.text.group2" ) );

    final JToggleButton group3 = new JToggleButton ();
    group3.putClientProperty ( StyleId.STYLE_PROPERTY, getStyleId () );
    UILanguageManager.registerComponent ( group3, getExampleLanguageKey ( "plain.text.group3" ) );

    final JToggleButton icon = new JToggleButton ( WebLookAndFeel.getIcon ( 16 ) );
    icon.putClientProperty ( StyleId.STYLE_PROPERTY, getStyleId () );
    UILanguageManager.registerComponent ( icon, getExampleLanguageKey ( "plain.text.icon" ) );

    return CollectionUtils.asList ( basic, new GroupPane ( group1, group2, group3 ), icon );
}
 
Example 12
Source Project: weblaf   Source File: JToggleButtonExample.java    License: GNU General Public License v3.0 6 votes vote down vote up
@NotNull
@Override
protected List<? extends JComponent> createPreviewElements ()
{
    final JToggleButton basic = new JToggleButton ( "", true );
    basic.putClientProperty ( StyleId.STYLE_PROPERTY, getStyleId () );
    UILanguageManager.registerComponent ( basic, getExampleLanguageKey ( "styled.text.basic" ) );

    final JToggleButton group1 = new JToggleButton ( "", true );
    group1.putClientProperty ( StyleId.STYLE_PROPERTY, getStyleId () );
    UILanguageManager.registerComponent ( group1, getExampleLanguageKey ( "styled.text.group1" ) );

    final JToggleButton group2 = new JToggleButton ();
    group2.putClientProperty ( StyleId.STYLE_PROPERTY, getStyleId () );
    UILanguageManager.registerComponent ( group2, getExampleLanguageKey ( "styled.text.group2" ) );

    final JToggleButton group3 = new JToggleButton ();
    group3.putClientProperty ( StyleId.STYLE_PROPERTY, getStyleId () );
    UILanguageManager.registerComponent ( group3, getExampleLanguageKey ( "styled.text.group3" ) );

    final JToggleButton icon = new JToggleButton ( WebLookAndFeel.getIcon ( 16 ) );
    icon.putClientProperty ( StyleId.STYLE_PROPERTY, getStyleId () );
    UILanguageManager.registerComponent ( icon, getExampleLanguageKey ( "styled.text.icon" ) );

    return CollectionUtils.asList ( basic, new GroupPane ( group1, group2, group3 ), icon );
}
 
Example 13
Source Project: weblaf   Source File: InterfaceInspector.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * Returns separate {@link WebDialog} with inspector for the specified {@link Component}.
 * That {@link WebDialog} will be displayed straight away on the screen.
 *
 * @param parent    parent {@link Component} for {@link WebDialog}
 * @param inspected {@link Component} to inspect
 * @return separate {@link WebDialog} with inspector for the specified {@link Component}
 */
@NotNull
public static WebDialog showDialog ( @Nullable final Component parent, @Nullable final Component inspected )
{
    final WebDialog dialog = new WebDialog ( parent );
    dialog.setIconImages ( WebLookAndFeel.getImages () );
    dialog.add ( new InterfaceInspector ( inspected ) );
    ProprietaryUtils.setUtilityWindowType ( dialog );
    dialog.setModalExclusionType ( Dialog.ModalExclusionType.APPLICATION_EXCLUDE );
    dialog.setModal ( false );
    dialog.pack ();
    dialog.setLocationRelativeTo ( inspected );
    // dialog.setAttachedTo ( ? );
    dialog.setVisible ( true );
    return dialog;
}
 
Example 14
Source Project: weblaf   Source File: JLabelExample.java    License: GNU General Public License v3.0 6 votes vote down vote up
@NotNull
@Override
protected List<? extends JComponent> createPreviewElements ()
{
    final JLabel leading = new JLabel ( "Leading text", JLabel.LEADING );
    leading.putClientProperty ( StyleId.STYLE_PROPERTY, getStyleId () );

    final ImageIcon icon = WebLookAndFeel.getIcon ( 16 );
    final JLabel center = new JLabel ( "Centered text with icon", icon, JLabel.CENTER );
    center.putClientProperty ( StyleId.STYLE_PROPERTY, getStyleId () );

    final JLabel trailing = new JLabel ( "Trailing text", JLabel.TRAILING );
    trailing.putClientProperty ( StyleId.STYLE_PROPERTY, getStyleId () );

    return CollectionUtils.asList ( leading, center, trailing );
}
 
Example 15
Source Project: weblaf   Source File: MagnifierGlass.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * Disposes {@link MagnifierGlass}.
 */
public void dispose ()
{
    // Event Dispatch Thread check
    WebLookAndFeel.checkEventDispatchThread ();

    // Changing visibility flag
    setEnabled ( false );

    // Updating buffer image
    updatePreview ();

    // Hiding magnifier
    disposeFromGlassPane ();

    // Stopping force updater
    restartForceUpdater ();

    // Removing global AWT event listeners
    Toolkit.getDefaultToolkit ().removeAWTEventListener ( listener );

    // Cleaning up
    zoomProvider = null;
    defaultCursor = null;
}
 
Example 16
Source Project: weblaf   Source File: DemoApplication.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * Constructs new {@link DemoApplication}.
 */
private DemoApplication ()
{
    super ();
    version = new Version ( DemoApplication.class );

    setIconImages ( WebLookAndFeel.getImages () );
    updateTitle ();

    initializeDocks ();
    initializeToolBar ();
    initializeStatus ();
    setDefaultCloseOperation ( WindowConstants.EXIT_ON_CLOSE );
    registerSettings ( new Configuration<WindowState> ( "application", new SerializableSupplier<WindowState> ()
    {
        @Override
        public WindowState get ()
        {
            return new WindowState ( new Dimension ( 1200, 820 ) );
        }
    } ) );
}
 
Example 17
Source Project: weblaf   Source File: NinePatchEditor.java    License: GNU General Public License v3.0 6 votes vote down vote up
public NinePatchEditor ()
{
    super ();

    ninePatchImage = null;
    ninePatchIcon = null;

    WebLookAndFeel.setOrientation ( this );
    setOpaque ( false );
    setFocusable ( true );
    setLayout ( new TableLayout ( new double[][]{ { RULER_LENGTH, TableLayout.PREFERRED, TableLayout.FILL },
            { RULER_LENGTH, TableLayout.PREFERRED, TableLayout.FILL } } ) );

    setFont ( new JLabel ().getFont ().deriveFont ( 10f ) );

    view = new WebScrollPane ( StyleId.scrollpaneTransparentHovering, this );

    final NinePatchEditorMouseAdapter mouseAdapter = new NinePatchEditorMouseAdapter ();
    addMouseListener ( mouseAdapter );
    addMouseMotionListener ( mouseAdapter );
    addMouseWheelListener ( mouseAdapter );
}
 
Example 18
Source Project: weblaf   Source File: AsyncTreeModel.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * Uninstalls this {@link AsyncTreeModel} from the specified {@link WebAsyncTree}.
 *
 * @param tree {@link WebAsyncTree}
 */
public void uninstall ( @NotNull final WebAsyncTree<N> tree )
{
    WebLookAndFeel.checkEventDispatchThread ();
    removeAsyncTreeModelListener ( tree );
    for ( final Map.Entry<String, N> entry : nodeById.entrySet () )
    {
        final N node = entry.getValue ();
        node.detachLoadIconObserver ( tree );
    }
    this.rootNode = null;
    this.tree = null;
    this.nodeById = null;
    this.rawNodeChildrenCache = null;
    this.nodeCached = null;
}
 
Example 19
Source Project: weblaf   Source File: AsyncTreeModel.java    License: GNU General Public License v3.0 6 votes vote down vote up
@NotNull
@Override
public N getChild ( @NotNull final Object parent, final int index )
{
    // Event Dispatch Thread check
    WebLookAndFeel.checkEventDispatchThread ();

    // Ensure model is installed
    checkInstalled ();

    final N child;
    final N node = ( N ) parent;
    if ( areChildrenLoaded ( node ) )
    {
        child = ( N ) super.getChild ( parent, index );
    }
    else
    {
        throw new RuntimeException ( "There are no loaded children at node: " + node );
    }
    return child;
}
 
Example 20
Source Project: weblaf   Source File: StyleData.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * Removes skin currently applied to the specified component.
 * This will uninstall component skin without installing any other on top of previous one and will leave component empty.
 *
 * @return previously applied skin
 */
@Nullable
protected Skin removeSkin ()
{
    // Event Dispatch Thread check
    WebLookAndFeel.checkEventDispatchThread ();

    // Checking previous skin existence
    final Skin oldSkin = this.skin;
    if ( this.skin != null )
    {
        // Retrieving component and checking its existence
        final JComponent component = getComponent ();

        // Removing skin
        this.skin.removeSkin ( component );
        this.skin = null;
    }
    return oldSkin;
}
 
Example 21
Source Project: weblaf   Source File: StyleData.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * Removes related style child.
 *
 * @param child related style child
 */
protected void removeChild ( @NotNull final JComponent child )
{
    // Event Dispatch Thread check
    WebLookAndFeel.checkEventDispatchThread ();

    // Removing child
    if ( children != null )
    {
        final Iterator<WeakReference<JComponent>> iterator = children.iterator ();
        while ( iterator.hasNext () )
        {
            final WeakReference<JComponent> next = iterator.next ();
            if ( next.get () == child )
            {
                iterator.remove ();
            }
        }
    }
}
 
Example 22
Source Project: weblaf   Source File: SettingsProcessor.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * Constructs new {@link SettingsProcessor} for the specified {@link JComponent} and {@link Configuration}.
 *
 * @param component     {@link JComponent} which settings are being managed
 * @param configuration {@link Configuration}
 */
public SettingsProcessor ( @NotNull final C component, @NotNull final K configuration )
{
    // Event Dispatch Thread check
    WebLookAndFeel.checkEventDispatchThread ();

    // Component and configuration
    this.component = component;
    this.configuration = configuration;

    // Performing initial settings load
    loadInitialSettings ();

    // Initializing processor settings
    initialize ();
}
 
Example 23
Source Project: weblaf   Source File: UISettingsManager.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * Saves settings for the specified {@link JComponent} if it is registered.
 *
 * @param component {@link JComponent} to save settings for
 */
public static void saveSettings ( final JComponent component )
{
    // Event Dispatch Thread check
    WebLookAndFeel.checkEventDispatchThread ();

    // Saving settings
    if ( settingsProcessors.contains ( component ) )
    {
        settingsProcessors.get ( component ).save ( false );
    }
    else
    {
        final String msg = "Processor is not registered for component: %s";
        throw new SettingsException ( String.format ( msg, component ) );
    }
}
 
Example 24
Source Project: weblaf   Source File: ExTreeModel.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * Returns root node provided by {@link ExTreeDataProvider}.
 *
 * @return root node provided by {@link ExTreeDataProvider}
 */
@NotNull
protected N loadRootNode ()
{
    // Event Dispatch Thread check
    WebLookAndFeel.checkEventDispatchThread ();

    // Ensure model is installed
    checkInstalled ();

    // Retrieving root node
    final N rootNode = getDataProvider ().getRoot ();

    // Caching root node
    cacheNodeById ( rootNode );
    cacheParentId ( rootNode, null );

    return rootNode;
}
 
Example 25
Source Project: weblaf   Source File: StyleEditor.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * {@link StyleEditor} main launch method.
 *
 * @param args editor arguments
 */
public static void main ( final String[] args )
{
    CoreSwingUtils.enableEventQueueLogging ();
    CoreSwingUtils.invokeLater ( new Runnable ()
    {
        @Override
        public void run ()
        {
            final Class<? extends Skin> skinClass = WebLightSkin.class;

            // Custom StyleEditor skin for WebLaF
            WebLookAndFeel.setForceSingleEventsThread ( true );
            WebLookAndFeel.install ( skinClass );

            // Edited skin file
            final ClassResource skin = new ClassResource ( skinClass, "resources/web-light-skin.xml" );

            // Displaying StyleEditor
            final StyleEditor styleEditor = new StyleEditor ( skin );
            styleEditor.setVisible ( true );
        }
    } );
}
 
Example 26
Source Project: weblaf   Source File: WebExTree.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public void setFilter ( @Nullable final Filter<N> filter )
{
    // Event Dispatch Thread check
    WebLookAndFeel.checkEventDispatchThread ();

    // Ensure parameter changed
    if ( filter != getFilter () )
    {
        final Filter<N> old = getFilter ();
        this.filter = filter;
        filter ();
        firePropertyChange ( FILTER_PROPERTY, old, filter );
    }
}
 
Example 27
Source Project: weblaf   Source File: LazyContent.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * Removes currently added content {@link JComponent}.
 */
protected void removeCurrentContent ()
{
    // Event Dispatch Thread check
    WebLookAndFeel.checkEventDispatchThread ();

    // Ensure old content exists
    if ( content != null && content.getParent () == container )
    {
        contentIndex = container.getComponentZOrder ( content );
        container.remove ( content );
    }
}
 
Example 28
Source Project: weblaf   Source File: ExTreeModel.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * Inserts a list of child nodes into parent node.
 * This method might be used to manually change tree node children without causing any structure corruptions.
 *
 * @param children list of new child nodes
 * @param parent   parent node
 * @param index    insert index
 */
@Override
public void insertNodesInto ( @NotNull final List<N> children, @NotNull final N parent, final int index )
{
    // Event Dispatch Thread check
    WebLookAndFeel.checkEventDispatchThread ();

    // Ensure model is installed
    checkInstalled ();

    // Caching nodes
    addRawChildren ( parent, children, index );
    cacheNodesById ( children );
    cacheParentId ( children, parent.getId () );

    // Clearing nodes children caches
    // That might be required in case nodes were moved inside of the tree
    clearRawChildren ( children, false );

    // Performing actual nodes insertion
    super.insertNodesInto ( children, parent, Math.min ( index, parent.getChildCount () ) );

    // Loading data for newly added nodes
    for ( final N child : children )
    {
        loadTreeData ( child );
    }

    // Updating parent node sorting and filtering
    filterAndSort ( parent, false );
}
 
Example 29
Source Project: mars-sim   Source File: DynamicMenu.java    License: GNU General Public License v3.0 5 votes vote down vote up
protected WebDynamicMenu createMenu ()
{
    final WebDynamicMenu menu = new WebDynamicMenu ();
    menu.setType ( ( DynamicMenuType ) type.getSelectedItem () );
    menu.setHideType ( ( DynamicMenuType ) hidingType.getSelectedItem () );
    menu.setRadius ( Integer.parseInt ( radius.getText () ) );
    menu.setFadeStepSize ( 0.07f );

    final int items = Integer.parseInt ( amount.getText () );
    for ( int i = 1; i <= items; i++ )
    {
        final ImageIcon icon = WebLookAndFeel.getIcon ( 24 );
        final ActionListener action = new ActionListener ()
        {
            @Override
            public void actionPerformed ( final ActionEvent e )
            {
                System.out.println ( icon );
            }
        };
        final WebDynamicMenuItem item = new WebDynamicMenuItem ( icon, action );
        item.setMargin ( new Insets ( 8, 8, 8, 8 ) );
        menu.addItem ( item );
    }

    return menu;
}
 
Example 30
Source Project: weblaf   Source File: WebComboBoxUI.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public void installUI ( final JComponent c )
{
    // Creating listener list before any operations
    listenerList = new EventListenerList ();

    super.installUI ( c );

    // Listeners
    if ( popup instanceof JComponent )
    {
        visibilityListener = new PropertyChangeListener ()
        {
            @Override
            public void propertyChange ( final PropertyChangeEvent evt )
            {
                if ( Objects.notEquals ( evt.getOldValue (), evt.getNewValue () ) )
                {
                    firePopupVisibilityChanged ( ( Boolean ) evt.getNewValue () );
                }
            }
        };
        ( ( JComponent ) popup ).addPropertyChangeListener ( WebLookAndFeel.VISIBLE_PROPERTY, visibilityListener );
    }
    editorChangeListener = new PropertyChangeListener ()
    {
        @Override
        public void propertyChange ( final PropertyChangeEvent evt )
        {
            if ( Objects.equals ( evt.getPropertyName (), WebComboBox.EDITOR_PROPERTY ) )
            {
                updateEditor ( comboBox.getEditor () );
            }
        }
    };
    comboBox.addPropertyChangeListener ( editorChangeListener );

    // Applying skin
    StyleManager.installSkin ( comboBox );
}