您的位置:程序门 -> java -> j2se / 基础类



qq的聊天场景设置的功能是如何实现的?


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


qq的聊天场景设置的功能是如何实现的?
发表于:2007-02-04 16:52:36 楼主
qq的聊天场景设置的功能是如何实现的?
发表于:2007-02-04 16:58:191楼 得分:0
这个还真的不知道。是用jfarm实现的吧。。
发表于:2007-02-04 17:10:422楼 得分:0
我用jtextpane的paint()方法给其上了背景后,上面原有的文字都没了,
发表于:2007-02-04 17:12:523楼 得分:0
楼上的能发下你的代码给我看看么?
发表于:2007-02-04 17:34:544楼 得分:0
package   com.softfz.zxj;

import   javax.swing.*;
import   javax.swing.text.*;
import   java.awt.event.*;
import   java.awt.*;

class   jtextpane1   extends   jtextpane{
  //private   jtextpane   textpane;
jbutton   b1   =new   jbutton();
imageicon     tu1   =   new     imageicon( "background.gif ");
  image   gg   =   tu1.getimage();
  jpanel   p1   =new   jpanel(new   borderlayout());//{
//   public   void   paint(graphics   g)
//   {
//   g.drawimage(gg,0,0,500,300,this);
//   }
//   };
        jframe   f=new   jframe( "jtextpane1 ");
   
  public   jtextpane1(){
     
    //textpane.paint()
      //this.setopaque(true);
      this.seteditable(false);
  }
 
//   textpane.setbackground(color   d)
//   {
//  
//   }
  public   void   paint(graphics   g)
  {
  g.drawimage(gg,0,0,500,300,this);
  }
 
  public   void   setyellow_bold_20(string   str){
      simpleattributeset   attrset=new   simpleattributeset();
      styleconstants.setforeground(attrset,color.yellow);
      styleconstants.setbold(attrset,true);
      insert(str,attrset);
  }
  public   void   setblue_italic_bold_22(string   str){
      simpleattributeset   attrset=new   simpleattributeset();
      styleconstants.setforeground(attrset,color.blue);
      styleconstants.setitalic(attrset,true);
      styleconstants.setfontsize(attrset,24);
      insert(str,attrset);
  }
  public   void   setred_underline_italic_24(string   str){
      simpleattributeset   attrset=new   simpleattributeset();
      styleconstants.setforeground(attrset,color.red);
      styleconstants.setunderline(attrset,true);
      styleconstants.setitalic(attrset,true);
      styleconstants.setfontsize(attrset,24);
      insert(str,attrset);
  }
      //这个方法最主要的用途是将字符串插入到jtextpane中。
  public   void   insert(string   str,attributeset   attrset){
      document   docs=this.getdocument();//利用getdocument()方法取得jtextpane的document   instance.0
      str=str+ "\n ";
      try{
          docs.insertstring(docs.getlength(),str,attrset);          
      }catch(badlocationexception   ble){
            system.out.println( "badlocationexception: "+ble);
      }
  }
public   component   getcomponent(){
    return   this;
}
public   static   void   main(string[]   args){
    jtextpane1   pane=new   jtextpane1();
    pane.setyellow_bold_20( "this   is   line   1,yellow,bold,size   20 ");
    pane.setblue_italic_bold_22( "this   is   line   2,blue,italic,bold,size   22 ");
    pane.setred_underline_italic_24( "this   is   line   3,red,underline,italic,size   24 ");
    jtextpane1   pane1=new   jtextpane1();
    pane.f.getcontentpane().add(pane.p1);
    pane.p1.add(pane);
    pane.p1.add(pane.b1,borderlayout.south);
    //pane.f.getcontentpane().add(pane.getcomponent());
    pane.f.setsize(450,180);
    pane.f.show();
    pane.f.addwindowlistener(new   windowadapter(){
                    public   void   windowclosing(windowevent   e){
                        system.exit(0);
                    }
                    });
}
}
只是尝试,所以代码有点乱
发表于:2007-02-05 20:51:405楼 得分:0
ding
发表于:2007-02-05 22:20:156楼 得分:0
场景中   还有图片会动的
难道用gif?
那新开发一个场景要怎么做?


快速检索

最新资讯
热门点击