Package com.alee.managers.hotkey

Examples of com.alee.managers.hotkey.HotkeyRunnable


    public static void main ( final String[] args )
    {
        WebLookAndFeel.install ();
        final TestFrame tf = TestFrame.show ( new ComplexExample ().getPreview ( null ), 0 );
        HotkeyManager.registerHotkey ( Hotkey.SPACE, new HotkeyRunnable ()
        {
            @Override
            public void run ( final KeyEvent e )
            {
                tf.pack ();
View Full Code Here


                    }
                }
                updateClassPath ( viewTabbedPane.getSelectedEntry (), false );
            }
        } );
        HotkeyManager.registerHotkey ( viewTabbedPane, Hotkey.ALT_LEFT, new HotkeyRunnable ()
        {
            @Override
            public void run ( final KeyEvent e )
            {
                final int tabCount = viewTabbedPane.getTabCount ();
                if ( tabCount > 0 )
                {
                    final int index = viewTabbedPane.getSelectedIndex ();
                    viewTabbedPane.setSelectedIndex ( index > 0 ? index - 1 : tabCount - 1 );
                }
            }
        } );
        HotkeyManager.registerHotkey ( viewTabbedPane, Hotkey.ALT_RIGHT, new HotkeyRunnable ()
        {
            @Override
            public void run ( final KeyEvent e )
            {
                final int tabCount = viewTabbedPane.getTabCount ();
View Full Code Here


        classSearchField = new WebTextField ( 20, false );
        classSearchField.setHideInputPromptOnFocus ( false );
        classSearchField.setInputPrompt ( "Enter class name here..." );
        HotkeyManager.registerHotkey ( classSearchField, Hotkey.ESCAPE, new HotkeyRunnable ()
        {
            @Override
            public void run ( final KeyEvent e )
            {
                hideClassSearchPopup ();
            }
        } );

        final WebImage leadingComponent = new WebImage ( classSearchIcon );
        leadingComponent.setMargin ( 2 );
        classSearchField.setLeadingComponent ( leadingComponent );

        classSearchPopup = new WebPopup ();
        classSearchPopup.setCloseOnFocusLoss ( true );
        classSearchPopup.add ( classSearchField );
        classSearchPopup.setDefaultFocusComponent ( classSearchField );

        classSearchHintsPopup = new WebWindow ( classSearchPopup )
        {
            @Override
            public Dimension getPreferredSize ()
            {
                final Dimension ps = super.getPreferredSize ();
                ps.width = Math.max ( classSearchField.getWidth (), ps.width );
                return ps;
            }
        };
        classSearchHintsPopup.setFocusable ( false );
        classSearchHintsPopup.setAlwaysOnTop ( true );
        classSearchPopup.addFocusableChild ( classSearchHintsPopup );

        classSearchHintsList = new WebList ( new DefaultListModel () );
        classSearchHintsList.setFocusable ( false );
        classSearchHintsList.setRolloverSelectionEnabled ( true );
        classSearchHintsList.setSelectionMode ( ListSelectionModel.SINGLE_SELECTION );
        classSearchHintsList.setCellRenderer ( new WebListCellRenderer ()
        {
            @Override
            public Component getListCellRendererComponent ( final JList list, final Object value, final int index, final boolean isSelected,
                                                            final boolean cellHasFocus )
            {
                final JarEntry entry = ( JarEntry ) value;
                final WebListElement renderer =
                        ( WebListElement ) super.getListCellRendererComponent ( list, value, index, isSelected, cellHasFocus );
                renderer.setIcon ( entry.getIcon () );
                renderer.setText ( entry.getName () );
                return renderer;
            }
        } );
        classSearchHintsList.addMouseListener ( new MouseAdapter ()
        {
            @Override
            public void mousePressed ( final MouseEvent e )
            {
                if ( SwingUtils.isLeftMouseButton ( e ) )
                {
                    openSelectedHint ();
                }
            }
        } );

        HotkeyManager.registerHotkey ( classSearchField, Hotkey.HOME, new HotkeyRunnable ()
        {
            @Override
            public void run ( final KeyEvent e )
            {
                if ( classSearchHintsList.getModelSize () > 0 )
                {
                    classSearchHintsList.setSelectedIndex ( 0 );
                }
            }
        } );
        HotkeyManager.registerHotkey ( classSearchField, Hotkey.UP, new HotkeyRunnable ()
        {
            @Override
            public void run ( final KeyEvent e )
            {
                if ( classSearchHintsList.getModelSize () > 0 )
                {
                    final int index = classSearchHintsList.getSelectedIndex ();
                    if ( index > 0 )
                    {
                        classSearchHintsList.setSelectedIndex ( index - 1 );
                    }
                    else
                    {
                        classSearchHintsList.setSelectedIndex ( classSearchHintsList.getModelSize () - 1 );
                    }
                }
            }
        } );
        HotkeyManager.registerHotkey ( classSearchField, Hotkey.DOWN, new HotkeyRunnable ()
        {
            @Override
            public void run ( final KeyEvent e )
            {
                if ( classSearchHintsList.getModelSize () > 0 )
                {
                    final int index = classSearchHintsList.getSelectedIndex ();
                    if ( index < classSearchHintsList.getModelSize () - 1 )
                    {
                        classSearchHintsList.setSelectedIndex ( index + 1 );
                    }
                    else
                    {
                        classSearchHintsList.setSelectedIndex ( 0 );
                    }
                }
            }
        } );
        HotkeyManager.registerHotkey ( classSearchField, Hotkey.END, new HotkeyRunnable ()
        {
            @Override
            public void run ( final KeyEvent e )
            {
                if ( classSearchHintsList.getModelSize () > 0 )
                {
                    classSearchHintsList.setSelectedIndex ( classSearchHintsList.getModelSize () - 1 );
                }
            }
        } );
        HotkeyManager.registerHotkey ( classSearchField, Hotkey.ENTER, new HotkeyRunnable ()
        {
            @Override
            public void run ( final KeyEvent e )
            {
                openSelectedHint ();
View Full Code Here

            }
        } );
        searchPlate.add ( searchField );


        HotkeyManager.registerHotkey ( layeredPane, Hotkey.CTRL_F, new HotkeyRunnable ()
        {
            @Override
            public void run ( final KeyEvent e )
            {
                toggleSearch ();
            }
        } );
        HotkeyManager.registerHotkey ( layeredPane, Hotkey.ESCAPE, new HotkeyRunnable ()
        {
            @Override
            public void run ( final KeyEvent e )
            {
                if ( searchField.getText ().length () > 0 )
View Full Code Here

                    final JRootPane rootPane = WebLookAndFeelDemo.this.getRootPane ();
                    final WebCustomTooltip searchTip = TooltipManager
                            .showOneTimeTooltip ( rootPane, new Point ( rootPane.getWidth () / 2, 0 ), SlidingSearch.searchIcon,
                                    "You can quickly navigate through components using search (Ctrl+F)", TooltipWay.down );

                    final HotkeyInfo searchTipHide = HotkeyManager.registerHotkey ( Hotkey.CTRL_F, new HotkeyRunnable ()
                    {
                        @Override
                        public void run ( final KeyEvent e )
                        {
                            searchTip.closeTooltip ();
View Full Code Here

                WebLookAndFeel.changeOrientation ();
            }
        } );

        // Special application-wide (global) hotkey
        HotkeyManager.registerHotkey ( Hotkey.ALT_R, new HotkeyRunnable ()
        {
            @Override
            public void run ( final KeyEvent e )
            {
                if ( !ltrOrientation.isFocusOwner () )
View Full Code Here

            passwordField = new WebPasswordField ( 12 );
            authPanel.add ( passwordField, "1,3" );


            HotkeyManager.registerHotkey ( authPanel, authPanel, Hotkey.ENTER, new HotkeyRunnable ()
            {
                @Override
                public void run ( final KeyEvent e )
                {
                    clickOk ();
                }
            } );
            HotkeyManager.registerHotkey ( authPanel, authPanel, Hotkey.ESCAPE, new HotkeyRunnable ()
            {
                @Override
                public void run ( final KeyEvent e )
                {
                    clickCancel ();
View Full Code Here

        installShowAllTooltipsAction ( topComponent, Hotkey.F2 );
    }

    public static void installShowAllTooltipsAction ( final Component topComponent, final HotkeyData hotkeyData )
    {
        HotkeyManager.registerHotkey ( topComponent, hotkeyData, new HotkeyRunnable ()
        {
            @Override
            public void run ( final KeyEvent e )
            {
                showAllTooltips ( topComponent );
View Full Code Here

                {
                    startEditing ();
                }
            }
        } );
        HotkeyManager.registerHotkey ( WebPathField.this, WebPathField.this, Hotkey.F2, new HotkeyRunnable ()
        {
            @Override
            public void run ( final KeyEvent e )
            {
                startEditing ();
View Full Code Here

        xmlEditor.setCaretPosition ( 0 );

        xmlEditor.setHyperlinksEnabled ( true );
        xmlEditor.setLinkGenerator ( new CodeLinkGenerator ( xmlEditor ) );

        HotkeyManager.registerHotkey ( xmlEditor, xmlEditor, Hotkey.CTRL_SHIFT_Z, new HotkeyRunnable ()
        {
            @Override
            public void run ( final KeyEvent e )
            {
                xmlEditor.undoLastAction ();
View Full Code Here

TOP

Related Classes of com.alee.managers.hotkey.HotkeyRunnable

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.