2015-01-09 2 views
2

세 버튼이있는 JTabbedPane을 사용하고 있습니다. 창 크기를 조정하더라도 단추가 작게 유지된다는 점을 제외하면 프로그램이 잘 실행 중입니다. 그들에게 setPrefferedSize의 방법이 있습니까? 여기 JTabbedPane 버튼의 크기를 어떻게 조정합니까?

내가 찾고있는 것을 발견 코드

public final class JTabbedPaneDemo { 

    JFrame frame; 
    JTabbedPane pane; 
    JPanel panel1; 
    JPanel panel2; 
    JPanel panel3; 


    JTabbedPaneDemo(){ 

    this.createFrameGUI("My Tabbed Pane"); 

    } 
    //creating the frame 
    public void createFrameGUI(String title){ 
    frame= new JFrame(title); 
    frame.setSize(new Dimension(350,350)); 
    frame.setVisible(true); 
    frame.setLayout(new BorderLayout()); 

    //create the the tabs 
    this.createPanel1(); 
    this.createPanel2(); 
    this.createPanel3(); 

    //create the tabbed pane 
    pane= new JTabbedPane(); 
    pane.addTab("Pane 1", panel1); 
    pane.addTab("Pane 2", panel2); 
    pane.addTab("Pane 3", panel3); 

    //add the pane to the frame 
    frame.add(pane,BorderLayout.CENTER); 
    } 


    //creating the tabs 
    public void createPanel1(){ 
    panel1= new JPanel(); 
    panel1.setLayout(new BorderLayout()); 
    panel1.add(new JButton("we are in panel 1")); 
    panel1.setPreferredSize(new Dimension(300,300)); 
    } 
     public void createPanel2(){ 
    panel2= new JPanel(); 
    panel2.setLayout(new BorderLayout()); 
    panel2.add(new JButton("we are in panel 2")); 
    panel2.setPreferredSize(new Dimension(300,300)); 
    } 
    public void createPanel3(){ 
    panel3= new JPanel(); 
    panel3.setLayout(new BorderLayout()); 
    panel3.add(new JButton("we are in panel 3")); 
    panel3.setPreferredSize(new Dimension(300,300)); 
    } 
    public static void main(String [] args){ 

    JTabbedPaneDemo dem= new JTabbedPaneDemo(); 

    } 
} 
+1

버튼? 탭 패널 안의 탭 자체? – MadProgrammer

+2

사용중인 코드를 표시하십시오. 탭 레이아웃에서 어떤 레이아웃을 사용합니까? – ChiefTwoPencils

+0

탭 패널의 @MadProgrammer 버튼 itseft – JWizard

답변

0

이다; 아마도 누군가는 이것을 필요로 할 것입니다. 나는 실제로 의 크기를 조정하고 싶어, 나는 버튼

mytabbedPane.addTab("<html><body leftmargin=15 topmargin=8 marginwidth=15 marginheight=5>Tab1</body></html>", new JLabel("Text Component 1")); 

이 마진 입력 한 값에 따라 크기가 조정됩니다 근무 코드 될거야은 다음과 같은 잘못된 용어이다 것을 깨달았다.

자세한 내용은 here 인 링크를 찾으십시오.

관련 문제