标题:为什么不显示字符串?
取消只看楼主
cai
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2005-10-24
 问题点数:0 回复次数:0 
为什么不显示字符串?

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

class point extends JFrame implements ActionListener { JButton b1,b2; public point() { ImageIcon ico1=new ImageIcon("121.jpg"); JButton b1=new JButton("aaaa",ico1); JButton b2=new JButton("bbbb"); this.setSize(400,300); this.setBackground(Color.lightGray); this.getContentPane().setLayout(new FlowLayout()); this.getContentPane().add(b1); this.getContentPane().add(b2); this.repaint(); b1.addActionListener(this); b2.addActionListener(this); this.setVisible(true); } public void actionPerformed(ActionEvent e) { if(e.getSource()==b1) { this.getContentPane().getGraphics().drawString("Bbbb",10,10); } if(e.getSource()==b2) { getGraphics().drawString("Aaaa",10,10); } this.repaint(); this.show(); } public static void main(String atgs[]) { new point(); } }

搜索更多相关主题的帖子: 字符 
2005-10-24 00:27



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-31152-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.244050 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved