我試圖製作一個邊框,這是成功的。我希望在邊界開始之前有一段距離。現在使用此代碼,邊框圍繞文本框非常緊密。這就是我想做的事:Ideal在Java中有間距的邊界?
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);
TextPaneScreen1.setBorder(BorderFactory.createLineBorder(Color.black));
TextPaneScreen1.setMargin(new Insets(3,3,3,3));
screen1.add(TextPaneScreen1);
cards.add(screen1);
mainframe.add(cards);
mainframe.setVisible(true);
}
喜歡的東西,'TextPaneScreen1.setPreferredSize(新尺寸(400,150) );'? –