I'm creating a notepad program in Java and would like to have different tabs to for each document opened. I'm having trouble getting the tabs to be displayed. This is my test document so far that I have looked over here at first and I modified it for the text document. How to add a JScrollPane onto a JTabbedPane using a null layout?.
This is what I currently have:
import java.awt.*;
import javax.swing.*;
public class Test extends JFrame {
private static void CreateAndShowGui() {
JFrame frame = new JFrame("Program");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JTextPane txt = new JTextPane();
JPanel noWrapPanel = new JPanel(new BorderLayout());
noWrapPanel.add(txt);
JScrollPane scroll = new JScrollPane(noWrapPanel);
JPanel topPanel = new JPanel();
topPanel.setLayout(new BorderLayout());
frame.add(topPanel);
JPanel panel = new JPanel();
panel.setLayout(new BorderLayout());
panel.add(scroll, BorderLayout.CENTER);
JTabbedPane tabbedPane = new JTabbedPane();
tabbedPane.addTab("Welcome", panel);
topPanel.add(tabbedPane);
frame.add(scroll);
frame.setSize(400, 200);
frame.setVisible(true);
}
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
UIManager.put("swing.boldmetal", Boolean.FALSE);
CreateAndShowGui();
}
});
}
}
What am I doing wrong? :(