本文整理汇总了Java中javax.swing.JToolBar.repaint方法的典型用法代码示例。如果您正苦于以下问题:Java JToolBar.repaint方法的具体用法?Java JToolBar.repaint怎么用?Java JToolBar.repaint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JToolBar
的用法示例。
在下文中一共展示了JToolBar.repaint方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addCustomToolbarComponent
import javax.swing.JToolBar; //导入方法依赖的package包/类
/**
* Adds the specified custom toolbar component.
* @param compDescription the component description
*/
private void addCustomToolbarComponent(CustomToolbarComponentDescription compDescription) {
if (compDescription==null || compDescription.getToolBarType()==null || compDescription.getToolBarSurrounding()==null) return;
// --------------------------------------------------------------------
// --- Check if the component should currently be added ---------------
// --------------------------------------------------------------------
boolean isExecutionTime = this.graphController.getProject()==null;
boolean addComponent = false;
switch (compDescription.getToolBarSurrounding()) {
case Both:
addComponent = true;
break;
case ConfigurationOnly:
if (isExecutionTime==false) addComponent = true;
break;
case RuntimeOnly:
if (isExecutionTime==true) addComponent = true;
break;
}
if (addComponent==false) return;
// --------------------------------------------------------------------
// --- Get the needed JToolBar ----------------------------------------
// --------------------------------------------------------------------
JToolBar toolBar = null;
switch (compDescription.getToolBarType()) {
case EditControl:
// --- Nothing to do in case of edit & execution --------
if (isExecutionTime==true) return;
toolBar = this.getJToolBarEdit();
break;
case ViewControl:
toolBar = this.getJToolBarView();
break;
}
// --------------------------------------------------------------------
// --- Add the component, if not already there ------------------------
// --------------------------------------------------------------------
AbstractCustomToolbarComponent componentClass = compDescription.getToolBarComponent(this.graphController);
// --- Avoid double creation ------------------------------------------
if (componentClass!=null && componentClass.getCreatedCustomComponent()==null) {
// --- Create and remind the custom component ---------------------
JComponent customComponent = componentClass.getCustomComponent();
componentClass.setCreatedCustomComponent(customComponent);
// --- Does the component already exists --------------------------
if (toolBar.getComponentIndex(customComponent)==-1) {
// --- Add a JSeparator first, if wished ----------------------
if (compDescription.isAddSeparatorFirst()==true) {
JToolBar.Separator separator = new JToolBar.Separator();
if (compDescription.getIndexPosition()==null) {
toolBar.add(separator);
} else {
toolBar.add(separator, (int)compDescription.getIndexPosition());
}
}
// --- Add new component --------------------------------------
if (compDescription.getIndexPosition()==null) {
toolBar.add(customComponent);
} else {
if (compDescription.isAddSeparatorFirst()==true) {
toolBar.add(customComponent, (int)compDescription.getIndexPosition()+1);
} else {
toolBar.add(customComponent, (int)compDescription.getIndexPosition());
}
}
toolBar.validate();
toolBar.repaint();
// --- Remind added component ---------------------------------
this.getCustomToolbarComponentDescriptionAdded().add(compDescription);
}
}
}