I am trying to make a card based application. I've been trying to follow tutorials and such. Here is my code. So far its very simple. The window shows up but the textpane inside does not.
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package professorphysinstall;
/**
*
* @author Kyle
*/
//Imports
import java.awt.CardLayout;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextPane;
public class ProfessorPhysInstall {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
//Variables
JFrame mainframe = new JFrame();
mainframe.setSize(500, 435);
JPanel cards = new JPanel(new CardLayout());
CardLayout cl = (CardLayout)(cards.getLayout());
mainframe.setTitle("Future Retro Gaming Launcher");
//Screen1
JPanel screen1 = new JPanel();
JTextPane TextPaneScreen1 = new JTextPane();
TextPaneScreen1.setEditable(false);
TextPaneScreen1.setBackground(new java.awt.Color(240, 240, 240));
TextPaneScreen1.setText("Welcome to the install wizard for Professor Phys!\n\nPlease agree to the following terms and click the next button to continue.");
TextPaneScreen1.setSize(358, 48);
TextPaneScreen1.setLocation(0, 0);
screen1.add(TextPaneScreen1);
mainframe.add(cards);
mainframe.setVisible(true);
}
}
Add the JPanel
containing the JTextPane
, screen1
, to the CardLayout
container cards
:
cards.add(screen1, "TextPane Card");
Aside: Java naming concentions show that variables start with a lowercase letter such as textPaneScreen1
.