我是挥杆初学者。我尝试为我的项目创建一个选项卡式窗口作为 GUI 的一部分。但如下所示,用于导航选项卡的按钮显示了某种边框。有没有办法可以删除这些边框?请参阅附图以查看问题。
GUI的代码如下
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Toolkit;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
public class tst {
/**
* @param args the command line arguments
*/
public static String generateHtml(String tabButtonLabel,String style) {
/*@@Generates HTML for the tab button when the button label is given*/
String ret = "<html><body style = '"+style+"'>"+tabButtonLabel+"</body></html>";
return ret;
}
public static void main(String[] args) {
// TODO code application logic here
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
JFrame frame = new JFrame("tst");
frame.setVisible(true);
frame.setSize(screenSize);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
/*Groups tab*/
JPanel groups = new JPanel();
groups.setBackground(Color.gray);
/*Settings Tab*/
JPanel settings = new JPanel();
/*About Tab*/
JPanel about = new JPanel();
/*Tabbed pane to hold all panels*/
JTabbedPane tabbedPane = new JTabbedPane();
/*Tabbed Pane CSS*/
String tabButtonCss = "margin:0;width:110px;height:10px;border-radius:3px;padding:10px;background:#fff;text-align:center;border:none;";
tabbedPane.setVisible(true);
tabbedPane.add(generateHtml("Groups",tabButtonCss),groups);
tabbedPane.add("Settings",settings);
tabbedPane.add("About",about);
/*Tab styles*/
tabbedPane.setBackground(Color.gray);
tabbedPane.setForeground(Color.white);
tabbedPane.setBounds(0, 0, 0,0);
//tabbedPane.setBorder(new EmptyBorder(-10,-20,-10,0));
frame.add(tabbedPane);
}
}