本文整理汇总了Java中java.awt.Component.repaint方法的典型用法代码示例。如果您正苦于以下问题:Java Component.repaint方法的具体用法?Java Component.repaint怎么用?Java Component.repaint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.Component
的用法示例。
在下文中一共展示了Component.repaint方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addImpl
import java.awt.Component; //导入方法依赖的package包/类
protected void addImpl(Component comp, Object constraints, int index) {
int layer;
int pos;
if(constraints instanceof Integer) {
layer = ((Integer)constraints).intValue();
setLayer(comp, layer);
} else
layer = getLayer(comp);
pos = insertIndexForLayer(layer, index);
super.addImpl(comp, constraints, pos);
comp.validate();
comp.repaint();
validateOptimizedDrawing();
}
示例2: handleDocumentEvent
import java.awt.Component; //导入方法依赖的package包/类
private void handleDocumentEvent(DocumentEvent e, Shape a,
ViewFactory f) {
int n = calculateLineCount();
if (this.nlines != n) {
this.nlines = n;
WrappedSyntaxView.this.preferenceChanged(this, false, true);
// have to repaint any views after the receiver.
RSyntaxTextArea textArea = (RSyntaxTextArea)getContainer();
textArea.repaint();
// Must also revalidate container so gutter components, such
// as line numbers, get updated for this line's new height
Gutter gutter = RSyntaxUtilities.getGutter(textArea);
if (gutter!=null) {
gutter.revalidate();
gutter.repaint();
}
}
else if (a != null) {
Component c = getContainer();
Rectangle alloc = (Rectangle) a;
c.repaint(alloc.x, alloc.y, alloc.width, alloc.height);
}
}
示例3: setupProgress
import java.awt.Component; //导入方法依赖的package包/类
private void setupProgress() {
setIcon(createProgressIcon());
t = new Timer(100, new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
Component comp = refComp.get();
TreeListNode nd = refNode.get();
if (nd == null && comp == null) {
t.stop();
Container p = getParent();
if (p != null) {
p.remove(ProgressLabel.this);
}
} else {
busyIcon.tick();
ProgressLabel.this.repaint();
if (nd != null) {
nd.fireContentChanged();
} else {
comp.repaint();
}
}
}
});
t.setRepeats(true);
super.setVisible(false);
}
示例4: processRepaint
import java.awt.Component; //导入方法依赖的package包/类
protected void processRepaint(ViewLayoutState.Parent lsParent) {
int firstRepaintChildIndex = getChildren().getFirstRepaintChildIndex();
if (firstRepaintChildIndex >= 0 && firstRepaintChildIndex < getViewCount()) {
double repY = getChildren().getMajorAxisOffset(firstRepaintChildIndex);
repY += firstRepaintChildYSubOffset;
int repaintY = (int)Math.floor(repY);
int repaintX;
int repaintHeight;
if (isRepaintTillEnd()) {
repaintX = 0; // till end should always be since begining
repaintHeight = lastAllocationHeight;
} else { // repaint only inside one child
repaintX = (int)Math.floor(firstRepaintChildXSubOffset);
double repYEnd = repY
+ getChild(firstRepaintChildIndex).getLayoutMajorAxisPreferredSpan();
repaintHeight = (int)Math.ceil(repYEnd) - repaintY;
}
int repaintWidth = lastAllocationWidth - repaintX;
// Shift repaintX by lastAllocationX
repaintX += lastAllocationX;
if (debugRepaint) {
System.err.println("REPAINT(childIndex=" + firstRepaintChildIndex // NOI18N
+ ", rect(" + repaintX + ", " + repaintY // NOI18N
+ ", " + repaintWidth + ", " + repaintHeight + "))" // NOI18N
); // NOI18N
}
Component c = getContainer();
if (c != null) {
c.repaint(repaintX, repaintY, repaintWidth, repaintHeight);
}
}
}
示例5: setText
import java.awt.Component; //导入方法依赖的package包/类
public void setText(String text) {
if (button != null) {
String _text = button.getText();
button.setText(text);
Component parent = getParent();
if (!Objects.equals(text, _text) && parent != null) {
parent.invalidate();
parent.revalidate();
parent.repaint();
}
}
}
示例6: setIcon
import java.awt.Component; //导入方法依赖的package包/类
public void setIcon(Icon icon) {
if (button != null) {
Icon _icon = button.getIcon();
button.setIcon(icon);
Component parent = getParent();
if (!Objects.equals(icon, _icon) && parent != null) {
parent.invalidate();
parent.revalidate();
parent.repaint();
}
}
}
示例7: mouseMoved
import java.awt.Component; //导入方法依赖的package包/类
@Override
public void mouseMoved(MouseEvent e) {
if(graphics !=null ){
LinkedPanel panel = (LinkedPanel) e.getComponent();
Graphics2D g = (Graphics2D) panel.getGraphics();
g.setTransform(panel.getTransform());
float timeOffset = LayerUtilities.pixelsToUnits(g, e.getX(), true);
float time = cs.getMin(Axis.X) + timeOffset;
float frequencyOffset = LayerUtilities.pixelsToUnits(g, panel.getHeight() - e.getY(), false);
float frequency = cs.getMin(Axis.Y) + frequencyOffset;
float timeDiameter = LayerUtilities.pixelsToUnits(g, 10, true) * 2f;
float frequencyDiameter = LayerUtilities.pixelsToUnits(g, 10, false)* 2f;
selectedEventPoint = null;
for(NFFTEventPoint eventPoint : fileInfo.eventpoints){
float time1 = timeIndexToTime(eventPoint.t) - timeDiameter/2.0f ;
float frequencyInCents1 = (frequencyIndexToCents(eventPoint.f)) - frequencyDiameter/2.0f;
if( time >= time1 && time <= time1+timeDiameter &&
frequency >= frequencyInCents1 && frequency <= frequencyInCents1 + frequencyDiameter
){
selectedEventPoint = eventPoint;
}
}
if(selectedEventPoint!=null && selectedEventPoint!=prevSelectedEventPoint ){
prevSelectedEventPoint = selectedEventPoint;
System.out.println(String.format("Selected (t,f,fe,c): (%d,%d,%02fHz,%02f)",selectedEventPoint.t,selectedEventPoint.f,selectedEventPoint.frequencyEstimate,selectedEventPoint.contrast));
e.getComponent().getParent().invalidate();
for(Component c : e.getComponent().getParent().getComponents()){
if(c instanceof LinkedPanel){
c.repaint();
}
}
}
}
}
示例8: animateComponent
import java.awt.Component; //导入方法依赖的package包/类
private static void animateComponent(final Component comp) {
Thread t = new Thread(new Runnable() {
public void run() {
do {
try {
Thread.sleep(50);
} catch (InterruptedException ex) {}
comp.repaint();
} while (!done);
}
});
t.start();
}
示例9: main
import java.awt.Component; //导入方法依赖的package包/类
public static void main(final String[] args) throws AWTException {
final Frame frame = new Frame();
final Component label = new PaintNativeOnUpdate();
frame.setBackground(Color.RED);
frame.add(label);
frame.setSize(300, 300);
frame.setUndecorated(true);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
sleep();
label.repaint();// first paint
sleep();
label.repaint();// incremental paint
sleep();
Robot robot = new Robot();
robot.setAutoDelay(50);
Point point = label.getLocationOnScreen();
Color color = robot.getPixelColor(point.x + label.getWidth() / 2,
point.y + label.getHeight() / 2);
if (!color.equals(Color.GREEN)) {
System.err.println("Expected color = " + Color.GREEN);
System.err.println("Actual color = " + color);
throw new RuntimeException();
}
frame.dispose();
}
示例10: main
import java.awt.Component; //导入方法依赖的package包/类
public static void main(final String[] args) throws AWTException {
ExtendedRobot robot = new ExtendedRobot();
robot.setAutoDelay(50);
final Frame frame = new Frame();
final Component label = new PaintNativeOnUpdate();
frame.setBackground(Color.RED);
frame.add(label);
frame.setSize(300, 300);
frame.setUndecorated(true);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
robot.waitForIdle(1000);
label.repaint();// first paint
robot.waitForIdle(1000);
label.repaint();// incremental paint
robot.waitForIdle(1000);
Point point = label.getLocationOnScreen();
Color color = robot.getPixelColor(point.x + label.getWidth() / 2,
point.y + label.getHeight() / 2);
if (!color.equals(Color.GREEN)) {
System.err.println("Expected color = " + Color.GREEN);
System.err.println("Actual color = " + color);
throw new RuntimeException();
}
frame.dispose();
}
示例11: processRepaint
import java.awt.Component; //导入方法依赖的package包/类
/**
* Process pending repaint requests from children.
* <br>
* Children are guaranteed to be non-null once this method gets called.
*/
protected void processRepaint(ViewLayoutState.Parent lsParent) {
if (lsParent != null) { // parent view is ViewLayoutState.Parent
int firstRepaintChildIndex = children.getFirstRepaintChildIndex();
double majorAxisOffset = children.getMajorAxisOffset(firstRepaintChildIndex);
double repaintMajorOffset;
double repaintMajorSpan;
float repaintMinorOffset;
float repaintMinorSpan;
if (isRepaintTillEnd()
|| firstRepaintChildIndex >= getViewCount() // bit strange but possible after last child remove
) {
if (isMajorAxesOrthogonal()) {
repaintMajorOffset = 0;
repaintMajorSpan = 0; // till end of view's span in parent
repaintMinorOffset = (float)majorAxisOffset;
repaintMinorSpan = 0; // till parent view minor span end
} else { // major axes equal
repaintMajorOffset = majorAxisOffset;
repaintMajorSpan = 0; // till end of view's span in parent
repaintMinorOffset = 0;
repaintMinorSpan = 0; // till parent view minor span end
}
} else { // repainting just single child that did not change major axis span
double majorAxisSpan = getChild(firstRepaintChildIndex).getLayoutMajorAxisPreferredSpan();
if (isMajorAxesOrthogonal()) {
repaintMajorOffset = 0;
repaintMajorSpan = 0; // till end of view's span in parent
repaintMinorOffset = (float)majorAxisOffset;
repaintMinorSpan = (float)majorAxisSpan;
} else { // major axes equal
repaintMajorOffset = majorAxisOffset;
repaintMajorSpan = majorAxisSpan;
repaintMinorOffset = 0;
repaintMinorSpan = 0; // till parent view minor span end
}
}
lsParent.repaint(this, repaintMajorOffset, repaintMajorSpan,
repaintMinorOffset, repaintMinorSpan);
} else { // do not know allocation here => repaint whole component
Component c = getContainer();
if (c != null) {
c.repaint();
}
}
}
示例12: dragDropEnd
import java.awt.Component; //导入方法依赖的package包/类
public void dragDropEnd(DragSourceDropEvent e) {
if( isButtonDrag ) {
Component sourceComponent = e.getDragSourceContext().getComponent();
if( sourceComponent instanceof JButton ) {
((JButton)sourceComponent).getModel().setRollover( false );
}
sourceComponent.repaint();
resetDropGesture();
if( e.getDropSuccess() == false && !isInToolbarPanel( e.getLocation() ) ) {
//TODO catch ESC key
removeButton( e.getDragSourceContext().getTransferable() );
}
} else if( isToolbarDrag ) {
Point newLocationOnScreen = null;
boolean save = false;
if( null != currentRow ) {
//the cursor is above some toolbar row, we can proceed with the drop
newLocationOnScreen = currentRow.drop();
if( sourceRow != currentRow ) {
//clean up the row which we dragged from
sourceRow.dragSuccess();
config.removeEmptyRows();
}
save = true;
} else if( null != sourceRow ) {
//cursor is outside the toolbar area, abort the drop
newLocationOnScreen = sourceRow.dragAbort();
save = true;
}
if( null != dragWindow ) {
if( null != newLocationOnScreen ) {
animateDragWindow(newLocationOnScreen);
} else {
dragWindow.dispose();
}
dragWindow = null;
}
config.maybeRemoveLastRow();
if( save ) {
config.refresh();
config.save();
}
}
isButtonDrag = false;
isToolbarDrag = false;
}
示例13: focusGained
import java.awt.Component; //导入方法依赖的package包/类
@Override
public void focusGained(FocusEvent e) {
Component c = (Component) e.getSource();
c.repaint();
}
示例14: mouseMoved
import java.awt.Component; //导入方法依赖的package包/类
@Override
public void mouseMoved(MouseEvent e) {
if(graphics !=null ){
LinkedPanel panel = (LinkedPanel) e.getComponent();
Graphics2D g = (Graphics2D) panel.getGraphics();
g.setTransform(panel.getTransform());
float timeOffset = LayerUtilities.pixelsToUnits(g, e.getX(), true);
float time = cs.getMin(Axis.X) + timeOffset;
float frequencyOffset = LayerUtilities.pixelsToUnits(g, panel.getHeight() - e.getY(), false);
float frequency = cs.getMin(Axis.Y) + frequencyOffset;
float timeDiameter = LayerUtilities.pixelsToUnits(g, 10, true) * 2f;
float frequencyDiameter = LayerUtilities.pixelsToUnits(g, 10, false)* 2f;
selectedEventPoint = null;
for(NFFTEventPoint eventPoint : fileInfo.eventpoints){
float time1 = timeIndexToTime(eventPoint.t) - timeDiameter/2.0f ;
float frequencyInCents1 = (frequencyIndexToCents(eventPoint.f)) - frequencyDiameter/2.0f;
if( time >= time1 && time <= time1+timeDiameter &&
frequency >= frequencyInCents1 && frequency <= frequencyInCents1 + frequencyDiameter
){
selectedEventPoint = eventPoint;
}
}
if(selectedEventPoint!=null){
NFFTAudioFileInfo.clearSelectedFingerprints();
for(NFFTFingerprint print: fileInfo.fingerprints){
if((print.t1==selectedEventPoint.t && print.f1==selectedEventPoint.f) || (print.t2==selectedEventPoint.t && print.f2==selectedEventPoint.f)){
NFFTAudioFileInfo.addFingerprintToSelection(print);
}
}
e.getComponent().getParent().invalidate();
for(Component c : e.getComponent().getParent().getComponents()){
if(c instanceof LinkedPanel){
c.repaint();
}
}
}
}
}
示例15: repaint
import java.awt.Component; //导入方法依赖的package包/类
/**
* Calls component.repaint() on the Components passed as parameters of the
* method.
*
* @param components
*/
private void repaint(Component... components) {
for (Component c : components) {
c.repaint();
}
}