As looking for a solution, i found almost the same idea in all answers in StackOverflow. But all did not work, i need to help me for a solution for that special part of code.
//Create a JTabbedPane for 2 tabs
mainTabs = new JTabbedPane(JTabbedPane.TOP);
//Create the first tab
reportingTabs = new JTabbedPane(JTabbedPane.TOP);
// editor is an object created from a class inherited form JPanel
editor = new GraphEditor();
//Create a JMenuBar
EditorMenuBar menuBar = new EditorMenuBar(editor);
//Create a JFrame for the editor
editorFrame = editor.createFrame();
//Create a JPanel object to contain bothe the JMenubar and the editor JFrame
JPanel editorPanel = new JPanel(new BorderLayout());
//Here the solution, creating a JScrollPane to contain only the editor JFrame to be scrolled
JScrollPane editorScroll = new JScrollPane();
//Adding the JMenuBar and the editor JFrame to the JPanel
editorPanel.add(menuBar, BorderLayout.NORTH);
editorPanel.add(editorFrame.getContentPane());
//Involve the JPanel into the JScrollPane
editorScroll.add(editorPanel);
//Adding the tabs to the main JFrame
maingui.getContentPane().add(mainTabs);
//Adding the JScrolledPane to a tab
mainTabs.addTab("Editor", editorScroll);
The result, is that thers is no JFrame in maingui. (with no SCrollPane solution, it appreas correctly)
Remove editorScroll variable completely and replace
mainTabs.addTab("Editor", editorScroll);
with
mainTabs.addTab("Editor", new JScrollPane(editorPanel));
It should work...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.