Package com.alee.laf.toolbar

Examples of com.alee.laf.toolbar.WebToolBar


    {
        final WebPanel editorPanel = new WebPanel ();

        //

        toolBar = new WebToolBar ( WebToolBar.HORIZONTAL );
        toolBar.setToolbarStyle ( ToolbarStyle.attached );
        toolBar.setFloatable ( false );
        editorPanel.add ( toolBar, BorderLayout.NORTH );

        final WebButton open = new WebButton ( OPEN_ICON );
View Full Code Here


            }
        } );

        //

        final WebToolBar toolBar = new WebToolBar ( WebToolBar.HORIZONTAL );
        toolBar.setToolbarStyle ( ToolbarStyle.attached );
        toolBar.setFloatable ( false );
        previewPanel.add ( toolBar, "0,0,2,0" );

        final boolean si = SettingsManager.get ( "NinePatchEditor", "preview.showIcon", false );
        preview.setIcon ( si ? ICON : null );

        final WebToggleButton showIcon = new WebToggleButton ( SHOW_ICON_ICON );
        showIcon.setLanguage ( "weblaf.ex.npeditor.preview.showIcon" );
        showIcon.setRolloverDecoratedOnly ( true );
        showIcon.setSelected ( si );
        showIcon.addActionListener ( new ActionListener ()
        {
            @Override
            public void actionPerformed ( final ActionEvent e )
            {
                final boolean show = showIcon.isSelected ();
                SettingsManager.set ( "NinePatchEditor", "preview.showIcon", show );
                preview.setIcon ( show ? ICON : null );
            }
        } );
        toolBar.add ( showIcon );

        final boolean st = SettingsManager.get ( "NinePatchEditor", "preview.showText", true );
        final WebToggleButton showText = new WebToggleButton ( SHOW_TEXT_ICON );
        showText.setLanguage ( "weblaf.ex.npeditor.preview.showText" );
        showText.setCursor ( Cursor.getDefaultCursor () );
        showText.setDrawFocus ( false );
        showText.setRolloverDecoratedOnly ( true );
        showText.setRolloverDarkBorderOnly ( false );
        showText.setDrawRight ( false );
        showText.setDrawRightLine ( true );
        showText.setShadeWidth ( 0 );
        showText.setSelected ( st );

        final String defaultPreviewText = LanguageManager.get ( "weblaf.ex.npeditor.preview.text" );
        final String previewText = SettingsManager.get ( "NinePatchEditor", "preview.text", defaultPreviewText );
        preview.setText ( st ? parseToMultilineHtml ( previewText ) : "" );

        final WebTextField textField = new WebTextField ( 8 );
        textField.setText ( previewText );
        textField.setHorizontalAlignment ( WebTextField.CENTER );
        textField.setDrawFocus ( false );
        textField.setEditable ( st );
        textField.setMargin ( -1 );
        textField.addCaretListener ( new CaretListener ()
        {
            @Override
            public void caretUpdate ( final CaretEvent e )
            {
                SettingsManager.set ( "NinePatchEditor", "preview.text", textField.getText () );
                preview.setText ( showText.isSelected () ? parseToMultilineHtml ( textField.getText () ) : "" );
            }
        } );
        showText.addActionListener ( new ActionListener ()
        {
            @Override
            public void actionPerformed ( final ActionEvent e )
            {
                final boolean show = showText.isSelected ();
                SettingsManager.set ( "NinePatchEditor", "preview.showText", show );
                textField.setEditable ( show );
                preview.setText ( show ? parseToMultilineHtml ( textField.getText () ) : "" );
            }
        } );
        textField.setLeadingComponent ( showText );
        toolBar.addFill ( textField );


        final WebButton chooseColor = new WebButton ( FOREGROUND_COLOR_ICON );
        chooseColor.setLanguage ( "weblaf.ex.npeditor.preview.foregroundColor" );
        preview.setForeground ( SettingsManager.get ( "NinePatchEditor", "preview.foregroundColor", Color.WHITE ) );
        chooseColor.setCursor ( Cursor.getDefaultCursor () );
        chooseColor.setDrawFocus ( false );
        chooseColor.setRolloverDecoratedOnly ( true );
        chooseColor.setRolloverDarkBorderOnly ( false );
        chooseColor.setDrawLeft ( false );
        chooseColor.setDrawLeftLine ( true );
        chooseColor.setShadeWidth ( 0 );
        chooseColor.addActionListener ( new ActionListener ()
        {
            private WebColorChooserDialog webColorChooser = null;

            @Override
            public void actionPerformed ( final ActionEvent e )
            {
                if ( webColorChooser == null )
                {
                    webColorChooser = new WebColorChooserDialog ( SwingUtils.getWindowAncestor ( previewPanel ) );
                }
                webColorChooser.setColor ( preview.getForeground () );
                if ( webColorChooser.showDialog () == DialogOptions.OK_OPTION )
                {
                    final Color color = webColorChooser.getColor ();
                    SettingsManager.set ( "NinePatchEditor", "preview.foregroundColor", color );
                    preview.setForeground ( color );
                }
            }
        } );
        textField.setTrailingComponent ( chooseColor );

        abp = new AlphaLayerPainter ();

        final boolean da = SettingsManager.get ( "NinePatchEditor", "preview.transparentBackground", true );
        final WebToggleButton drawAlphaBackground = new WebToggleButton ( TRANSPARENT_ICON );
        drawAlphaBackground.setLanguage ( "weblaf.ex.npeditor.preview.transparentBackground" );
        drawAlphaBackground.setSelected ( da );
        drawAlphaBackground.addActionListener ( new ActionListener ()
        {
            @Override
            public void actionPerformed ( final ActionEvent e )
            {
                SettingsManager.set ( "NinePatchEditor", "preview.transparentBackground", true );
                previewPanel.setPainter ( abp );
            }
        } );

        colorPainter = new ColorPainter ( SettingsManager.get ( "NinePatchEditor", "preview.backgroundColor", Color.WHITE ) );

        final WebToggleButton drawColoredBackground = new WebToggleButton ( ImageUtils.createColorIcon ( colorPainter.getColor () ) );
        drawColoredBackground.setLanguage ( "weblaf.ex.npeditor.preview.coloredBackground" );
        drawColoredBackground.setSelected ( !da );
        drawColoredBackground.addActionListener ( new ActionListener ()
        {
            private WebColorChooserDialog webColorChooser = null;

            @Override
            public void actionPerformed ( final ActionEvent e )
            {
                SettingsManager.set ( "NinePatchEditor", "preview.transparentBackground", false );
                if ( webColorChooser == null )
                {
                    webColorChooser = new WebColorChooserDialog ( SwingUtils.getWindowAncestor ( previewPanel ) );
                }
                webColorChooser.setColor ( colorPainter.getColor () );
                if ( webColorChooser.showDialog () == DialogOptions.OK_OPTION )
                {
                    final Color color = webColorChooser.getColor ();
                    SettingsManager.set ( "NinePatchEditor", "preview.backgroundColor", color );
                    drawColoredBackground.setIcon ( ImageUtils.createColorIcon ( color ) );
                    colorPainter.setColor ( color );
                }
                previewPanel.setPainter ( colorPainter );
            }
        } );

        previewPanel.setPainter ( da ? abp : colorPainter );

        toolBar.addToEnd ( new WebButtonGroup ( true, drawAlphaBackground, drawColoredBackground ) );

        return new WebPanel ( previewPanel );
    }
View Full Code Here

TOP

Related Classes of com.alee.laf.toolbar.WebToolBar

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.