Im new to Swing, first of all. Im trying to set the background color of an audio recording applet to make it blend with my webpage (white instead of the default grey), but the change never seems to take. Heres the applet initialization...
public void init()
{
setLayout(null);
setBackground(Color.white);
JLabel recorder = new JLabel("Record");
JLabel fileName = new JLabel("Please Enter File Name");
JLabel status = new JLabel("Status...");
fnametxt = new JTextField("FileNameHere");
statustxt = new JTextField("");
record = new JButton("Record");
play = new JButton("Play");
pause = new JButton("Pause");
stop = new JButton("Stop");
send = new JButton("Upload");
listen = new JButton("Listen");
save = new JButton("Save and Submit");
//A bunch of other stuff, event listeners and whatnot.
Im using no layout managers, Im setting all the positions manually. Any ideas?
You set (presumably) the background of the Applet, but that background will only show where it is not obstructed by another component.
Depending on how you structured your GUI, there may be inner panels or other components covering the area. You need to change the color of those components, too (or alternately set them to be transparent using setOpaque(false)).
Edit: setOpaque() is only available for Swing components, not the Applet itself (since that is plain old AWT).
You probably should set the background color of the content pane.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With