2012-02-16 92 views
0

我想更改一個swing組件的可訪問性級別(即jTextArea),以便我可以在另一個類中訪問它!我正在使用netBeans,但它似乎沒有視覺特徵!這就是我已經試過,但我有我不能修復如何在Java中創建一個私有的swing組件?

public class HttpHeadersFrame extends javax.swing.JFrame 
{ 

/** Creates new form HttpHeadersFrame */ 

    public HttpHeadersFrame() 
    { 
     initComponents(); 
    } 
    public JTextArea getRequestTextArea 
    { 
     return requestTextArea;//Got error that says "initilizer must be to complete normally" 

    } 

// Variables declaration - do not modify 

private javax.swing.JTextArea requestTextArea; 
private javax.swing.JTextArea responseTextArea; 

回答

3

錯誤應該

//         VV 
public JTextArea getRequestTextArea() 
{ 
    return requestTextArea;//Got error that says "initilizer must be to complete normally" 

} 

否則,該塊被視爲一個初始化,你進去一個語法錯誤。

+0

我非常貼心! – Xris 2012-02-16 06:16:46