JTabbedPane Component in Java
Submitted by donbermoy on Monday, November 17, 2014 - 11:48.
This is a tutorial in which we will going to create a program that has the JTabbedPane Component using Java. The JTabbedPane is used to let the user switch on other menus or components by clicking on a tab with a given title or icon.
So, now let's start this tutorial!
1. Open JCreator or NetBeans and make a java program with a file name of jTabbedPaneComponent.java.
2. Import the javax.swing package to access the JFrame,JButton, JLabel,JTextField, and the JTabbedPane class.
3. Initialize your variable in your Main, variable frame for creating JFrame and variable tabbedPane for the JTabbedPane component.
4. To create a tab in the TabbedPane we will use the addTabmethod. The first tab that we will create will be equal to 0 and the last tab will be equal to the tab index minus 1. Have this code below:
We have use the addTab Method to create tabbed pane in the frame. This addTab method has this parameters of String and the Component. We have created three tabbed pane above, the Transaction, Maintenance, and Inquiry as the string text and the second parameter has the parameters of JButton, JLabel, and JTextField component.
5. Now, add the tabbed pane to the frame using the default BorderLayout of the North orientation of the getContentPane. Then set the size, visibility, and the close operation of the frame. Have this code below:
Output:
Here's the full code of this tutorial:
For more inquiries and need programmer for your thesis systems in any kind of programming languages, just contact my number of Facebook Page below.
Best Regards,
Engr. Lyndon Bermoy
IT Instructor/System Developer/Android Developer/Freelance Programmer
Mobile: 09488225971
Landline: 826-9296
E-mail:[email protected]
Add and Follow me on Facebook: https://www.facebook.com/donzzsky
Visit and like my page on Facebook at: https://www.facebook.com/BermzISware
- import javax.swing.*; // this is used to access the JFrame,JButton, JLabel,JTextField, and the JTabbedPane class
- frame.getContentPane().add(tabbedPane, "North");
- frame.setSize(400, 150);
- frame.setVisible(true);

- import javax.swing.*; // this is used to access the JFrame,JButton, JLabel,JTextField, and the JTabbedPane class
- public class jTabbedPaneComponent {
- frame.getContentPane().add(tabbedPane, "North");
- frame.setSize(400, 150);
- frame.setVisible(true);
- }
- }
Add new comment
- 132 views