当前位置: 首页>>代码示例>>Java>>正文


Java JSeparator.setPreferredSize方法代码示例

本文整理汇总了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();
}
 
开发者ID:GateNLP,项目名称:gate-core,代码行数:25,代码来源:XJPopupMenu.java

示例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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:37,代码来源:PersistenceProviderComboboxHelper.java

示例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);
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:41,代码来源:JStatusBar.java

示例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;
}
 
开发者ID:cetic,项目名称:SimQRI,代码行数:6,代码来源:SimulationManagementWindow.java

示例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);
}
 
开发者ID:maumss,项目名称:file-type-plugin,代码行数:7,代码来源:FileType.java


注:本文中的javax.swing.JSeparator.setPreferredSize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。