本文整理汇总了Java中javax.swing.JSeparator.setPreferredSize方法的典型用法代码示例。如果您正苦于以下问题:Java JSeparator.setPreferredSize方法的具体用法?Java JSeparator.setPreferredSize怎么用?Java JSeparator.setPreferredSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JSeparator
的用法示例。
在下文中一共展示了JSeparator.setPreferredSize方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setVisible
import javax.swing.JSeparator; //导入方法依赖的package包/类
/**
* Force separators to be the same width as the JPopupMenu.
* This is because the MenuLayout make separators invisible contrary
* to the default JPopupMenu layout manager.
* @param aFlag true if the popupmenu is visible
*/
@Override
public void setVisible(boolean aFlag) {
super.setVisible(aFlag);
if (!aFlag) { return; }
MenuLayout layout = (MenuLayout) getLayout();
for (int i = 0; i < getComponents().length; i++) {
Component component = getComponents()[i];
if (component instanceof JSeparator) {
JSeparator separator = (JSeparator) component;
int column = layout.getColumnForComponentIndex(i);
int preferredWidth = layout.getPreferredWidthForColumn(column);
// use the popupmenu width to set the separators width
separator.setPreferredSize(new Dimension(
preferredWidth, separator.getHeight()));
}
}
revalidate();
}
示例2: getListCellRendererComponent
import javax.swing.JSeparator; //导入方法依赖的package包/类
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
if (isSelected) {
setBackground(list.getSelectionBackground());
setForeground(list.getSelectionForeground());
} else {
setBackground(list.getBackground());
setForeground(list.getForeground());
}
if (value instanceof Provider) {
Provider provider = (Provider)value;
String text = provider.getDisplayName();
if (value.equals(defaultProvider) && (!(value instanceof DefaultProvider))) {
text += NbBundle.getMessage(PersistenceProviderComboboxHelper.class, "LBL_DEFAULT_PROVIDER");
}
setText(text);
} else if (SEPARATOR.equals(value)) {
JSeparator s = new JSeparator();
s.setPreferredSize(new Dimension(s.getWidth(), 1));
s.setForeground(Color.BLACK);
return s;
} else if (EMPTY.equals(value)) {
setText(" ");
} else if (value instanceof LibraryItem) {
setText(((LibraryItem) value).getText());
} else {
setText(value != null ? value.toString() : ""); // NOI18N
}
return this;
}
示例3: addToBar
import javax.swing.JSeparator; //导入方法依赖的package包/类
private void addToBar(JComponent comp, int pos, boolean priority, boolean separator)
{
JPanel panel = getPanel(pos);
JSeparator sep = new JSeparator(SwingConstants.VERTICAL);
sep.setPreferredSize(new Dimension(3, image.getIconHeight()));
comp.setBorder(new EmptyBorder(0, 5, 0, 5));
boolean sepFirst = false;
int loc = -1;
// This could all be done nicer, but who cares if it works?
if( pos == SwingConstants.RIGHT )
{
if( priority )
{
sepFirst = true;
}
else
{
loc = 0;
}
}
else
{
if( priority )
{
loc = 0;
sepFirst = true;
}
}
if( sepFirst && separator )
{
panel.add(sep, loc);
}
panel.add(comp, loc);
if( !sepFirst && separator )
{
panel.add(sep, loc);
}
}
示例4: horizontalSeparator
import javax.swing.JSeparator; //导入方法依赖的package包/类
private static JComponent horizontalSeparator() {
JSeparator x = new JSeparator(SwingConstants.HORIZONTAL);
x.setPreferredSize(new Dimension(350,3));
return x;
}
示例5: includeSeparator
import javax.swing.JSeparator; //导入方法依赖的package包/类
private void includeSeparator() {
JSeparator separator = new JSeparator(SwingConstants.VERTICAL);
separator.setPreferredSize(new Dimension(2, 14));
this.panel.add(separator);
this.panel.add(FileType.label);
}