Ok... I'm not new to Java... just new to Swing. I'm frustrated with how some of this stuff works, and I was hoping someone could clear this little bit up for me.
I've got a JButton. I want to wipe away the margins and set the size of the margin as I like. However, depending on the layout of the JPanel, I get different results for the same lines (that should in my mind do the same thing)... Here are the lines in question.
import javax.swing.*;
import java.awt.*;
public class XXXXXX extends JFrame {
public XXXXXX() {
//...
JPanel panel = new JPanel();
getContentPane().add(panel);
panel.setLayout(null);
JButton sendMsgBtn = new JButton("Send");
sendMsgBtn.setBounds(200, 60, 50, 30);
sendMsgBtn.setMargin(new Insets(0,0,0,0));
panel.add(sendMsgBtn);
}
}
When I comment out the panel.setLayout(null) line of code then the setMargins works (but the setSize part of the setBounds doesn't work). However, when I leave the line uncommented, the setSize part of setBounds works (but the setMargin doesn't work). Any ideas?
I guess the pertinent question would be this... Why doesn't the setMargin() call work since I've set the Layout to null?