Blogtrottr
Yahoo!奇摩知識+ - 分類問答 - 電腦網路 - 發問中
Yahoo!奇摩知識+ - 分類問答 - 電腦網路 - 發問中 
Thousands of Free eBooks

BookBub brings you free & bargain national bestselling eBooks in the genres of your choice! Sign up now & join 1.5 million happy readers.
From our sponsors
JTabbedPane Size問題
Jan 7th 2014, 09:57

大家好~
最近在寫一支程式 但是遇到這個問題已經卡好久了
懇求聰明的各位為小弟指點迷津...

問題是這樣的:
我的JFrame裡面 有一個 JTabbedPane
其中 JTabbedPane 包含兩個 Box ( New, TYPE)
New 裡面有個 JTextArea 大小是已經設定好了 跟視窗剛好合身
然後TYPE裡面有一個包含 JTree 的 JPanel
當JTree沒打開時 世界是很和平的
但是當JTree打開後 New 裡面的 整個JTabbedPane就會被拉長 拉超出JFrame外
我已經用 JScrollPane 想包住她 讓他不要亂延伸
可是當我打開TYPE裡面的JTree 然後再點去 New 再點回 TYPE後
JSCrollPane 就不見了 整個視窗還是被拉長...

請問我該怎麼做 才可以讓JTree打開時 點去New 整個視窗還是可以很合身很漂亮呢?

附上部分相關程式碼:

public class Test extends JFrame {

private JTabbedPane tabs = new JTabbedPane(JTabbedPane.TOP);
private Box New = Box.createVerticalBox();
private Box TYPE = Box.createHorizontalBox();
private JPanel PS ;
private JTextArea psFrame ;
private JScrollPane psSC ;
private JPanel TypePanel ;
TypeTree TT ;

public Test(){
super("TEST") ;
setSize(530, 180);
setLocation(700, 100);
setDefaultCloseOperation(EXIT_ON_CLOSE);
setLayout(new FlowLayout());
setResizable(false) ;

PS = new JPanel();
psFrame = new JTextArea(5, 40);
psSC = new JScrollPane(psFrame);
psSC.setHorizontalScrollBar(null);
PS.setLayout(new FlowLayout());
PS.add(psSC);
New.add(PS);

TypePanel = new JPanel();
TypePanel.setLayout(new GridLayout(1, 2));
TypePanel.add(new JButton("NewType"));
TT = new TypeTree();
TypePanel.add(new JScrollPane(TT));
TYPE.add(TypePanel);

tabs.addTab("New",New) ;
tabs.addTab("TYPE", TYPE);
add(tabs) ;

setVisible(true) ;
}

public class TypeTree extends JPanel {
JTree typeTree ;
public TypeTree() {
setLayout( new BorderLayout() ) ;
DefaultMutableTreeNode root = new DefaultMutableTreeNode(
new String("ROOT"));
typeTree = new JTree(root);

for( int i = 0 ; i < 10 ; i++ ){
DefaultMutableTreeNode next=new DefaultMutableTreeNode(i) ;
root.add(next);
}
add(typeTree) ;
setVisible(true) ;
}
}
main{...}//打不下了..
}

This entry passed through the Full-Text RSS service — if this is your content and you're reading it on someone else's site, please read the FAQ at fivefilters.org/content-only/faq.php#publishers.

You are receiving this email because you subscribed to this feed at blogtrottr.com.

If you no longer wish to receive these emails, you can unsubscribe from this feed, or manage all your subscriptions
arrow
arrow
    全站熱搜
    創作者介紹
    創作者 sdfgdf2 的頭像
    sdfgdf2

    中文名字日文翻譯, 中文翻譯日文名字, 名字日文翻譯, 日文翻譯名字, 日文翻譯字典發音, 日文翻譯網 漢字,

    sdfgdf2 發表在 痞客邦 留言(0) 人氣()