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

📄 jtermdata.java

📁 用JAVA程序来上BBS?这就是一个这样的程序
💻 JAVA
字号:
package JTerm;

/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2003</p>
 * <p>Company: </p>
 * @author not attributable
 * @version 1.0
 */
import java.awt.*;
import javax.swing.*;
import java.util.ResourceBundle;

public class JTermData  {
  static ResourceBundle res = ResourceBundle.getBundle("JTerm.Res");
  static Color defaultForeColor,defaultBackColor;
  char data;
  Color foreground;
  Color background;
  boolean fontShow=true;
  boolean fontBold=false,fontUnderLine=false,fontBlink=false,fontReverse=false;
  int   xoff,yoff,width,height;

  public void setSize(int xoff,int yoff,int width,int height){
    this.xoff=xoff;
    this.yoff=yoff;
    this.width=width;
    this.height=height;
  }
  public void setDefaultColor(Color fg,Color bg){
    this.defaultBackColor=bg;
    this.defaultForeColor=fg;
  }
  public JTermData() {

  }

  public JTermData(char data) {
    this.data = data;
  }

  public void setData(char data) {

    this.data = data;
    fontShow=true;

  }

  public void setForeground(Color color) {
    this.foreground = color;
  }

  public void setBackground(Color color) {
    this.background = color;
  }

  public char getData() {
    return data;
  }

  public void copyData(JTermData src){
    this.data=src.data;
    this.fontBlink=src.fontBlink;
        this.fontBold=src.fontBold;
    this.foreground=src.foreground;
    this.background=src.background;
  }

  public int put(Graphics g) {

    Color fg,bg;
    if (data!='\u0000'){
      Graphics2D g2=(Graphics2D) g;

      if (fontReverse){
          fg=this.background;
          bg=foreground;
          if (fg==null){
            fg=this.defaultBackColor;
          }
          if (bg==null){
            bg=this.defaultForeColor;
          }

      }else{
          fg=foreground;
          bg=background;
          if (fg==null){
  fg=this.defaultForeColor;
}
if (bg==null){
  bg=this.defaultBackColor;
}

      }
      
      int w;
      g2.setBackground(bg);
      if (data>'\u00ff')
      w=2*width;
      else 
      w=width;
      g2.clearRect(xoff, yoff-height + 2, w, height);
        g2.setColor(fg);
      if (fontUnderLine)
        g2.drawLine(xoff, yoff + height, xoff + w, yoff + height);
      if (fontShow)
        g2.drawString(String.valueOf(data), xoff, yoff);
	  return w;
   }
      return width;
  }


  public void blink(){
    if (data!=res.getString("EmptyChar").charAt(0)){
      if (fontBlink) {
        fontShow = !fontShow;
      }
    }

  }
  public void setAttr(boolean fontBold,
                      boolean fontUnderLine,
                      boolean fontBlink,
                      boolean fontReverse){
    this.fontBlink=fontBlink;
    this.fontBold=fontBold;
    this.fontReverse=fontReverse;
    this.fontUnderLine=fontUnderLine;
    fontShow=true;
  }
}


⌨️ 快捷键说明

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