📄 desktop.bsh
字号:
/** Start the BeanShell GUI desktop. @method void desktop()*/import javax.swing.*;import bsh.util.JConsole;import bsh.util.Util;import bsh.Interpreter;import java.awt.Component;import bsh.Capabilities;desktop() { // need a way to set things to void again if ( bsh.system.desktop != void ) { print("There is already a desktop running..."); return; } else bsh.system.desktop = this; // race condition (hah!) // Ignore unhandled method invocations from listeners. invoke( method, args ) { } makeFontMenu( Component component ) { menu = new JMenu("Font"); mi = new JMenuItem("Normal"); mi.addActionListener(this); menu.add(mi); mi = new JMenuItem("Big"); mi.addActionListener(this); menu.add(mi); mi = new JMenuItem("Bigger"); mi.addActionListener(this); menu.add(mi); actionPerformed(e) { com = e.getActionCommand(); if ( com.equals("Normal") ) setFont( component, 12 ); else if ( com.equals("Big") ) setFont( component, 16 ); else if ( com.equals("Bigger") ) setFont( component, 20 ); } return menu; } makeInternalFrame( String name ) { // Closable by default frame = new JInternalFrame( name, true, true, true, true); frame.setVisible( true ); return frame; } addInternalFrame( frame ) { bsh.system.desktop.pane.add( frame ); /* frame.pack(); frame.show(); frame.toFront(); */ } windowCount=0; mousePressed( e ) { popup.show( pane, e.getX(), e.getY() ); } shutdown() { /* ret = JOptionPane.showInternalConfirmDialog( pane, "This workspace has not been saved. Do you really want to exit?" ); if ( ret == JOptionPane.YES_OPTION ) exit(); */ frame.dispose(); exit(); } actionPerformed( e ) { com = e.getActionCommand(); if ( com.equals("New Bsh Workspace") ) makeWorkspace( ""+ super.windowCount++); if ( com.equals("New Class Browser") ) classBrowser(); else if ( com.equals("Save Workspace") ) JOptionPane.showInternalMessageDialog( pane, "Unimplemented" ); else if ( com.equals("Exit") ) shutdown(); } pane=new JDesktopPane(); popup=new JPopupMenu("Root Menu"); mi=new JMenuItem("New Bsh Workspace"); mi.addActionListener(this); popup.add( mi ); mi=new JMenuItem("New Class Browser"); mi.addActionListener(this); popup.add( mi ); mi=new JMenuItem("Save Workspace"); mi.addActionListener(this); popup.add( mi ); mi=new JMenuItem("Exit"); mi.addActionListener(this); popup.add( mi ); pane.addMouseListener( this ); frame=new JFrame("BeanShell Desktop 1.0"); frame.getContentPane().add("Center", pane); windowClosing( e ) { bsh.system.desktop = null; shutdown(); } frame.addWindowListener( this ); /* If available, add a listener for classpath mapping I'm planning to implement a GUI progress indicator here if ( Capabilities.canGenerateInterfaces() ) { import bsh.classpath.BshClassPath; classFeedbackListener = new BshClassPath.MappingFeedback() { startClassMapping() { } classMapping( msg ) { } errorWhileMapping( msg ) { } endClassMapping() { } }; BshClassPath.addMappingFeedback( classFeedbackListener ); } */ // start one terminal makeWorkspace( ""+windowCount++ ); frame.setSize(800,600); frame.show(); frame.toFront(); Util.endSplashScreen();}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -