0

我正在尝试制作基于卡的应用程序。我一直在尝试遵循教程等。这是我的代码。到目前为止它非常简单。窗口显示,但里面的文本窗格没有。

/*
* 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);
}
}
4

1 回答 1

3

JPanel包含JTextPane, screen1, 添加到CardLayout容器中cards

cards.add(screen1, "TextPane Card");

另外:Java 命名规范表明变量以小写字母开头,例如textPaneScreen1.

于 2013-06-12T22:44:13.283 回答