📄 titledseparator.java
字号:
package com.sshtools.ui.swing;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JSeparator;
import javax.swing.UIManager;
/**
* Swing component that provides a horziontal separator that is preceeded by some text.
*
* @author $Author: lee $
* @version $Revision: 1.2 $
*/
public class TitledSeparator
extends JPanel {
// Private instance variables
/**
* Construct a titled separtor with some text
*
* @param text text
*/
public TitledSeparator(String text) {
super(new GridBagLayout());
GridBagConstraints gbc2 = new GridBagConstraints();
gbc2.fill = GridBagConstraints.HORIZONTAL;
gbc2.anchor = GridBagConstraints.WEST;
gbc2.weightx = 0.0;
gbc2.insets = new Insets(4, 0, 2, 2);
JLabel l = new JLabel(text);
l.setFont(UIManager.getFont("ToolTip.font"));
UIUtil.jGridBagAdd(this, l, gbc2,
GridBagConstraints.RELATIVE);
gbc2.weightx = 1.0;
UIUtil.jGridBagAdd(this, new JSeparator(JSeparator.HORIZONTAL), gbc2,
GridBagConstraints.REMAINDER);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -