[英]When i trying to install SVN Connectors i got below error. I used eclipse neon
[英]I am trying to user Swing in Eclipse but I keep getting this error. See below
private void initialize() {
frame = new JFrame();
frame.setBounds(100, 100, 450, 300);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JLabel lblSomeText = new JLabel("Hello, World!");
frame.getContentPane().add(lblSomeText, BorderLayout.CENTER); //error here
}
它說:“類型容器在 frame.getContentPane() 周圍不可見”
以下完整代碼對我有用。 請檢查您的導入並向我們展示您的完整代碼,以便我們為您提供幫助!
package stackoverflow;
import javax.swing.JFrame;
import javax.swing.JLabel;
public class SwingTest {
public static void main( String[] args ) {
JFrame frame = new JFrame();
JLabel lblSomeText = new JLabel( "Hello, World!" );
frame.getContentPane().add( lblSomeText );
frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
frame.setSize( 640, 480 ); // use setSize() instead of setBounds
// frame.pack(); // or call pack() instead
frame.setLocationRelativeTo( null );
frame.setVisible( true );
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.