2016-05-13 64 views
0

行我想這個用的Java Swing

enter image description here

更換

enter image description here

更換了JTextField是否有可能在的Java Swing?也許這有一些用戶界面庫?

+0

嘗試 - https://github.com/mgarin/weblaf。它有PainterFactory,您可以使用它將背景塗成黑色。通過使用畫家,你也應該可以在普通的java swing中完成。 – sethu

+0

閱讀Java中的[look-n-feeling](https://docs.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html) –

+0

Thankyou!它仍然沒有讓我的下劃線文本框,但你幫我找到了一個有用的圖書館,我將在我目前的項目中使用。 @sethu –

回答

0

你可以嘗試這種方式, 添加jlabeljframe並添加jtextfieldjlabel 然後調用

label.setvisible(false); 
textfield.setvisible(true); 

設置setvisible(false)將隱藏component.and每當你需要顯示的行

label.setvisible(true); 
textfield.setvisible(false); 
2

您不需要任何額外的庫。只需設定JTextField屬性和設置Border

JTextField textField = new JTextField(20); 
    textField.setBackground(Color.BLACK); 
    textField.setForeground(Color.GRAY); 
    textField.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, Color.GRAY));