qq的聊天场景设置的功能是如何实现的?
解决方案 »
- 急求license相关源码
- JAVA有关string类库问题,请教各位高手。
- 基础问答,看了有好处!!!
- 正则表达式???
- 请教一个 static 和泛型的问题。
- java SOCKET通讯 问题...........
- 有个函数可以随机发出0-1之间的数 如何实现运算让他可以发出-10---------10之间的数 恳求大家解答 用语言表达即可
- C++的STL里有queue这个模板类,那JAVA中有没有相对应的类?
- 那里有最新<jbuilder开发人员指南>下载
- 其实微软不支持java VM也没关系呀,只不过是applet没办用了而以,是吧
- 求使用 wait() 和 notify() 的例子
- 《JAVA编程思想》中关于迭代器的疑问
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);
}
});
}
}
只是尝试,所以代码有点乱
难道用GIF?
那新开发一个场景要怎么做?