下面列出了javax.swing.JToolBar#Separator ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public void setOperationMode(OperationMode mode) {
// toolBarAttributes.setVisible(mode == OperationMode.MODELLING);
toolBarAlignment.setVisible(mode == OperationMode.MODELLING);
// Items in Toolbar "Create"
buttonCreatePoint.setVisible(mode == OperationMode.MODELLING);
buttonCreateLocation.setVisible(mode == OperationMode.MODELLING);
buttonCreatePath.setVisible(mode == OperationMode.MODELLING);
buttonCreateLink.setVisible(mode == OperationMode.MODELLING);
buttonCreateLocationType.setVisible(mode == OperationMode.MODELLING);
buttonCreateVehicle.setVisible(mode == OperationMode.MODELLING);
buttonCreateBlock.setVisible(mode == OperationMode.MODELLING);
buttonCreateGroup.setVisible(mode == OperationMode.MODELLING);
for (JToolBar.Separator sep : separatorList) {
sep.setVisible(mode == OperationMode.MODELLING);
}
buttonCreateOrder.setEnabled(mode == OperationMode.OPERATING);
buttonFindVehicle.setEnabled(mode == OperationMode.OPERATING);
buttonPauseAllVehicles.setVisible(mode == OperationMode.OPERATING);
}
/** Overridden to set focusable to false for any AbstractButton
* subclasses which are added */
@Override
protected void addImpl(Component c, Object constraints, int idx) {
//issue 39896, after opening dialog from toolbar button, focus
//remains on toolbar button. Does not create an accessibility issue -
//all standard toolbar buttons are also available via the keyboard
if (c instanceof AbstractButton) {
c.setFocusable(false);
((JComponent) c).setOpaque(false);
if (isMetalLaF) {
//metal/ocean resets borders, so fix it this way
((AbstractButton) c).setBorderPainted(false);
((AbstractButton) c).setOpaque(false);
}
//This is active for GTK L&F. It should be fixed in JDK
//but it is not fixed in JDK 6.0.
if (!isMetalLaF && !isFlatLaF) {
((AbstractButton) c).setMargin( emptyInsets );
}
if( null != label && c != label ) {
remove( label );
label = null;
}
} else if( c instanceof JToolBar.Separator ) {
JToolBar.Separator separator = (JToolBar.Separator)c;
if (getOrientation() == VERTICAL) {
separator.setOrientation(JSeparator.HORIZONTAL);
} else {
separator.setOrientation(JSeparator.VERTICAL);
}
}
super.addImpl (c, constraints, idx);
}
public ToolbarAqua() {
super( new BorderLayout() );
JSeparator sep = new JToolBar.Separator();
sep.setOrientation(JSeparator.VERTICAL);
sep.setForeground(UIManager.getColor("NbSplitPane.background")); //NOI18N
add( sep, BorderLayout.CENTER );
dim = new Dimension (GRIP_WIDTH, GRIP_WIDTH);
max = new Dimension (GRIP_WIDTH, Integer.MAX_VALUE);
setBorder(BorderFactory.createEmptyBorder(4, 0, 2, 0));
}
public void addSpace(int width) {
Dimension dim = horizontal ? new Dimension(width, 0) : new Dimension(0, width);
JToolBar.Separator separator = new JToolBar.Separator(dim);
separator.setOrientation(horizontal ? JToolBar.Separator.VERTICAL :
JToolBar.Separator.HORIZONTAL);
addItem(separator);
}
public void addSeparator() {
JToolBar.Separator separator = new JToolBar.Separator();
separator.setOrientation(JToolBar.Separator.VERTICAL);
addItem(separator);
}
protected JSeparator createInstanceImpl() {
return separatorSize == null ? new JToolBar.Separator() :
new JToolBar.Separator(separatorSize.createInstance());
}
/**
* Register all actions as listed in the descriptor files, and organize them
* according to the various domains defined.
* There is one pull-down menu generated for each domain found.
*/
public void registerAllActions ()
{
// Insert an initial separator, to let user easily grab the toolBar
toolBar.addSeparator();
DomainLoop:
for (String domain : Actions.getDomainNames()) {
// Create dedicated menu for this range, if not already existing
JMenu menu = menuMap.get(domain);
if (menu == null) {
logger.debug("Creating menu:{}", domain);
menu = new SeparableMenu(domain);
menuMap.put(domain, menu);
} else {
logger.debug("Augmenting menu:{}", domain);
}
// Proper menu decoration
ResourceMap resource = OmrGui.getApplication().getContext().getResourceMap(
Actions.class);
menu.setText(domain); // As default
menu.setName(domain);
// Register all actions in the given domain
registerDomainActions(domain, menu);
resource.injectComponents(menu); // Localized
SeparableMenu.trimSeparator(menu); // No separator at end of menu
// Smart insertion of the menu into the menu bar, and separators into the toolBar
if (menu.getItemCount() > 0) {
final int toolCount = toolBar.getComponentCount();
if (toolCount > 0) {
Component comp = toolBar.getComponent(toolCount - 1);
if (!(comp instanceof JToolBar.Separator)) {
toolBar.addSeparator();
}
}
menuBar.add(menu);
}
}
}
public void addSeparator() {
JToolBar.Separator separator = new JToolBar.Separator();
separator.setOrientation(JToolBar.Separator.VERTICAL);
addItem(separator);
}
protected JSeparator createInstanceImpl() {
return separatorSize == null ? new JToolBar.Separator() :
new JToolBar.Separator(separatorSize.createInstance());
}
public void addSeparator() {
JToolBar.Separator separator = new JToolBar.Separator();
separator.setOrientation(horizontal ? JToolBar.Separator.VERTICAL :
JToolBar.Separator.HORIZONTAL);
addItem(separator);
}
private JToolBar.Separator getToolBarSeparator() {
if (toolBarSeparator == null) {
toolBarSeparator = new JToolBar.Separator();
}
return toolBarSeparator;
}
private JToolBar.Separator getToolbarSeparator() {
if (toolbarSeparator == null) {
toolbarSeparator = new JToolBar.Separator();
}
return toolbarSeparator;
}