java中的JTabbedPane问题
package例题5;importjavax.swing.*;importjava.awt.event.*;classTtpDemoextendsJFrame{TtpDe...
package 例题5;
import javax.swing.*;
import java.awt.event.*;
class TtpDemo extends JFrame
{
TtpDemo()
{
super("一只鸡的一天");
setSize(400,350);
setVisible(true);
JTabbedPane jtp=new JTabbedPane();
ImageIcon icon1=new ImageIcon("a1.jpg");
ImageIcon icon2=new ImageIcon("a2.jpg");
ImageIcon icon3=new ImageIcon("a1.jpg");
jtp.addTab("陈洁",icon1, new CitiesPanel(),"性格");
jtp.addTab("生病了",icon2,new BookPanel(),"么么你");
jtp.addTab("好了之后",icon3,new NetPanel(),"丽江奇幻之旅");
getContentPane().add(jtp);
validate();
addWindowListener(new WindowAdapter(){public void windowClosing(WindowEvent e){System.exit(0);}});
}
}
class CitiesPanel extends JPanel{
CitiesPanel(){
JButton b1=new JButton("温柔");
JButton b2=new JButton("可爱");
JButton b3=new JButton("善良");
JButton b4=new JButton("聪明");
add(b1);add(b2);add(b3);add(b4);
}
}
class BookPanel extends JPanel{
BookPanel(){
JCheckBox cb1=new JCheckBox("吃点药");
JCheckBox cb2=new JCheckBox("多穿点");
JCheckBox cb3=new JCheckBox("喝热水");
add(cb1);add(cb2);add(cb3);
}
}
class NetPanel extends JPanel
{
NetPanel(){
JComboBox jcb=new JComboBox();
jcb.addItem("去丽江");
jcb.addItem("人贩子");
jcb.addItem("哦嚯。。。。");
add(jcb);
}
}
public class li5 {
public static void main(String args[]){
new TtpDemo();
}
}
怎么让JTabbedPane竖直显示出来? 展开
import javax.swing.*;
import java.awt.event.*;
class TtpDemo extends JFrame
{
TtpDemo()
{
super("一只鸡的一天");
setSize(400,350);
setVisible(true);
JTabbedPane jtp=new JTabbedPane();
ImageIcon icon1=new ImageIcon("a1.jpg");
ImageIcon icon2=new ImageIcon("a2.jpg");
ImageIcon icon3=new ImageIcon("a1.jpg");
jtp.addTab("陈洁",icon1, new CitiesPanel(),"性格");
jtp.addTab("生病了",icon2,new BookPanel(),"么么你");
jtp.addTab("好了之后",icon3,new NetPanel(),"丽江奇幻之旅");
getContentPane().add(jtp);
validate();
addWindowListener(new WindowAdapter(){public void windowClosing(WindowEvent e){System.exit(0);}});
}
}
class CitiesPanel extends JPanel{
CitiesPanel(){
JButton b1=new JButton("温柔");
JButton b2=new JButton("可爱");
JButton b3=new JButton("善良");
JButton b4=new JButton("聪明");
add(b1);add(b2);add(b3);add(b4);
}
}
class BookPanel extends JPanel{
BookPanel(){
JCheckBox cb1=new JCheckBox("吃点药");
JCheckBox cb2=new JCheckBox("多穿点");
JCheckBox cb3=new JCheckBox("喝热水");
add(cb1);add(cb2);add(cb3);
}
}
class NetPanel extends JPanel
{
NetPanel(){
JComboBox jcb=new JComboBox();
jcb.addItem("去丽江");
jcb.addItem("人贩子");
jcb.addItem("哦嚯。。。。");
add(jcb);
}
}
public class li5 {
public static void main(String args[]){
new TtpDemo();
}
}
怎么让JTabbedPane竖直显示出来? 展开
1个回答
2013-10-26
展开全部
JTabbedPane 的标签栏,可以放置在顶、侧边
看API
JTabbedPane(int tabPlacement)
Creates an empty TabbedPane with the specified tab placement
of either: JTabbedPane.TOP, JTabbedPane.BOTTOM,
JTabbedPane.LEFT, or JTabbedPane.RIGHT.
看API
JTabbedPane(int tabPlacement)
Creates an empty TabbedPane with the specified tab placement
of either: JTabbedPane.TOP, JTabbedPane.BOTTOM,
JTabbedPane.LEFT, or JTabbedPane.RIGHT.
追问
函数怎么打啊 哥
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询