
谁给我个Java可视化的简单例子?Eclipse
一个输入文本区和五个显示文本区,加按钮,单选,多选就可了!我用EclipseGanymede怎么实现?加swing直接import就可以了吗?swing里的类怎么用呢?我...
一个输入文本区和五个显示文本区,加按钮,单选,多选就可了!
我用Eclipse Ganymede怎么实现?
加swing直接import就可以了吗?
swing里的类怎么用呢?
我希望能直接得到一个例子,然后自己推敲 展开
我用Eclipse Ganymede怎么实现?
加swing直接import就可以了吗?
swing里的类怎么用呢?
我希望能直接得到一个例子,然后自己推敲 展开
展开全部
IDE:
http://nchc.dl.sourceforge.net/sourceforge/easyeclipse/easyeclipse-
desktop-java-1.3.1.1.exe(自带VE,可视化开发GUI)
//例子
import java.awt.Color;
import java.awt.Graphics;
import javax.swing.JFrame;
public class FlagFrame extends JFrame implements Runnable{
private static final long serialVersionUID = 1L;
private int x = 125;
private int y = 460;
private int step = 1;//步阶,升旗速度
private Thread thread = new Thread(this);
public void paint(Graphics g) {
Color c = g.getColor();
g.setColor(Color.BLACK);
g.fillRect(120, 0, 5, 600);
g.setColor(Color.RED);
g.fillRect(x, y, 200, 120);
g.setColor(Color.BLUE);
g.drawString("China", x + 30, y + 30 );
g.setColor(this.getBackground());
g.fillRect(x, y + 120 + step, 200, 120);
g.setColor(c);
}
public void init() {
this.setBackground(Color.CYAN);
this.setLayout(null);
this.setBounds(300, 120, 400, 600);
this.setResizable(false);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
thread.start();
this.setVisible(true);
}
public static void main(String[] args) {
new FlagFrame().init();
}
@SuppressWarnings("deprecation")
public void run() {
while(true) {
try {
if(y <= 28) {
thread.stop();//不安全
}
y -= step;
repaint();
Thread.sleep(20);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
http://nchc.dl.sourceforge.net/sourceforge/easyeclipse/easyeclipse-
desktop-java-1.3.1.1.exe(自带VE,可视化开发GUI)
//例子
import java.awt.Color;
import java.awt.Graphics;
import javax.swing.JFrame;
public class FlagFrame extends JFrame implements Runnable{
private static final long serialVersionUID = 1L;
private int x = 125;
private int y = 460;
private int step = 1;//步阶,升旗速度
private Thread thread = new Thread(this);
public void paint(Graphics g) {
Color c = g.getColor();
g.setColor(Color.BLACK);
g.fillRect(120, 0, 5, 600);
g.setColor(Color.RED);
g.fillRect(x, y, 200, 120);
g.setColor(Color.BLUE);
g.drawString("China", x + 30, y + 30 );
g.setColor(this.getBackground());
g.fillRect(x, y + 120 + step, 200, 120);
g.setColor(c);
}
public void init() {
this.setBackground(Color.CYAN);
this.setLayout(null);
this.setBounds(300, 120, 400, 600);
this.setResizable(false);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
thread.start();
this.setVisible(true);
}
public static void main(String[] args) {
new FlagFrame().init();
}
@SuppressWarnings("deprecation")
public void run() {
while(true) {
try {
if(y <= 28) {
thread.stop();//不安全
}
y -= step;
repaint();
Thread.sleep(20);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询