Hallo zusammen,
ich bin gerade dabei, mich in Swing einzuarbeiten. Dazu haben ich ein TabbedPane angelegt, mit dem zwei Tabs angezeigt werden sollen. Auf jedem soll ein Scroll Pane zu sehen sein, auf dem dann wiederum ein oder zwei Buttons liegen. Allerdings werden weder das ScrollPane noch die Buttons angezeigt.
Was ist da wohl schiefgelaufen?
Vielen Dank, Gruß, Skrodde
ich bin gerade dabei, mich in Swing einzuarbeiten. Dazu haben ich ein TabbedPane angelegt, mit dem zwei Tabs angezeigt werden sollen. Auf jedem soll ein Scroll Pane zu sehen sein, auf dem dann wiederum ein oder zwei Buttons liegen. Allerdings werden weder das ScrollPane noch die Buttons angezeigt.
Was ist da wohl schiefgelaufen?
Vielen Dank, Gruß, Skrodde
Java:
package optGUI;
import java.awt.FlowLayout;
import java.awt.HeadlessException;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;
import OptController.OptController;
public class OptGUI extends JFrame {
private static final long serialVersionUID = 1L;
private OptController optController;
/**
* @throws HeadlessException
*/
public OptGUI(OptController optController) throws HeadlessException {
//Name the frame "Optimization"
super("Optimization");
this.optController = optController;
//Place the frame in the middle of the screen
setLocationRelativeTo(null);
//End the program via System.exit() when user clicks on (X) of the frame
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//User can not resize the frame
//this.setResizable( false );
//Create a Tabs-Object
JTabbedPane tabs = new JTabbedPane();
this.add(tabs);
//ScrollPane for the Definition of Variables
//------------------------------------------
//Scroll Pane can be scrolled vertically, but not horizontally
JScrollPane pane_1 = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
tabs.addTab("(1) Define Variables", null, pane_1, "Define all necessary variables that are used in the optimization problem.");
//Continue Button that continues to Scroll Pane 2
JButton btn_continue1 = new JButton("Continue");
pane_1.add(btn_continue1);
//ScrollPane for the Definition of Constraints
//--------------------------------------------
//Scroll Pane can be scrolled vertically, but not horizontally
JScrollPane pane_2 = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
tabs.addTab("(2) Define Objective Function", null, pane_2, "Define the Type of the Optimization and the objective Function.");
//Continue Button that continues to Scroll Pane 3
JButton btn_continue2 = new JButton("Continue");
pane_2.add(btn_continue2);
//Backwards Button that goes back to Pane 1
JButton btn_back2 = new JButton("Back");
pane_2.add(btn_back2);
JLabel l = new JLabel( "Lebe immer First-Class, sonst tun es deine Erben! Das ist eine alte Weisheit, beachte sie!" );
this.add( l );
this.pack();
this.setVisible(true);
this.setLayout(new FlowLayout());
}
}