我想讓我的JTextArea只顯示插入符號。我已將JTextArea設置爲不透明,但無法隱藏文本。如何做到這一點JTextArea使文字不可見
JTextArea text = new JTextArea();
text.setOpaque(false);//This doesn't make text transparent
我想讓我的JTextArea只顯示插入符號。我已將JTextArea設置爲不透明,但無法隱藏文本。如何做到這一點JTextArea使文字不可見
JTextArea text = new JTextArea();
text.setOpaque(false);//This doesn't make text transparent
此代碼:
JTextArea a = new JTextArea();
a.setText("hello, world!");
a.setForeground(new Color(0, 0, 0, 0));
似乎正常工作時,我測試了它,它使兩個組文字和輸入的文字不可見。
_Invisible_和_show_似乎矛盾。請編輯您的問題以包含一個[sscce](http://sscce.org/),以顯示您正在做的事情。圖片和平臺/外觀的名稱也會有所幫助。 – trashgod 2012-03-24 13:06:25
是否要刪除'JTextArea'中的文本,或者只是保留文本但使其不可見(如同使用與JTextArea背景顏色相同的字體顏色)? – Robin 2012-03-24 13:11:34
也許你想要設置JTextarea的前景顏色與背景顏色相同。 – 2012-03-24 13:12:03