Reputation: 53
I want to make my JTextfield
invisible and read only but the value must be shown in a window frame. I am using window builder in Eclipse.
JLabel lblLabel1 = new JLabel("Default DITA-OT File :");
lblLabel1.setBounds(10, 79, 123, 14);
frmPdfPublisher.getContentPane().add(lblLabel1);
JSeparator separator = new JSeparator();
separator.setBounds(10, 140, 414, 2);
frmPdfPublisher.getContentPane().add(separator);
JSeparator separator_1 = new JSeparator();
separator_1.setBounds(10, 257, 414, 2);
frmPdfPublisher.getContentPane().add(separator_1);
textField_1 = new JTextField();
textField_1.setBounds(138, 76, 286, 20);
frmPdfPublisher.getContentPane().add(textField_1);
textField_1.setColumns(10);
textField_1.setVisible(false);
Upvotes: 1
Views: 666
Reputation: 512
if you want to make it read only than JLable
is better option to do this work .
However if you want to use JTextfield
than make text field as a private member and use a method to settext field hidden .
class Example {
private JTextField tf;
public void hideTextField(){
tf.setVisible(false);
} }
Change the color of Textfield and make it same As color of Panel or frame .
setBackground(Color.white);
And Remove Border Either by overriding setBorder method or by Passing "null" to
setBorder(BorderFactory.createLineBorder(Color.white));
or
txt.setBorder(new LineBorder(Color.white,0));
Upvotes: 2