Package javax.swing

Examples of javax.swing.ActionMap


        cp.setBorder(new EmptyBorder(16, 16, 16, 16));

        InputMap im = cp.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
        im.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "blur");

        ActionMap am = cp.getActionMap();
        am.put("blur", new AbstractAction() {
            @Override
            public void actionPerformed(ActionEvent e) {
                layoutManager.blur();
                cp.revalidate();
            }
View Full Code Here


    final TimeLabel        lbTime;
    final MessageFormat      frmtPeak    = new MessageFormat( getResourceString( "msgPeak" ), Locale.US ); // XXX Locale.US
    final Object[]        peakArgs    = new Object[1];
    final JRootPane        rp        = getRootPane();
    final InputMap        imap      = rp.getInputMap( JComponent.WHEN_IN_FOCUSED_WINDOW );
    final ActionMap        amap      = rp.getActionMap();
    final JButton        ggAbort, ggRecord, ggStop, ggClose;
    final int          myMeta      = BasicMenuFactory.MENU_SHORTCUT == InputEvent.CTRL_MASK ?
      InputEvent.CTRL_MASK | InputEvent.SHIFT_MASK : BasicMenuFactory.MENU_SHORTCUT;  // META on Mac, CTRL+SHIFT on PC

    // use same encoding as parent document
    encodingString = (displayAFD.sampleFormat == AudioFileDescr.FORMAT_INT ? "int" : "float") +
             String.valueOf( displayAFD.bitsPerSample );
//encodingString = "float32";

    audioPrefs  = app.getUserPrefs().node( PrefsUtil.NODE_AUDIO );
    classPrefs  = app.getUserPrefs().node( className.substring( className.lastIndexOf( '.' ) + 1 ));
   
    recPane    = new SpringPanel( 4, 2, 4, 2 );
//    affp    = new AudioFileFormatPane( AudioFileFormatPane.ENCODING );
//    recPane.gridAdd( new JLabel( getResourceString( "labelFormat" ), SwingConstants.RIGHT ), 0, 1 );
//    recPane.gridAdd( affp, 1, 1 );
    ggRecordConfig  = new PrefComboBox();
    ggRecordConfig.setFocusable( false );
    lbPeak      = new JLabel();
    actionPeakReset  = new ActionPeakReset();
    ggPeakReset    = new JButton( actionPeakReset );
    ggPeakReset.setFocusable( false );
    lbTime      = new TimeLabel();
    tbMonitoring  = new JToolBar();
    tbMonitoring.setFloatable( false );
    ggMonitoring  = new JToggleButton( new ActionMonitoring() );
    ggMonitoring.setFocusable( false );
    tbMonitoring.add( ggMonitoring );
    recPane.gridAdd( lbTime, 1, 0, -2, 1 );
    recPane.gridAdd( new JLabel( getResourceString( "labelRecInputs" ), SwingConstants.RIGHT ), 0, 1 );
    recPane.gridAdd( ggRecordConfig, 1, 1, -1, 1 );
    recPane.gridAdd( tbMonitoring, 2, 1 );
    recPane.gridAdd( new JLabel( getResourceString( "labelHeadroom" ) + " :", SwingConstants.RIGHT ), 0, 2 );
    recPane.gridAdd( lbPeak, 1, 2 );
//    recPane.gridAdd( new JLabel( getResourceString( "labelDB" ), SwingConstants.RIGHT ), 2, 1 );
    recPane.gridAdd( ggPeakReset, 2, 2, -1, 1 );
   
    refillConfigs();

//    affp.setPreferences( classPrefs );
    ggRecordConfig.setPreferences( classPrefs, KEY_CONFIG );

    recPane.makeCompactGrid();

    butPane        = new JPanel(); // new FlowLayout( FlowLayout.TRAILING ));
    butPane.setLayout( new BoxLayout( butPane, BoxLayout.X_AXIS ));
    actionRecord    = new ActionRecord();
    actionStop      = new ActionStop();
    actionAbort      = new ActionAbort();
    actionClose      = new ActionClose();
    butPane.add( new HelpButton( "RecorderDialog" ));
    butPane.add( Box.createHorizontalGlue() );
    ggAbort        = new JButton( actionAbort );
    ggAbort.setFocusable( false );
    butPane.add( ggAbort );
    ggRecord      = new JButton( actionRecord );
    ggRecord.setFocusable( false );
    butPane.add( ggRecord );
    ggStop        = new JButton( actionStop );
    ggStop.setFocusable( false );
    butPane.add( ggStop );
    ggClose        = new JButton( actionClose );
    ggClose.setFocusable( false );
    butPane.add( ggClose );
    butPane.add( CoverGrowBox.create() );
       
    cp.add( recPane, BorderLayout.NORTH );
    cp.add( butPane, BorderLayout.SOUTH );

    GUIUtil.setDeepFont( cp, app.getGraphicsHandler().getFont( GraphicsHandler.FONT_SYSTEM | GraphicsHandler.FONT_SMALL ));

//    runPeakUpdate = new Runnable() {
//      public void run()
//      {
//        peakArgs[0] = new Double( MathUtil.linearToDB( 1.0 / maxPeak ));
//        lbPeak.setText( frmtPeak.format( peakArgs ));
//      }
//    };
//    runPeakUpdate.run();  // initially reset peak hold
    meterTimer  = new Timer( 100, new ActionListener() {
      public void actionPerformed( ActionEvent e )
      {
        final float    value    = docFrame.getMaxMeterHold();
        final boolean  valueClip  = value > -0.2f;
        peakArgs[0] = new Float( value );
        lbPeak.setText( frmtPeak.format( peakArgs ));
        if( valueClip && !clipped ) {
          clipped = valueClip;
          lbPeak.setForeground( Color.red );
        }
      }
    });
   
    recLenTimer  = new RecLenTimer( lbTime, recFrames, doc.timeline.getRate() );
   
//    cSetNRespBody = new OSCListener() {
//      public void messageReceived( OSCMessage msg, SocketAddress sender, long time )
//      {
//        final int    busIndex  = ((Number) msg.getArg( 0 )).intValue();
//        final Context  ct      = RecorderDialog.this.ct;  // quasi sync
//       
//        if( (ct == null) || (busIndex != ct.busMeter.getIndex()) ) return;
//
////        final long    now      = System.currentTimeMillis();
//       
//        try {
//          final int numValues = ((Number) msg.getArg( 1 )).intValue();
//          if( numValues != meterValues.length ) {
//            meterValues = new float[ numValues ];
//          }
//           
//          for( int i = 0; i < meterValues.length; i++ ) {
//            meterValues[ i ] = ((Number) msg.getArg( i + 2 )).floatValue();
//          }
//           
//          meterUpdate();
//        }
////        catch( IOException e1 ) {
////          printError( "Receive /c_setn", e1 );
////        }
//        catch( ClassCastException e2 ) {
//          printError( "Receive /c_setn", e2 );
//        }
//      }
//    };

    // ---- meters -----

//    meterTimer  = new javax.swing.Timer( 33, new ActionListener() {
//      public void actionPerformed( ActionEvent e )
//      {
//        try {
//          if( (server != null) && (ct != null) ) server.sendMsg( ct.meterBangMsg );
//        }
//        catch( IOException e1 ) {}
//      }
//    });
   
    setDefaultCloseOperation( DO_NOTHING_ON_CLOSE );
//    root.addComponent( Main.COMP_RECORDER, this );

    server  = superCollider.getServer();
    player  = superCollider.getPlayerForDocument( doc );
   
    if( (server == null) || (player == null) || !server.isRunning() ) {
      throw new IOException( getResourceString( "errServerNotRunning" ));
    }

    osc  = new OSCRouterWrapper( doc, this );

    // ---- listeners -----
   
    winListener = new WindowAdapter() {
      public void windowClosing( WindowEvent e ) {
        if( !isRecording ) {
          disposeRecorder();
        }
      }
    };
    addWindowListener( winListener );
       
    superCollider.addServerListener( this );
//    player.addMeterListener( this );
//    player.setMetering( true );
   
    nw    = superCollider.getNodeWatcher();
    nw.addListener( this );
   
    // ---- keyboard shortcuts ----
    imap.put( KeyStroke.getKeyStroke( KeyEvent.VK_R, myMeta ), "record" )// VK_SPACE doesn't work (WHY?)
//    amap.put( "record", actionRecord );
    amap.put( "record", new DoClickAction( ggRecord ));
    imap.put( KeyStroke.getKeyStroke( KeyEvent.VK_PERIOD, myMeta ), "abort" );
//    amap.put( "abort", actionAbort );
    amap.put( "abort", new DoClickAction( ggAbort ));
    imap.put( KeyStroke.getKeyStroke( KeyEvent.VK_ENTER, myMeta ), "stop" );
//    amap.put( "stop", actionStop );
    amap.put( "stop", new DoClickAction( ggStop ));
    imap.put( KeyStroke.getKeyStroke( KeyEvent.VK_ESCAPE, 0 ), "close" );
    amap.put( "close", actionClose );

    docFrame.setForceMeters( true );
    player.setActiveInput( true );
    meterTimer.start();
View Full Code Here

    rate    = doc.timeline.getRate();

    final AbstractAction  actionPlay, actionStop, actionGoToTime;
    final JButton      ggFFwd, ggRewind;
    final InputMap      imap    = this.getInputMap( JComponent.WHEN_IN_FOCUSED_WINDOW );
    final ActionMap      amap    = this.getActionMap();

    toolBar      = new ToolBar( SwingConstants.HORIZONTAL );

        ggRewind    = new JButton();
    GraphicsUtil.setToolIcons( ggRewind, GraphicsUtil.createToolIcons( GraphicsUtil.ICON_REWIND ));
    ggRewind.addChangeListener( new CueListener( ggRewind, -100 ));
        ActionCue actionRwdOn  = new ActionCue( ggRewind, true );
        ActionCue actionRwdOff = new ActionCue( ggRewind, false );
        actionRwdOn .setPair(actionRwdOff);
        actionRwdOff.setPair(actionRwdOn );
    imap.put( KeyStroke.getKeyStroke( KeyEvent.VK_OPEN_BRACKET, 0, false ), "startrwd" );
    amap.put( "startrwd", actionRwdOn);
    imap.put( KeyStroke.getKeyStroke( KeyEvent.VK_OPEN_BRACKET, 0, true ), "stoprwd" );
    amap.put( "stoprwd", actionRwdOff);

    actionStop    = new ActionStop();
        ggStop      = new JButton( actionStop );
    GraphicsUtil.setToolIcons( ggStop, GraphicsUtil.createToolIcons( GraphicsUtil.ICON_STOP ));

    actionPlay    = new ActionPlay();
        ggPlay      = new JButton( actionPlay );
    GraphicsUtil.setToolIcons( ggPlay, GraphicsUtil.createToolIcons( GraphicsUtil.ICON_PLAY ));

    imap.put( KeyStroke.getKeyStroke( KeyEvent.VK_SPACE, 0 ), "playstop" );
    imap.put( KeyStroke.getKeyStroke( KeyEvent.VK_SPACE, InputEvent.SHIFT_MASK ), "playstop" );
    imap.put( KeyStroke.getKeyStroke( KeyEvent.VK_SPACE, InputEvent.SHIFT_MASK | InputEvent.ALT_MASK ), "playstop" );
    imap.put( KeyStroke.getKeyStroke( KeyEvent.VK_NUMPAD0, 0 ), "playstop" );
    amap.put( "playstop", new ActionTogglePlayStop() );
    imap.put( KeyStroke.getKeyStroke( KeyEvent.VK_SPACE, InputEvent.CTRL_MASK ), "playsel" );
    amap.put( "playsel", new ActionPlaySelection() );

        ggFFwd      = new JButton();
    GraphicsUtil.setToolIcons( ggFFwd, GraphicsUtil.createToolIcons( GraphicsUtil.ICON_FASTFORWARD ));
    ggFFwd.addChangeListener( new CueListener( ggFFwd, 100 ));
    imap.put( KeyStroke.getKeyStroke( KeyEvent.VK_CLOSE_BRACKET, 0, false ), "startfwd" );
        ActionCue actionFwdOn  = new ActionCue( ggFFwd, true );
        ActionCue actionFwdOff = new ActionCue( ggFFwd, false );
        actionFwdOn .setPair(actionFwdOff);
        actionFwdOff.setPair(actionFwdOn );
    amap.put( "startfwd", actionFwdOn);
    imap.put( KeyStroke.getKeyStroke( KeyEvent.VK_CLOSE_BRACKET, 0, true ), "stopfwd" );
    amap.put( "stopfwd", actionFwdOff);

    actionLoop    = new ActionLoop();
    ggLoop      = new JToggleButton( actionLoop );
    GraphicsUtil.setToolIcons( ggLoop, GraphicsUtil.createToolIcons( GraphicsUtil.ICON_LOOP ));
    GUIUtil.createKeyAction( ggLoop, KeyStroke.getKeyStroke( KeyEvent.VK_SLASH, 0));
    toolBar.addButton( ggRewind );
    toolBar.addButton( ggStop );
    toolBar.addButton( ggPlay );
    toolBar.addButton( ggFFwd );
    toolBar.addToggleButton( ggLoop, 2 );
//        HelpGlassPane.setHelp( toolBar, "TransportTools" );
       
    actionGoToTime  = new ActionGoToTime();
    lbTime      = new TimeLabel();
//        HelpGlassPane.setHelp( lbTime, "TransportPosition" );
    lbTime.setCursor( new Cursor( Cursor.HAND_CURSOR ));
    lbTime.addMouseListener( new MouseAdapter() {
      public void mouseClicked( MouseEvent e )
      {
        actionGoToTime.actionPerformed( null );
        lbTime.black();
      }
     
      public void mouseEntered( MouseEvent e )
      {
        lbTime.blue();
      }

      public void mouseExited( MouseEvent e )
      {
        lbTime.black();
      }
    });
    imap.put( KeyStroke.getKeyStroke( KeyEvent.VK_G, 0 ), "gototime" );
    amap.put( "gototime", actionGoToTime );
   
    this.add( toolBar );
Box b2 = Box.createVerticalBox();
b2.add( Box.createVerticalGlue() );
b2.add( lbTime );
View Full Code Here

  private ActionMap map;
  private Action action;

  @Before
  public void setUp() {
    map = new ActionMap();
    action = mock(Action.class);
    map.put("key", action);
  }
View Full Code Here

        // start suppressing autocompletion when selecting values from the popup with the mouse
        this.popup.getList().addMouseListener(popupMouseHandler);

        // record the original Up/Down arrow key Actions
        final ActionMap actionMap = comboBox.getActionMap();
        this.originalSelectNextAction = actionMap.get("selectNext");
        this.originalSelectPreviousAction = actionMap.get("selectPrevious");
        this.originalSelectNext2Action = actionMap.get("selectNext2");
        this.originalSelectPrevious2Action = actionMap.get("selectPrevious2");
        this.originalAquaSelectNextAction = actionMap.get("aquaSelectNext");
        this.originalAquaSelectPreviousAction = actionMap.get("aquaSelectPrevious");

        final Action upAction = new MoveAction(-1);
        final Action downAction = new MoveAction(1);

        // install custom actions for the arrow keys in all non-Apple L&Fs
        actionMap.put("selectPrevious", upAction);
        actionMap.put("selectNext", downAction);
        actionMap.put("selectPrevious2", upAction);
        actionMap.put("selectNext2", downAction);

        // install custom actions for the arrow keys in the Apple Aqua L&F
        actionMap.put("aquaSelectPrevious", upAction);
        actionMap.put("aquaSelectNext", downAction);

        // install a custom ComboBoxEditor that decorates the existing one, but uses the
        // convertToString(...) method to produce text for the editor component (rather than .toString())
        this.comboBoxEditor = new FormatComboBoxEditor(comboBox.getEditor());
        this.comboBox.setEditor(comboBoxEditor);
View Full Code Here

        this.popupLocationFix.uninstall();

        // stop suppressing autocompletion when selecting values from the popup with the mouse
        this.popup.getList().removeMouseListener(popupMouseHandler);

        final ActionMap actionMap = comboBox.getActionMap();
        // restore the original actions for the arrow keys in all non-Apple L&Fs
        actionMap.put("selectPrevious", originalSelectPreviousAction);
        actionMap.put("selectNext", originalSelectNextAction);
        actionMap.put("selectPrevious2", originalSelectPrevious2Action);
        actionMap.put("selectNext2", originalSelectNext2Action);

        // restore the original actions for the arrow keys in the Apple Aqua L&F
        actionMap.put("aquaSelectPrevious", originalAquaSelectPreviousAction);
        actionMap.put("aquaSelectNext", originalAquaSelectNextAction);

        // remove the KeyListener from the ComboBoxEditor which handles the special case of backspace when in strict mode
        this.comboBoxEditorComponent.removeKeyListener(strictModeBackspaceHandler);
        // remove the FocusListener from the ComboBoxEditor which selects all text when focus is gained
        this.comboBoxEditorComponent.removeFocusListener(selectTextOnFocusGainHandler);
View Full Code Here

                // camera
                InputMap im = mainMenuBar.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
                im.put(KeyStroke.getKeyStroke('c'), "cycleCamera");
                im.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "resetCamera");

                ActionMap am = mainMenuBar.getActionMap();
                am.put("cycleCamera", new AbstractAction() {
                    public void actionPerformed(ActionEvent e) {
                        cameraButtonGroup.next();
                    }
                });
                am.put("resetCamera", new AbstractAction() {
                    public void actionPerformed(ActionEvent e) {
                        ViewManager.getViewManager().setCameraController(
                                ViewManager.getDefaultCamera());
                    }
                });
View Full Code Here

    /**
     * Builds the ActionMap of this canvas with a set of predefined
     * <tt>Action</tt>s.
     */
    protected void installActions() {
        ActionMap actionMap = getActionMap();

        actionMap.put(SCROLL_RIGHT_ACTION, new ScrollRightAction(10));
        actionMap.put(SCROLL_LEFT_ACTION, new ScrollLeftAction(10));
        actionMap.put(SCROLL_UP_ACTION, new ScrollUpAction(10));
        actionMap.put(SCROLL_DOWN_ACTION, new ScrollDownAction(10));

        actionMap.put(FAST_SCROLL_RIGHT_ACTION, new ScrollRightAction(30));
        actionMap.put(FAST_SCROLL_LEFT_ACTION, new ScrollLeftAction(30));
        actionMap.put(FAST_SCROLL_UP_ACTION, new ScrollUpAction(30));
        actionMap.put(FAST_SCROLL_DOWN_ACTION, new ScrollDownAction(30));

        actionMap.put(ZOOM_IN_ACTION, new ZoomInAction());
        actionMap.put(ZOOM_OUT_ACTION, new ZoomOutAction());

        actionMap.put(RESET_TRANSFORM_ACTION, new ResetTransformAction());
    }
View Full Code Here

        previewPanel = new PreviewPanel(foUserAgent, renderable, renderer);
        getContentPane().add(previewPanel, BorderLayout.CENTER);

        // Keyboard shortcuts - pgup/pgdn
        InputMap im = previewPanel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
        ActionMap am = previewPanel.getActionMap();
        im.put(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_DOWN, 0), "nextPage");
        im.put(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_UP, 0), "prevPage");
        im.put(KeyStroke.getKeyStroke(KeyEvent.VK_HOME, 0), "firstPage");
        im.put(KeyStroke.getKeyStroke(KeyEvent.VK_END, 0), "lastPage");
        previewPanel.getActionMap().put("nextPage", nextPageAction);
View Full Code Here

    /**
     * Builds the ActionMap of this canvas with a set of predefined
     * <tt>Action</tt>s.
     */
    protected void installActions() {
        ActionMap actionMap = getActionMap();

        actionMap.put(SCROLL_RIGHT_ACTION, new ScrollRightAction(10));
        actionMap.put(SCROLL_LEFT_ACTION, new ScrollLeftAction(10));
        actionMap.put(SCROLL_UP_ACTION, new ScrollUpAction(10));
        actionMap.put(SCROLL_DOWN_ACTION, new ScrollDownAction(10));

        actionMap.put(FAST_SCROLL_RIGHT_ACTION, new ScrollRightAction(30));
        actionMap.put(FAST_SCROLL_LEFT_ACTION, new ScrollLeftAction(30));
        actionMap.put(FAST_SCROLL_UP_ACTION, new ScrollUpAction(30));
        actionMap.put(FAST_SCROLL_DOWN_ACTION, new ScrollDownAction(30));

        actionMap.put(ZOOM_IN_ACTION, new ZoomInAction());
        actionMap.put(ZOOM_OUT_ACTION, new ZoomOutAction());

        actionMap.put(RESET_TRANSFORM_ACTION, new ResetTransformAction());
    }
View Full Code Here

TOP

Related Classes of javax.swing.ActionMap

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.