Reputation: 87
Im trying to improve the Java GUI of my project in Netbeans, below is the picture of my project in Netbeans's design palette , the 4 texts are actually JButtons which I have set the Border to false to improve the design.
However in the picture below, you can see the result is quite different from what it should look like and the borders are still there even when I set it as false, I do not know how to get it to look like the picture on top, Ive provided the code for this below for your reference.
Code here: (as you can see I already setBorderPainted(false) which I thought will do the trick but no)
HomeButton = new javax.swing.JButton();
HomeButton.setBackground(new java.awt.Color(102, 102, 102));
HomeButton.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N
HomeButton.setForeground(new java.awt.Color(255, 255, 255));
HomeButton.setText("Home");
HomeButton.setBorderPainted(false);
HomeButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
HomeButtonActionPerformed(evt);
}
});
If you know how to get the result of my code to look like the first image please do update me. Thank you.
Upvotes: 1
Views: 261
Reputation: 3311
Try with:
HomeButton.setContentAreaFilled(false);
along with:
HomeButton.setBorderPainted(false);
... in which case I think setting the background color is not needed, but I am not sure.
Upvotes: 1