⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mainwindow.java

📁 FuncPlotter is a combined Java application and applet for displaying two-dimensional plots of explic
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
        menuItem = editMenu.add( FunctionDocument.Command.UNDO );        menuItem.setMnemonic( KeyEvent.VK_U );        menuItem = editMenu.add( FunctionDocument.Command.REDO );        menuItem.setMnemonic( KeyEvent.VK_R );        menuItem = editMenu.add( FunctionDocument.Command.CLEAR_EDIT_LIST );        menuItem.setMnemonic( KeyEvent.VK_L );        editMenu.addSeparator( );        menuItem = editMenu.add( FunctionDocument.Command.EDIT_COMMENT );        menuItem.setMnemonic( KeyEvent.VK_C );        editMenu.addSeparator( );        menuItem = editMenu.add( FunctionDocument.Command.REVERSE_FUNCTIONS );        menuItem.setMnemonic( KeyEvent.VK_V );        menuItem = editMenu.add( AppCommand.COPY_INTERVALS );        menuItem.setMnemonic( KeyEvent.VK_I );        menuBar.add( editMenu );        // Options menu        optionsMenu = new JMenu( OPTIONS_STR );        optionsMenu.setMnemonic( KeyEvent.VK_O );        optionsMenu.addMenuListener( this );        menuItem = optionsMenu.add( AppCommand.EDIT_PREFERENCES );        menuItem.setMnemonic( KeyEvent.VK_P );        menuItem = optionsMenu.add( new JCheckBoxMenuItem( AppCommand.SHOW_FULL_PATHNAMES ) );        menuItem.setMnemonic( KeyEvent.VK_F );        menuBar.add( optionsMenu );        // Set menu bar        setJMenuBar( menuBar );        //----  Tabbed panel        tabbedPanel = new TabbedPanel( );        tabbedPanel.setIgnoreCase( true );        App.applyOrientationByLocale( tabbedPanel );        tabbedPanel.addChangeListener( this );        // Add temporary view        addView( new String( ), null, App.getInstance( ).getView( 0 ) );        // Set preferred size of tabbed pane        tabbedPanel.setPreferredSize( tabbedPanel.getPreferredSize( ) );        // Set transfer handler        tabbedPanel.setTransferHandler( new FileTransferHandler( ) );        //----  Window        // Set orientation of components according to locale        App.applyOrientationByLocale( this );        // Set content pane        setContentPane( tabbedPanel );        // Dispose of window explicitly        setDefaultCloseOperation( DO_NOTHING_ON_CLOSE );        // Handle window closing        addWindowListener( new WindowEventHandler( ) );        // Handle change to focused window        addWindowFocusListener( this );        // Prevent window from being resized        setResizable( false );        // Resize window to its preferred size        pack( );        // Set location of window        setLocation( GuiUtilities.                            getLocationWithinScreen( this,                                                     AppConfig.getInstance( ).getMainWindowLocation( ) ) );        // Delete temporary document        App.getInstance( ).clearDocuments( );        // Remove temporary view from tabbed panel        removeView( 0 );        // Update title and menus        updateTitleAndMenus( );        // Make window visible        setVisible( true );    }    //------------------------------------------------------------------//////////////////////////////////////////////////////////////////////////  Instance methods : ChangeListener interface////////////////////////////////////////////////////////////////////////    public void stateChanged( ChangeEvent event )    {        if ( event.getSource( ) == tabbedPanel )        {            if ( isVisible( ) )                updateTitleAndMenus( );        }    }    //------------------------------------------------------------------//////////////////////////////////////////////////////////////////////////  Instance methods : MenuListener interface////////////////////////////////////////////////////////////////////////    public void menuCanceled( MenuEvent event )    {        // do nothing    }    //------------------------------------------------------------------    public void menuDeselected( MenuEvent event )    {        // do nothing    }    //------------------------------------------------------------------    public void menuSelected( MenuEvent event )    {        Object eventSource = event.getSource( );        if ( eventSource == fileMenu )            updateFileMenu( );        else if ( eventSource == editMenu )            updateEditMenu( );        else if ( eventSource == optionsMenu )            updateOptionsMenu( );    }    //------------------------------------------------------------------//////////////////////////////////////////////////////////////////////////  Instance methods : WindowFocusListener interface////////////////////////////////////////////////////////////////////////    public void windowGainedFocus( WindowEvent event )    {        FunctionView view = App.getInstance( ).getView( );        if ( view != null )            view.showMouseCursorCoords( true );    }    //------------------------------------------------------------------    public void windowLostFocus( WindowEvent event )    {        FunctionView view = App.getInstance( ).getView( );        if ( view != null )            view.showMouseCursorCoords( false );    }    //------------------------------------------------------------------//////////////////////////////////////////////////////////////////////////  Instance methods////////////////////////////////////////////////////////////////////////    public int getTabIndex( )    {        return tabbedPanel.getSelectedIndex( );    }    //------------------------------------------------------------------    public void addView( String       title,                         String       toolTipText,                         FunctionView view )    {        tabbedPanel.addComponent( title, new CloseAction( ), view );        view.setDefaultFocus( );        int index = tabbedPanel.getNumTabs( ) - 1;        tabbedPanel.setToolTipText( index, toolTipText );        tabbedPanel.setSelectedIndex( index );    }    //------------------------------------------------------------------    public void removeView( int index )    {        tabbedPanel.removeComponent( index );    }    //------------------------------------------------------------------    public void setView( int          index,                         FunctionView view )    {        tabbedPanel.setComponent( index, view );    }    //------------------------------------------------------------------    public void selectView( int index )    {        tabbedPanel.setSelectedIndex( index );    }    //------------------------------------------------------------------    public void setTabText( int    index,                            String title,                            String toolTipText )    {        tabbedPanel.setTitle( index, title );        tabbedPanel.setToolTipText( index, toolTipText );    }    //------------------------------------------------------------------    public void updateTitleAndMenus( )    {        updateTitle( );        updateMenus( );    }    //------------------------------------------------------------------    private void updateTitle( )    {        FunctionDocument document = App.getInstance( ).getDocument( );        boolean fullPathname = AppConfig.getInstance( ).isShowFullPathnames( );        setTitle( (document == null)                                ? App.LONG_NAME + " " + App.getInstance( ).getVersionString( )                                : App.SHORT_NAME + "  [" + document.getTitleString( fullPathname ) + "]" );    }    //------------------------------------------------------------------    private void updateMenus( )    {        updateFileMenu( );        updateEditMenu( );        updateOptionsMenu( );    }    //------------------------------------------------------------------    private void updateFileMenu( )    {        updateAppCommands( );    }    //------------------------------------------------------------------    private void updateEditMenu( )    {        editMenu.setEnabled( App.getInstance( ).hasDocuments( ) );        updateDocumentCommands( );        updateAppCommands( );    }    //------------------------------------------------------------------    private void updateOptionsMenu( )    {        updateAppCommands( );    }    //------------------------------------------------------------------    private void updateAppCommands( )    {        FunctionDocument document = App.getInstance( ).getDocument( );        boolean isDocument = (document != null);        boolean notFull = !App.getInstance( ).isDocumentsFull( );        AppCommand.TRANSFER_FILES.setEnabled( true );        AppCommand.CHECK_MODIFIED_FILE.setEnabled( true );        AppCommand.NEW_FILE.setEnabled( notFull );        AppCommand.OPEN_FILE.setEnabled( notFull );        AppCommand.REOPEN_FILE.setEnabled( isDocument && document.isChanged( ) &&                                           (document.getFile( ) != null) );        AppCommand.CLOSE_FILE.setEnabled( isDocument );        AppCommand.CLOSE_ALL_FILES.setEnabled( isDocument );        AppCommand.SAVE_FILE.setEnabled( isDocument && document.isChanged( ) );        AppCommand.SAVE_FILE_AS.setEnabled( isDocument );        AppCommand.EXPORT_IMAGE.setEnabled( isDocument && FunctionDocument.canWriteImages( ) );        AppCommand.EXIT.setEnabled( true );        AppCommand.COPY_INTERVALS.setEnabled( App.getInstance( ).getNumDocuments( ) > 1 );        AppCommand.EDIT_PREFERENCES.setEnabled( true );        AppCommand.SHOW_FULL_PATHNAMES.setEnabled( true );        AppCommand.SHOW_FULL_PATHNAMES.setSelected( AppConfig.getInstance( ).isShowFullPathnames( ) );    }    //------------------------------------------------------------------    private void updateDocumentCommands( )    {        FunctionDocument document = App.getInstance( ).getDocument( );        if ( document == null )            FunctionDocument.Command.setAllEnabled( false );        else            document.updateCommands( );    }    //------------------------------------------------------------------//////////////////////////////////////////////////////////////////////////  Instance variables////////////////////////////////////////////////////////////////////////    private JMenu       fileMenu;    private JMenu       editMenu;    private JMenu       optionsMenu;    private TabbedPanel tabbedPanel;}//----------------------------------------------------------------------

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -