Add JTabbedPane with buttons, labels ... in a frame with an absolute layout

Posted by alibenmessaoud on Stack Overflow See other posts from Stack Overflow or by alibenmessaoud
Published on 2011-02-14T02:49:40Z Indexed on 2013/06/27 22:21 UTC
Read the original article Hit count: 238

I have a code in java.

package interfaces;

 import javax.swing.JPanel;

 public class TabbedPaneDemo extends JPanel {
public TabbedPaneDemo() {
    JTabbedPane pane = new JTabbedPane();

    JPanel dashboardPanel = new JPanel();
    dashboardPanel.add(new JLabel("Dashboard"));
    // Add Dashboard Tab
    pane.addTab("Dashboard", dashboardPanel);

    JPanel transactionPanel = new JPanel();
    transactionPanel.add(new JLabel("Transactions"));
    // Add Transactions Tab
    pane.addTab("Transactions", transactionPanel);

    JPanel accountPanel = new JPanel();
    accountPanel.add(new JLabel("Account"));
    // Add Account Tab
    pane.addTab("Account", accountPanel);

    this.setLayout(new BorderLayout());
    this.setPreferredSize(new Dimension(400, 200));
    this.add(pane, BorderLayout.CENTER);
}




public static void main(String[] args) {

    JPanel panel = new TabbedPaneDemo();
     panel.setOpaque(true);
   // panel.setBounds(12, 12, 45, 98);

    JFrame frame = new JFrame("JTabbedPane Demo");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setContentPane(panel);
    frame.pack();
    frame.setVisible(true);
}}

and the output it's !

enter image description here

I want to change in this code to be like this.

enter image description here

I want use an absolute layout (null). I want to add menu, buttons and labels with these tabs ...

How can I do??

Thanks in advance.

Best regards, Ali

© Stack Overflow or respective owner

Related posts about java

Related posts about swing