gpt4 book ai didi

java - 如何删除 Accordion 标签上的数字?

转载 作者:行者123 更新时间:2023-12-01 22:20:31 27 4
gpt4 key购买 nike

Accordion 可以在这里下载 - http://www.javaswingcomponents.com/product/accordion

accordion sample

这是 Accordion 的示例输出。我想删除选项卡右侧的数字。我该怎么做?谢谢!

示例代码如下:

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Container;
import java.awt.GridLayout;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import com.javaswingcomponents.accordion.JSCAccordion;
import com.javaswingcomponents.accordion.TabOrientation;

public class SampleAccordion extends JPanel {
static JFrame frame;

public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
SampleAccordion codeExample = new SampleAccordion();
frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container panel = frame.getContentPane();
panel.setLayout(new BorderLayout());
panel.add(codeExample, BorderLayout.CENTER);
frame.pack();
frame.setSize(500, 300);
frame.setVisible(true);
}
});
}

public SampleAccordion() {
JSCAccordion accordion = new JSCAccordion();
JPanel transparentPanel = new JPanel();
transparentPanel.setOpaque(false);
transparentPanel.setBackground(Color.GRAY);

JPanel opaquePanel = new JPanel();
opaquePanel.setOpaque(true);
opaquePanel.setBackground(Color.GRAY);

accordion.addTab("Tab 1", new JLabel("help me remove 1"));
accordion.addTab("Tab 2", new JLabel("help me remove 2"));

accordion.setTabOrientation(TabOrientation.VERTICAL);

setLayout(new GridLayout(1, 1, 30, 30));
add(accordion);
}

}

最佳答案

enter image description here

您可以指定是否要查看选项卡索引:

accordion.setTabOrientation(TabOrientation.VERTICAL);
((FormattedTabRenderer) accordion.getTabRenderer()).setShowIndex(false);

(第一行已经在示例代码中,仅作为引用。)

看起来 Accordion 支持三种可插入的外观和感觉:基本、钢和暗钢。我不确定选项卡渲染器是否可以转换为所有 PLAF 的 FormattedTabRenderer 抽象类,但它似乎适用于钢。

关于java - 如何删除 Accordion 标签上的数字?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29905494/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com