看看Java这两种编程思想有什么区别?可以在eclipse上用吗?可以混用吗?
2个回答
展开全部
package 练习题;//你的这个程序可以运行,我在eclipse上运行过了。
import java.awt.CardLayout;
import java.awt.Container;
import javax.*;
import javax.swing.JFrame;
import javax.swing.JLabel;
public class CardLayoutDemo {
public static void main(String []args){
JFrame frame=new JFrame("CardLayoutDemo");
CardLayout card =new CardLayout();
frame.setLayout(card);
Container con =frame.getContentPane();
con.add(new JLabel("卡片1", JLabel.CENTER),"1");
con.add(new JLabel("卡片2", JLabel.CENTER),"2");
con.add(new JLabel("卡片3", JLabel.CENTER),"3");
con.add(new JLabel("卡片4", JLabel.CENTER),"4");
con.add(new JLabel("卡片5", JLabel.CENTER),"5");
frame.setSize(400, 200);
frame.setVisible(true);
card.show(con, "1");
for(int i=0;i<5;i++){
try{
Thread.sleep(2000);
card.next(con);
}catch(InterruptedException e){
e.printStackTrace();
}
}
}
}
import java.awt.CardLayout;
import java.awt.Container;
import javax.*;
import javax.swing.JFrame;
import javax.swing.JLabel;
public class CardLayoutDemo {
public static void main(String []args){
JFrame frame=new JFrame("CardLayoutDemo");
CardLayout card =new CardLayout();
frame.setLayout(card);
Container con =frame.getContentPane();
con.add(new JLabel("卡片1", JLabel.CENTER),"1");
con.add(new JLabel("卡片2", JLabel.CENTER),"2");
con.add(new JLabel("卡片3", JLabel.CENTER),"3");
con.add(new JLabel("卡片4", JLabel.CENTER),"4");
con.add(new JLabel("卡片5", JLabel.CENTER),"5");
frame.setSize(400, 200);
frame.setVisible(true);
card.show(con, "1");
for(int i=0;i<5;i++){
try{
Thread.sleep(2000);
card.next(con);
}catch(InterruptedException e){
e.printStackTrace();
}
}
}
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询