javax.swing.JComponent#repaint ( )源码实例Demo

下面列出了javax.swing.JComponent#repaint ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: Rails   文件: GridPanel.java
/**
 * highlights given component by altering its border's attributes
 */
protected void setHighlight(JComponent comp,boolean isToBeHighlighted) {
    //quit if nothing is to be done
    if (isToBeHighlighted && highlightedComps.contains(comp)) return;
    if (!isToBeHighlighted && !highlightedComps.contains(comp)) return;

    if (comp.getBorder() instanceof FieldBorder) {
        FieldBorder fb = (FieldBorder)comp.getBorder();
        fb.setHighlight(isToBeHighlighted);
        comp.repaint();
        if (isToBeHighlighted) {
            highlightedComps.add(comp);
        } else {
            highlightedComps.remove(comp);
        }
    }
}
 
源代码2 项目: visualvm   文件: PluggableTreeTableView.java
private static void checkVisibility(JComponent comp) {
    if (comp == null) return;

    comp.invalidate();
    comp.revalidate();
    comp.doLayout();
    comp.repaint();

    for (Component c : comp.getComponents())
        if (c.isVisible()) {
            comp.setVisible(true);

            return;
        }

    comp.setVisible(false);
}
 
void repaintComponents()
{
  synchronized (components) {
    for (final JComponent comp : components) {
      comp.invalidate();
      comp.repaint();
    }
  }
}
 
源代码4 项目: Rails   文件: GridPanel.java
protected void removeAllHighlights() {
    for (JComponent c : highlightedComps) {
        if (c.getBorder() instanceof FieldBorder) {
            FieldBorder fb = (FieldBorder)c.getBorder();
            fb.setHighlight(false);
            c.repaint();
        }
    }
    highlightedComps.clear();
}
 
void repaintComponents()
{
  synchronized (components) {
    for (final JComponent comp : components) {
      comp.invalidate();
      comp.repaint();
    }
  }
}
 
源代码6 项目: gcs   文件: FeatureEditor.java
private void removeFeature() {
    JComponent parent = (JComponent) getParent();
    parent.remove(this);
    if (parent.getComponentCount() == 0) {
        parent.add(new NoFeature(mRow));
    }
    parent.revalidate();
    parent.repaint();
}
 
源代码7 项目: megamek   文件: MenuScroller.java
private void refreshMenu() {
  if (menuItems != null && menuItems.length > 0) {
    firstIndex = Math.max(topFixedCount, firstIndex);
    firstIndex = Math.min(menuItems.length - bottomFixedCount - scrollCount, firstIndex);

    upItem.setEnabled(firstIndex > topFixedCount);
    downItem.setEnabled(firstIndex + scrollCount < menuItems.length - bottomFixedCount);

    menu.removeAll();
    for (int i = 0; i < topFixedCount; i++) {
      menu.add(menuItems[i]);
    }
    if (topFixedCount > 0) {
      menu.add(new JSeparator());
    }

    menu.add(upItem);
    for (int i = firstIndex; i < scrollCount + firstIndex; i++) {
      menu.add(menuItems[i]);
    }
    menu.add(downItem);

    if (bottomFixedCount > 0) {
      menu.add(new JSeparator());
    }
    for (int i = menuItems.length - bottomFixedCount; i < menuItems.length; i++) {
      menu.add(menuItems[i]);
    }

    JComponent parent = (JComponent) upItem.getParent();
    parent.revalidate();
    parent.repaint();
  }
}
 
源代码8 项目: gcs   文件: SkillDefaultEditor.java
private void addDefault() {
    SkillDefault skillDefault = new SkillDefault(LAST_ITEM_TYPE, LAST_ITEM_TYPE.isSkillBased() ? "" : null, null, 0); //$NON-NLS-1$
    JComponent   parent       = (JComponent) getParent();
    parent.add(new SkillDefaultEditor(skillDefault));
    if (mDefault == null) {
        parent.remove(this);
    }
    parent.revalidate();
    parent.repaint();
    notifyActionListeners();
}
 
源代码9 项目: gcs   文件: PrereqEditor.java
@Override
public void actionPerformed(ActionEvent event) {
    String command = event.getActionCommand();
    if (CHANGE_BASE_TYPE.equals(command)) {
        Class<?> type = BASE_TYPES[mBaseTypeCombo.getSelectedIndex()];
        if (!mPrereq.getClass().equals(type)) {
            JComponent parent    = (JComponent) getParent();
            PrereqList list      = mPrereq.getParent();
            int        listIndex = list.getIndexOf(mPrereq);
            try {
                Prereq prereq;
                if (type == ContainedWeightPrereq.class) {
                    prereq = new ContainedWeightPrereq(list, mRow.getDataFile().defaultWeightUnits());
                } else {
                    prereq = (Prereq) type.getConstructor(PrereqList.class).newInstance(list);
                }
                if (prereq instanceof HasPrereq && mPrereq instanceof HasPrereq) {
                    ((HasPrereq) prereq).has(((HasPrereq) mPrereq).has());
                }
                list.add(listIndex, prereq);
                list.remove(mPrereq);
                parent.add(create(mRow, prereq, mDepth), UIUtilities.getIndexOf(parent, this));
            } catch (Exception exception) {
                // Shouldn't have a failure...
                exception.printStackTrace(System.err);
            }
            parent.remove(this);
            parent.revalidate();
            parent.repaint();
            ListPrereqEditor.setLastItemType(type);
        }
    } else if (CHANGE_HAS.equals(command)) {
        ((HasPrereq) mPrereq).has(((JComboBox<?>) event.getSource()).getSelectedIndex() == 0);
    } else {
        super.actionPerformed(event);
    }
}
 
源代码10 项目: visualvm   文件: SimpleXYChartUtils.java
public static void setZoomingEnabled(JComponent chartUI, boolean enabled) {
    SimpleXYChart chart = (SimpleXYChart)chartUI.getClientProperty("chart"); // NOI18N
    
    if (chart.isZoomingEnabled() == enabled) return;
    else chart.setZoomingEnabled(enabled);
    
    JPanel sidePanel = (JPanel)chartUI.getClientProperty("sidePanel"); // NOI18N
    JPanel scrollerPanel = (JPanel)chartUI.getClientProperty("scrollerPanel"); // NOI18N
    
    if (enabled) {
        TransparentToolBar toolbar = new TransparentToolBar(false);
        for (Action action : chart.getActions()) toolbar.addItem(action);
        sidePanel.add(toolbar);
        
        JScrollBar scroller = chart.getScroller();
        scroller.setSize(scroller.getPreferredSize());
        scrollerPanel.add(scroller);
        chart.putClientProperty("scroller", scroller); // NOI18N
    } else {
        sidePanel.removeAll();
        scrollerPanel.removeAll();
        chart.putClientProperty("scroller", null); // NOI18N
    }
    
    sidePanel.setVisible(enabled);
    
    chartUI.doLayout();
    chartUI.repaint();
}
 
源代码11 项目: ChatGameFontificator   文件: ComboMenuBar.java
public void updateScroll()
{
    List<JMenuItem> menuKeyList = getKeyList();

    // Keep the first index less than the total number available in the list (unfiltered) minus the length of the scroll count, and no lower than zero
    firstIndex = Math.min(firstIndex, menuKeyList.size() - SCROLL_COUNT);
    firstIndex = Math.max(firstIndex, 0);
    int lastIndex = firstIndex + Math.min(menuKeyList.size(), SCROLL_COUNT);

    int runningUnfilteredCount = 0;
    for (int i = 0; i < menuKeyList.size(); i++)
    {
        JMenuItem jmi = menuKeyList.get(i);
        MenuVisibilityStatus status = allMenuItems.get(jmi);
        final boolean inScrollBounds = !status.isFiltered() && runningUnfilteredCount >= firstIndex && runningUnfilteredCount < lastIndex;
        status.setOutOfScrollBounds(!inScrollBounds);
        if (!status.isFiltered())
        {
            runningUnfilteredCount++;
        }
    }

    mainMenu.getPopupMenu().removeAll();
    setMenuItemFilterVisibility();

    upItem.setEnabled(firstIndex > 0);
    mainMenu.getPopupMenu().add(upItem);
    List<JMenuItem> inBoundsScrollMenuFolders = getInBoundScrollMenuFolders();

    for (JMenuItem menuFolder : inBoundsScrollMenuFolders)
    {
        mainMenu.getPopupMenu().add(menuFolder);
    }
    downItem.setEnabled(lastIndex < runningUnfilteredCount);
    mainMenu.getPopupMenu().add(downItem);

    JComponent parent = (JComponent) upItem.getParent();
    parent.revalidate();
    parent.repaint();
}
 
void repaintComponents()
{
  for (final JComponent comp : components) {
    comp.invalidate();
    comp.repaint();
  }
}
 
源代码13 项目: pumpernickel   文件: AnimatedLayout.java
protected void layoutContainerImmediately(JComponent parent) {
	synchronized (parent.getTreeLock()) {
		Map<JComponent, Rectangle> destMap = getDestinationMap(parent);
		for (Entry<JComponent, Rectangle> entry : destMap.entrySet()) {
			entry.getKey().setBounds(entry.getValue());
		}
	}
	parent.repaint();
}
 
源代码14 项目: jmeter-plugins   文件: GraphPanel.java
/**
 *
 */
public void updateGui() {
    graphPanelObject.invalidateCache();
    JComponent selectedTab = (JComponent) getSelectedComponent();
    selectedTab.updateUI();
    selectedTab.repaint();
}
 
源代码15 项目: jclic   文件: AbstractBox.java
public void repaint() {
  JComponent jc = getContainerResolve();
  if (jc != null)
    jc.repaint(getBorderBounds());
  if (hostedComponent != null)
    hostedComponent.repaint();
}
 
源代码16 项目: netbeans   文件: ViewUtils.java
public static void repaint(JComponent component, Rectangle2D r) {
    component.repaint((int)r.getX(), (int)r.getY(), (int)r.getWidth(), (int)r.getHeight());
}
 
源代码17 项目: Rails   文件: HexMap.java
/**
 * Do only call this method if you are sure that a complete repaint is
 * needed!
 */
public synchronized void repaintAll(Rectangle r) {
    for (JComponent l : layers) {
        l.repaint(r);
    }
}
 
源代码18 项目: basicv2   文件: BlockCaret.java
public void mouseClicked(MouseEvent e) {
	JComponent c = (JComponent) e.getComponent();
	c.repaint();
}
 
源代码19 项目: jclic   文件: TextGrid.java
public void repaintCell(int px, int py) {
  JComponent jc = getContainerResolve();
  if (jc != null)
    jc.repaint(getCellBorderBounds(px, py));
}
 
源代码20 项目: pumpernickel   文件: AbstractPanelUI.java
/**
 * Repaint all panels using this UI.
 */
protected void repaintInstalledPanels() {
	for (JComponent jc : getInstalledPanels()) {
		jc.repaint();
	}
}