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

📄 decimaltohex.java

📁 its a kind of tutorial.
💻 JAVA
字号:
// Filename DecimalToHex.java.
// Provides an example of the AWT Scrollbar class.  
// Written for the Java interface book Chapter 2 - see text.
//
// Fintan Culwin, v 0.2, August 1997.

import java.awt.*;
import java.awt.event.*;
import java.applet.*;


public class DecimalToHex extends    Applet 
                          implements AdjustmentListener { 

private Scrollbar scroller;
private Label     decimalLabel;
private Label     hexLabel;

   public void init() {
      this.setFont( new Font( "TimesRoman", Font.PLAIN, 20));
      this.setLayout( new GridLayout( 3, 1, 5, 5));
     
      scroller = new Scrollbar( Scrollbar.HORIZONTAL, 0, 1, 0, 255);
      scroller.setBlockIncrement( 10);                                            
      scroller.addAdjustmentListener( this);
                                                   
      decimalLabel = new Label();
      hexLabel     = new Label();
          
      this.add( decimalLabel);     
      this.add( scroller);
      this.add( hexLabel);     

      this.update();
   } // End init.


   public void adjustmentValueChanged( AdjustmentEvent event) { 
      this.update();  
   } // End adjustmentValueChanged.


   protected void update() { 
   
   int     theValue     = scroller.getValue();
   String  decimalValue = new String( Integer.toString( theValue, 10));
   String  hexValue     = new String( Integer.toString( theValue, 16));
    
   String  decimalString = new String( "Decimal : " +  decimalValue);
   String  hexString     = new String( "Hex : " +  hexValue);

        decimalLabel.setText(  decimalString);
        hexLabel.setText(      hexString);
   } // End update.


   public static void main(String args[]) {

   Frame        frame      = new Frame("Decimal To Hex");
   DecimalToHex theExample = new DecimalToHex();

      theExample.init();
      frame.add("Center", theExample);

      frame.show();
      frame.setSize( frame.getPreferredSize());
   } // End main.

} // end class DecimalToHex.



⌨️ 快捷键说明

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