I\'m working on a log in server & my JTextFields
aren\'t transparent when I set Opaque to false
.
My code:
//username
no idea what you tried, for better help sooner post an SSCCE, short. runnable, compilable with setBackground instead of Image
import java.awt.*;
import javax.swing.*;
import javax.swing.text.*;
public class LabelImageText extends JPanel {
private static final long serialVersionUID = 1L;
public LabelImageText() {
JTextField jUsername = new JTextField(10);
jUsername.setText("MyText");
jUsername.setOpaque(false);
//jUsername.setBorder(null);
add(jUsername);
JTextField jPassword = new JTextField(15);
jPassword.setText("MyText");
jPassword.setOpaque(false);
//jPassword.setBorder(null);
add(jPassword);
setBackground(Color.RED);
}
private static void createAndShowUI() {
JFrame frame = new JFrame("set Opaque");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.add(new LabelImageText());
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
createAndShowUI();
}
});
}
}