简单的画板问题求助

asxp409 2012-11-01 10:42:29
import javax.swing.JFrame;
import javax.swing.JButton;

import java.awt.Color;
import java.awt.Container;
import java.awt.FlowLayout;
import javax.swing.BoxLayout;
import java.awt.Graphics;
import javax.swing.JPanel;


class J_Panel extends JPanel
{

protected void paintComponent(Graphics g)
{
g.clearRect(0,0,getWidth(),getHeight());
g.drawLine(30,20,320,160);
}
}




class JFW extends JFrame
{
public JFW()
{

super("hanoi模拟");
Container cp=getContentPane();
J_Panel huaban[]=new J_Panel[2];
huaban[0]=new J_Panel();
huaban[1]=new J_Panel();
huaban[0].setSize(120,60);
huaban[0].setBackground(Color.BLACK);
huaban[0].show(true);
JButton a=new JButton("单步");
JButton b=new JButton("自动");
JButton c=new JButton("效果");
cp.setLayout(new FlowLayout());
huaban[0].setLayout(new BoxLayout(huaban[0],BoxLayout.X_AXIS));
huaban[1].setLayout(new BoxLayout(huaban[1],BoxLayout.X_AXIS));
huaban[1].add(a);
huaban[1].add(b);
huaban[1].add(c);
cp.add(huaban[0]);
cp.add(huaban[1]);
}

}


public class hanuota {



/* static void hanoi(int n,char one,char two,char three)
{
if(n==1)
move(one,three);
else
{
hanoi(n-1,one,three,two);
move(one,three);
hanoi(n-1,two,one,three);
}
}
static void move(char x,char y)
{
System.out.println(x+"->>"+y);
}*/
public static void main(String args[])
{

//hanoi(4,'A','B','C');
JFW app= new JFW();
app.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
app.setSize(640,320);
app.setVisible(true);
}
}
我想要的是让画板显示出来画板下面是按钮。。。怎么改画板都出不来。。。TAT
...全文
53 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

62,621

社区成员

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

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