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

📄 aplet.java

📁 http://w3eval.calcsharp.net/ W3Eval is Java applet that evaluates mathematical expressions. It uses
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
         else if ( e.getKeyCode()==KeyEvent.VK_R )            {            if ( jRadioButtonMenuItem1.isSelected() )               drg='D';            else if ( jRadioButtonMenuItem2.isSelected() )               drg='R';            else if ( jRadioButtonMenuItem3.isSelected() )               drg='G';            Vector	rez;            rez=Izracunavanje.rezultat( tokeni );           	rezultat.append( (String)rez.elementAt( 0 ) );            }         }/*   	if ( e.getKeyCode()==KeyEvent.VK_ESCAPE )   		{   		System.exit( 0 );   		}*/      if ( e.getModifiers()==2 && e.getKeyCode()==KeyEvent.VK_L )         {         izrazi.setText( "" );         }      if ( e.getModifiers()==2 && e.getKeyCode()==KeyEvent.VK_D )         {         Varijabla v=null;         rezultat.setText( "" );         for ( int i=varijable.size()-1; i>=0; i-- )            {            v=(Varijabla)varijable.elementAt( i );            rezultat.append( v.varijabla + " = " + v.vrijednost + "\n" );            }         }/*      else if ( e.getModifiers()==8 && e.getKeyCode()==KeyEvent.VK_O )         {         Operator o=null;         rezultat.setText( "" );         for ( int i=operatori.size()-1; i>=0; i-- )            {            o=(Operator)operatori.elementAt( i );            rezultat.append( o.operator + " ; " + o.prioritet + "\n" );            }         }      else if ( e.getModifiers()==8 && e.getKeyCode()==KeyEvent.VK_F )         {         Funkcija f=null;         rezultat.setText( "" );         for ( int i=funkcije.size()-1; i>=0; i-- )            {            f=(Funkcija)funkcije.elementAt( i );            rezultat.append( f.funkcija + " ; " + f.broj_argumenata + "\n" );            }         }*/   	else if ( e.getKeyCode()==KeyEvent.VK_S && e.getModifiers()==2 )   		{         String s=izrazi.getText();         int p=izrazi.getCaretPosition();         Raspon r=Izrazi.raspon_trenutnog_izraza( s, p );         if ( r!=null )            {            izrazi.setSelectionStart( r.pocetak );            izrazi.setSelectionEnd( r.kraj );            }   		}   	else if ( e.getKeyCode()==KeyEvent.VK_TAB )   		{     		if ( e.getModifiers()==0 )   			rezultat.requestFocus();      	else       		drvo.requestFocus();   		e.consume();   		}      }   void rezultat_keyPressed(KeyEvent e)   	{		if ( e.getKeyCode()==KeyEvent.VK_TAB )			{	  		if ( e.getModifiers()==0 )				drvo.requestFocus();	   	else	    		izrazi.requestFocus();			e.consume();			}		}   void drvo_mouseClicked( MouseEvent e )      {      // popup meni na desni klik      if ( e.getModifiers() == Event.META_MASK )         {         drvo.add( drvo_popup );         drvo_popup.show( drvo, e.getX(), e.getY() );         }      else if ( e.getClickCount()==2 )         {         DefaultMutableTreeNode node = (DefaultMutableTreeNode)drvo.getLastSelectedPathComponent();         if ( node!=null && node.isLeaf() )            umetanje_tokena( node );         }      }   void drvo_keyPressed( KeyEvent e )      {      if ( e.getKeyCode()==KeyEvent.VK_ENTER )         {         DefaultMutableTreeNode node = (DefaultMutableTreeNode)drvo.getLastSelectedPathComponent();         if ( node!=null && node.isLeaf() )            umetanje_tokena( node );         }      }   void umetanje_tokena( DefaultMutableTreeNode node )      {      String s=(String)node.getUserObject();      izrazi.insert( s, izrazi.getCaretPosition() );      }   void izrazi_mouseClicked(MouseEvent e)      {      // na desni klik      if ( e.getModifiers() == Event.META_MASK )         {         izrazi.add( izrazi_popup );         izrazi_popup.show( izrazi, e.getX(), e.getY() );         }      }   void izrazi_about_popup_actionPerformed(ActionEvent e)      {      rezultat.setText( "W3Eval DEMO\n" );      }   void izrazi_explain_popup_actionPerformed(ActionEvent e)      {      KeyEvent k = new KeyEvent( izrazi, 0, 0, 2, KeyEvent.VK_ENTER );      izrazi_keyPressed( k );      }   void izrazi_background_popup_actionPerformed(ActionEvent e)      {      Color color = JColorChooser.showDialog( this, "Background Color", izrazi.getBackground() );      if ( color != null )         izrazi.setBackground( color );      this.repaint();      }   void izrazi_foreground_popup_actionPerformed(ActionEvent e)      {      Color color = JColorChooser.showDialog( this, "Foreground Color", izrazi.getForeground() );      if ( color != null )         izrazi.setForeground( color );      this.repaint();      }   void rezultat_background_popup_actionPerformed(ActionEvent e)      {      Color color = JColorChooser.showDialog( this, "Background Color", rezultat.getBackground() );      if ( color != null )         rezultat.setBackground( color );      this.repaint();      }   void rezultat_foreground_popup_actionPerformed(ActionEvent e)      {      Color color = JColorChooser.showDialog( this, "Foreground Color", rezultat.getForeground() );      if ( color != null )         rezultat.setForeground( color );      this.repaint();      }   void rezultat_mouseClicked(MouseEvent e)      {      // na desni klik      if ( e.getModifiers() == Event.META_MASK )         {         rezultat.add( rezultat_popup );         rezultat_popup.show( rezultat, e.getX(), e.getY() );         }      }   void izrazi_normalize_popup_actionPerformed(ActionEvent e)      {      KeyEvent k = new KeyEvent( izrazi, 0, 0, 2, KeyEvent.VK_N );      izrazi_keyPressed( k );      }   void izrazi_parse_popup_actionPerformed(ActionEvent e)      {      KeyEvent k = new KeyEvent( izrazi, 0, 0, 2, KeyEvent.VK_P );      izrazi_keyPressed( k );      }   void izrazi_evaluate_popup_actionPerformed(ActionEvent e)      {      KeyEvent k = new KeyEvent( izrazi, 0, 0, 2, KeyEvent.VK_E );      izrazi_keyPressed( k );      }   void izrazi_reduce_popup_actionPerformed(ActionEvent e)      {      KeyEvent k = new KeyEvent( izrazi, 0, 0, 2, KeyEvent.VK_R );      izrazi_keyPressed( k );      }   void drvo_expand_popup_actionPerformed(ActionEvent e)      {      int red=0;      while ( red < drvo.getRowCount() )         {         drvo.expandRow( red );         red++;         }      }   void drvo_collapse_popup_actionPerformed(ActionEvent e)      {      int red = drvo.getRowCount() - 1;      while ( red >= 0)         {         drvo.collapseRow( red );         red--;         }      }   /*   void izrazi_help_popup_actionPerformed( ActionEvent e )      {      URL adresa=null;      String s = "http://geodet.geof.hr/~mstepan/nik/help.html";      AppletContext kontekst = getAppletContext();      try         {         adresa = new URL( s );         kontekst.showDocument( adresa );         }      catch ( MalformedURLException m )         {         rezultat.setText( "Malformed URL Exception" );         }      }   */   void izrazi_select_popup_actionPerformed(ActionEvent e)      {      KeyEvent k = new KeyEvent( izrazi, 0, 0, 2, KeyEvent.VK_S );      izrazi_keyPressed( k );      }   void izrazi_variables_popup_actionPerformed(ActionEvent e)      {      KeyEvent k = new KeyEvent( izrazi, 0, 0, 2, KeyEvent.VK_D );      izrazi_keyPressed( k );      }   void drvo_expand_selection_popup_actionPerformed(ActionEvent e)      {      int red=0;      while ( red < drvo.getRowCount() )         {         if ( drvo.isRowSelected( red ) )            drvo.expandRow( red );         red++;         }      }   void drvo_collapse_selection_popup_actionPerformed(ActionEvent e)      {      int red = drvo.getRowCount() - 1;      while ( red >= 0)         {         if ( drvo.isRowSelected( red ) )            drvo.collapseRow( red );         red--;         }      }   void izrazi_clear_popup_actionPerformed(ActionEvent e)      {      izrazi.setText( "" );      }   void osvjezavanje()      {      SwingUtilities.updateComponentTreeUI( this );      SwingUtilities.updateComponentTreeUI( drvo_popup );      SwingUtilities.updateComponentTreeUI( izrazi_popup );      SwingUtilities.updateComponentTreeUI( rezultat_popup );      jScrollPane3.setBorder(null);      jScrollPane2.setBorder(null);      jScrollPane1.setBorder(null);      jSplitPane1.setBorder(null);      jSplitPane2.setBorder(null);      }   void jMenuItem1_actionPerformed(ActionEvent e)      {      try         {         UIManager.setLookAndFeel( "javax.swing.plaf.metal.MetalLookAndFeel" );         }      catch ( Exception e1 )         {         }      osvjezavanje();      }   void jMenuItem2_actionPerformed(ActionEvent e)      {      try         {         UIManager.setLookAndFeel( "com.sun.java.swing.plaf.windows.WindowsLookAndFeel" );         }      catch ( Exception e2 )         {         }      osvjezavanje();      }   void jMenuItem3_actionPerformed(ActionEvent e)      {      try         {         UIManager.setLookAndFeel( "com.sun.java.swing.plaf.motif.MotifLookAndFeel" );         }      catch ( Exception e2 )         {         }      osvjezavanje();      }   } // kraj klase Aplet

⌨️ 快捷键说明

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