Java 小问题,等代求教

Janyue 2006-03-30 10:42:29
//在面板上显示一条信息
import javax.swing.*;
import java.awt.*;
//import java.awt.event.*;
import java.awt.geom.*;



public class SimpleFrameTest
{
public static void main(String[] args)
{
SimpleFrame frame = new SimpleFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.show();
}
}

//框架类
class SimpleFrame extends JFrame
{
public SimpleFrame()
{


setTitle("This is a Title");
setSize(WIDTH,HEIGHT);

//加入一个面板到框架

HelloPanel panel = new HelloPanel ();
Container contentPane = getContentPane();

contentPane.add(panel);

}
public static final int WIDTH = 400;
public static final int HEIGHT = 400;
}
...全文
124 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
tomison 2006-03-30
  • 打赏
  • 举报
回复
请楼主把问题写详细点,HelloPanel类的代码也没给出来,又没提及画图的函数
SanFire 2006-03-30
  • 打赏
  • 举报
回复
怎么不见你的画图函数啊?画图函数没有调用怎么会显示呢?进入调用画图函数代码。
Camelh 2006-03-30
  • 打赏
  • 举报
回复
把HelloPanel类的代码贴出来
hsuyuan 2006-03-30
  • 打赏
  • 举报
回复
HelloPanel 是什么类型的 好像不对吧
huangdeji 2006-03-30
  • 打赏
  • 举报
回复
不会,帮你鼎一下
Janyue 2006-03-30
  • 打赏
  • 举报
回复
就这些,我就是要让g.drawString("Hello this is message",MESSAGE_X,MESSAGE_Y);显示出来,可是出来的窗口空白的 why?
捏造的信仰 2006-03-30
  • 打赏
  • 举报
回复
程序看到了,问题楼主忘了写了?
UnAgain 2006-03-30
  • 打赏
  • 举报
回复
呵呵,这是道填空题

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



public class SimpleFrameTest
{
public static void main(String[] args)
{
SimpleFrame frame = new SimpleFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}

//框架类
class SimpleFrame extends JFrame
{
public SimpleFrame() {

setTitle("This is a Title");
setSize(WIDTH,HEIGHT);

//加入一个面板到框架
HelloPanel panel =
new HelloPanel("Hello this is message", 100, 100);
Container contentPane = getContentPane();

contentPane.add(panel);

}

class HelloPanel extends JPanel{
String msg = null;
int MESSAGE_X, MESSAGE_Y;

HelloPanel(String msg, int x, int y){
super();
this.msg = msg;
MESSAGE_X = x;
MESSAGE_Y = y;
}
public void paint(Graphics g){
g.drawString(msg, MESSAGE_X, MESSAGE_Y);
}
}

public static final int WIDTH = 400;
public static final int HEIGHT = 400;
}

huaiyusong 2006-03-30
  • 打赏
  • 举报
回复
写清楚点啊

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧