Examples of InputMap


Examples of javax.swing.InputMap

    private AdaptiveLayoutTest() {
        cp = new JPanel();
        cp.setBackground(Color.black);
        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) {
View Full Code Here

Examples of javax.swing.InputMap

    final JToolBar        tbMonitoring;
    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

Examples of javax.swing.InputMap

    transport   = doc.getTransport();
    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() );
View Full Code Here

Examples of javax.swing.InputMap

                addToViewMenu(frontPersonRB, 2);
                cameraButtonGroup.add(frontPersonRB);

                // add custom accelerators for cycling and resetting the
                // 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();
View Full Code Here

Examples of javax.swing.InputMap

            final KeyStroke copyKeyStroke = KeyStroke.getKeyStroke("meta pressed C");
            final KeyStroke pasteKeyStroke = KeyStroke.getKeyStroke("meta pressed V");
            final KeyStroke cutKeyStroke = KeyStroke.getKeyStroke("meta pressed X");
            final KeyStroke allKeyStroke = KeyStroke.getKeyStroke("meta pressed A");

            InputMap textFieldMap = (InputMap) UIManager.get("TextField.focusInputMap");
            textFieldMap.put(copyKeyStroke, DefaultEditorKit.copyAction);
            textFieldMap.put(pasteKeyStroke, DefaultEditorKit.pasteAction);
            textFieldMap.put(cutKeyStroke, DefaultEditorKit.cutAction);
            textFieldMap.put(allKeyStroke, DefaultEditorKit.selectAllAction);

            InputMap formattedTextFieldMap = (InputMap) UIManager.get("FormattedTextField.focusInputMap");
            formattedTextFieldMap.put(copyKeyStroke, DefaultEditorKit.copyAction);
            formattedTextFieldMap.put(pasteKeyStroke, DefaultEditorKit.pasteAction);
            formattedTextFieldMap.put(cutKeyStroke, DefaultEditorKit.cutAction);
            formattedTextFieldMap.put(allKeyStroke, DefaultEditorKit.selectAllAction);

            InputMap textAreaMap = (InputMap) UIManager.get("TextArea.focusInputMap");
            textAreaMap.put(copyKeyStroke, DefaultEditorKit.copyAction);
            textAreaMap.put(pasteKeyStroke, DefaultEditorKit.pasteAction);
            textAreaMap.put(cutKeyStroke, DefaultEditorKit.cutAction);
            textAreaMap.put(allKeyStroke, DefaultEditorKit.selectAllAction);

            InputMap passwordFieldMap = (InputMap) UIManager.get("PasswordField.focusInputMap");
            passwordFieldMap.put(pasteKeyStroke, DefaultEditorKit.pasteAction);
        }
    }
View Full Code Here

Examples of javax.swing.InputMap

        }
    }

    public static void installEscapeBinding(final Window window, final JRootPane rootPane, final boolean dispose) {
        final KeyStroke stroke = KeyStroke.getKeyStroke("ESCAPE");
        final InputMap inputMap = rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
        inputMap.put(stroke, "ESCAPE");
        rootPane.getActionMap().put("ESCAPE", new AbstractAction() {
            private static final long serialVersionUID = 1L;

            @Override
            public void actionPerformed(ActionEvent e) {
View Full Code Here

Examples of javax.swing.InputMap

     * Builds the InputMap of this canvas with a set of predefined
     * <tt>Action</tt>s.
     */
    protected void installKeyboardActions() {

        InputMap inputMap = getInputMap(JComponent.WHEN_FOCUSED);
        KeyStroke key;

        key = KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, 0);
        inputMap.put(key, SCROLL_RIGHT_ACTION);

        key = KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 0);
        inputMap.put(key, SCROLL_LEFT_ACTION);

        key = KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0);
        inputMap.put(key, SCROLL_UP_ACTION);

        key = KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0);
        inputMap.put(key, SCROLL_DOWN_ACTION);

        key = KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, KeyEvent.SHIFT_MASK);
        inputMap.put(key, FAST_SCROLL_RIGHT_ACTION);

        key = KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, KeyEvent.SHIFT_MASK);
        inputMap.put(key, FAST_SCROLL_LEFT_ACTION);

        key = KeyStroke.getKeyStroke(KeyEvent.VK_UP, KeyEvent.SHIFT_MASK);
        inputMap.put(key, FAST_SCROLL_UP_ACTION);

        key = KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, KeyEvent.SHIFT_MASK);
        inputMap.put(key, FAST_SCROLL_DOWN_ACTION);

        key = KeyStroke.getKeyStroke(KeyEvent.VK_I, KeyEvent.CTRL_MASK);
        inputMap.put(key, ZOOM_IN_ACTION);

        key = KeyStroke.getKeyStroke(KeyEvent.VK_O, KeyEvent.CTRL_MASK);
        inputMap.put(key, ZOOM_OUT_ACTION);

        key = KeyStroke.getKeyStroke(KeyEvent.VK_T, KeyEvent.CTRL_MASK);
        inputMap.put(key, RESET_TRANSFORM_ACTION);
    }
View Full Code Here

Examples of javax.swing.InputMap

        //Page view stuff
        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);
        previewPanel.getActionMap().put("prevPage", previousPageAction);
        previewPanel.getActionMap().put("firstPage", firstPageAction);
        previewPanel.getActionMap().put("lastPage", lastPageAction);
View Full Code Here

Examples of javax.swing.InputMap

   
  public void testMethod1(TestHarness harness)
  {
    harness.checkPoint("()");
    JTableHeader th = new JTableHeader();
    InputMap m1 = th.getInputMap();
    InputMap m2 = th.getInputMap(JComponent.WHEN_FOCUSED);  
    harness.check(m1 == m2);
  }
View Full Code Here

Examples of javax.swing.InputMap

   
  public void testMethod2(TestHarness harness)
  {
    harness.checkPoint("(int)");
    JTableHeader th = new JTableHeader();
    InputMap m1 = th.getInputMap(JComponent.WHEN_FOCUSED);
    harness.check(m1.keys(), null);
    harness.check(m1.getParent(), null);
    InputMap m2 = th.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);  
    harness.check(m2.keys(), null);
    harness.check(m2.getParent(), null);
    InputMap m3 = th.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    harness.check(m3.keys(), null);
    harness.check(m3.getParent(), null);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.