Tabnine Logo
Component.repaint
Code IndexAdd Tabnine to your IDE (free)

How to use
repaint
method
in
java.awt.Component

Best Java code snippets using java.awt.Component.repaint (Showing top 20 results out of 945)

Refine searchRefine arrow

  • Window.setVisible
  • Container.add
  • JFrame.setDefaultCloseOperation
  • JFrame.<init>
  • Window.pack
  • Dimension.<init>
origin: stackoverflow.com

return new Dimension(canvas.getWidth(), canvas.getHeight());
repaint();
repaint();
repaint();
repaint();
int width = 640;
int height = 480;
JFrame frame = new JFrame("Direct draw demo");
frame.add(panel);
frame.pack();
frame.setVisible(true);
frame.setResizable(false);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
origin: stackoverflow.com

this.setLayout(new BorderLayout());
checkBox = new JCheckBox();
add(checkBox, BorderLayout.CENTER);
setOpaque(false);
  selfPointer.repaint();                          
origin: stackoverflow.com

JScrollPane screenScroll = new JScrollPane(screenLabel);
screenScroll.setPreferredSize(new Dimension(
    (int)(screen.getWidth()/3),
    (int)(screen.getHeight()/3)));
panel.add(screenScroll, BorderLayout.CENTER);
panel.add(selectionLabel, BorderLayout.SOUTH);
screenLabel.repaint();
    repaint(screen, screenCopy);
    selectionLabel.setText("Start Point: " + start);
    screenLabel.repaint();
    Point end = me.getPoint();
    captureRect = new Rectangle(start,
        new Dimension(end.x-start.x, end.y-start.y));
    repaint(screen, screenCopy);
    screenLabel.repaint();
    selectionLabel.setText("Rectangle: " + captureRect);
origin: stackoverflow.com

 import javax.swing.*;
import java.awt.*;

public class Infout extends JFrame{
  Infout(){
    setSize(300, 400);
    setTitle("An Empty Frame");
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setVisible(true);
  }

  public static void main(String[] args) {
     Infout m = new Infout();
     m.repaint(); 
  }

  @Override
  public void paint(Graphics g) 
  {
     g.drawRect(5, 5, 105, 105);
  }

}
origin: stackoverflow.com

 import javax.swing.*;
import java.awt.*;

public class Main {
  public static void main(String[] args) {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setVisible(true);
    frame.setSize(600, 400);

    JPanel panel = new JPanel() {
      @Override
      public void paintComponent(Graphics g) {
        super.paintComponent(g);
        g.setColor(Color.BLUE);
        g.fillRect(0, 0, 100, 100);
      }
    };
    frame.add(panel);

    // Graphics g = panel.getGraphics();
    // g.setColor(Color.BLUE);
    // g.fillRect(0, 0, 100, 100);

    frame.validate(); // because you added panel after setVisible was called
    frame.repaint(); // because you added panel after setVisible was called
  }
}
origin: stackoverflow.com

public void mouseClicked(MouseEvent e) {
  isLiving = !isLiving;
  repaint();
for (int jj = 0; jj < s; jj++) {
  GameOfLife cell = new GameOfLife(ii, jj);
  cell.setPreferredSize(new Dimension(10, 10));
  gui.add(cell);
  biosphere[ii][jj] = cell;
  gui.repaint();
origin: stackoverflow.com

gui.add(quality, BorderLayout.WEST);
dithering = new JCheckBox("Dithering", false);
controls.add(antialiasing);
controls.add(fractionalMetrics);
gui.repaint();
updateText();
origin: stackoverflow.com

JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
frame.setSize(600, 400);
frame.add(panel);
frame.repaint(); // because you added panel after setVisible was called
origin: stackoverflow.com

 import java.awt.Dimension;
import java.awt.event.ActionEvent;
import javax.swing.AbstractAction;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JOptionPane;
import javax.swing.JPanel;

public class Main {
  public static void main(String[] args) {
   final JComboBox<String> myCombo = new JComboBox<String>(new String[]{"Foo", "Bar"});
   final JPanel mainPanel = new JPanel();
   mainPanel.setPreferredSize(new Dimension(250, 100));
   mainPanel.add(new JButton(new AbstractAction("Toggle Combo") {

     @Override
     public void actionPerformed(ActionEvent arg0) {
      myCombo.setVisible(!myCombo.isVisible());
      mainPanel.revalidate();
      mainPanel.repaint();
     }
   }));
   mainPanel.add(myCombo);

   JOptionPane.showMessageDialog(null, mainPanel);
  }

}
origin: stackoverflow.com

return new Dimension(PREF_W, PREF_H);
  currentPointList = new ArrayList<Point>();
  currentPointList.add(mEvt.getPoint());
  repaint();
public void mouseDragged(MouseEvent mEvt) {
  currentPointList.add(mEvt.getPoint());
  repaint();
  pointsList.add(currentPointList);
  currentPointList = null;
  repaint();
JFrame frame = new JFrame("DrawStuff");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add(new DrawStuff());
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
origin: stackoverflow.com

repaint();
repaint();
JFrame testFrame = new JFrame();
testFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
final LinesComponent comp = new LinesComponent();
comp.setPreferredSize(new Dimension(320, 200));
testFrame.getContentPane().add(comp, BorderLayout.CENTER);
JPanel buttonsPanel = new JPanel();
JButton newLineButton = new JButton("New Line");
JButton clearButton = new JButton("Clear");
buttonsPanel.add(newLineButton);
buttonsPanel.add(clearButton);
testFrame.getContentPane().add(buttonsPanel, BorderLayout.SOUTH);
newLineButton.addActionListener(new ActionListener() {
testFrame.pack();
testFrame.setVisible(true);
origin: stackoverflow.com

  JFrame frame = new JFrame("Testing");
  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  frame.setLayout(new BorderLayout());
  frame.add(new TestPane());
  frame.pack();
  frame.setLocationRelativeTo(null);
  frame.setVisible(true);
    repaint();
return new Dimension(200, 200);
origin: stackoverflow.com

      JFrame frame = new JFrame();
      frame.setLayout(new GridLayout(N, N, N, N));
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      for (int i = 0; i < N * N; i++) {
        frame.add(new RotatePanel());
      frame.pack();
      frame.setVisible(true);
  this.setPreferredSize(new Dimension(
    image.getWidth(null), image.getHeight(null)));
  this.addMouseListener(new MouseAdapter() {
public void actionPerformed(ActionEvent e) {
  theta += dt;
  repaint();
  return new Dimension(SIZE, SIZE);
origin: stackoverflow.com

this.scores = scores;
invalidate();
this.repaint();
mainPanel.setPreferredSize(new Dimension(800, 600));
JFrame frame = new JFrame("DrawGraph");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add(mainPanel);
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
origin: stackoverflow.com

repaint();
  JFrame window = new JFrame();
  window.setSize(840, 560);
  window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  window.add(grid);
  window.setVisible(true);
  grid.fillCell(0, 0);
  grid.fillCell(79, 0);
origin: stackoverflow.com

JFrame f = new JFrame("AnimationTest");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.add(this);
f.pack();
f.setLocationRelativeTo(null);
f.setVisible(true);
timer.start();
super(true);
this.setOpaque(false);
this.setPreferredSize(new Dimension(WIDE, HIGH));
this.addMouseListener(new MouseHandler());
this.addComponentListener(new ComponentHandler());
this.repaint();
  Dimension d = field.getPreferredSize();
  field.setBounds(e.getX(), e.getY(), d.width, d.height);
  add(field);
origin: stackoverflow.com

  for (int col = 0; col < GRID_COLS; col++) {
    panelGrid[row][col] = new JPanel(new GridBagLayout());
    backingPanel.add(panelGrid[row][col]);
redLabel.setBackground(Color.red.brighter().brighter());
redLabel.setPreferredSize(LABEL_SIZE);
panelGrid[4][3].add(redLabel);
panelGrid[1][1].add(blueLabel);
    clickedPanel.remove(dragLabel);
    clickedPanel.revalidate();
    clickedPanel.repaint();
    dragLabel.setLocation(x, y);
    add(dragLabel, JLayeredPane.DRAG_LAYER);
    repaint();
  int y = me.getPoint().y - dragLabelHeightDiv2;
  dragLabel.setLocation(x, y);
  repaint();
  repaint();
  dragLabel = null;
origin: stackoverflow.com

this.setPreferredSize(new Dimension(640, 480));
this.addMouseListener(mouseHandler);
this.addMouseMotionListener(mouseHandler);
  p1 = e.getPoint();
  p2 = p1;
  repaint();
  drawing = false;
  p2 = e.getPoint();
  repaint();
  if (drawing) {
    p2 = e.getPoint();
    repaint();
  this.add(new MoveButton("\u2190", KeyEvent.VK_LEFT, -DELTA, 0));
  this.add(new MoveButton("\u2191", KeyEvent.VK_UP, 0, -DELTA));
  this.add(new MoveButton("\u2192", KeyEvent.VK_RIGHT, DELTA, 0));
  this.add(new MoveButton("\u2193", KeyEvent.VK_DOWN, 0, DELTA));
        LinePanel.this.p1.translate(dx, dy);
        LinePanel.this.p2.translate(dx, dy);
        LinePanel.this.repaint();
origin: stackoverflow.com

JFrame f = new JFrame();
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.add(new MainPanel());
f.pack();
f.setLocationRelativeTo(null);
f.setVisible(true);
Control control = new Control(model, view);
JLabel label = new JLabel("Guess what color!", JLabel.CENTER);
this.add(label, BorderLayout.NORTH);
this.add(view, BorderLayout.CENTER);
this.add(control, BorderLayout.SOUTH);
  PieceButton pb = (PieceButton) e.getSource();
  icon.color = pb.piece.color;
  label.repaint();
  model.check(pb.piece);
origin: stackoverflow.com

    repaint();
   repaint();
JFrame test = new JFrame("Tab test");
test.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
test.setSize(400, 400);
tabs.addTab("Four", new JButton("Four"));
test.add(tabs);
test.setVisible(true);
java.awtComponentrepaint

Javadoc

Repaints this component.

If this component is a lightweight component, this method causes a call to this component's paint method as soon as possible. Otherwise, this method causes a call to this component's update method as soon as possible.

Note: For more information on the paint mechanisms utilitized by AWT and Swing, including information on how to write the most efficient painting code, see Painting in AWT and Swing.

Popular methods of Component

  • getParent
    Gets the parent of this component.
  • getPreferredSize
    Gets the preferred size of this component.
  • getHeight
    Returns the current height of this component. This method is preferable to writingcomponent.getBound
  • getWidth
    Returns the current width of this component. This method is preferable to writingcomponent.getBounds
  • isVisible
    Determines whether this component should be visible when its parent is visible. Components are initi
  • setBounds
    Moves and resizes this component to conform to the new bounding rectangle r. This component's new po
  • getName
    Gets the name of the component.
  • getSize
    Stores the width/height of this component into "return value" rv and return rv. If rv is null a newD
  • setEnabled
    Enables or disables this component, depending on the value of the parameter b. An enabled component
  • setBackground
    Sets the background color of this component. The background color affects each component differently
  • setVisible
    Shows or hides this component depending on the value of parameterb.
  • getMinimumSize
    Gets the mininimum size of this component.
  • setVisible,
  • getMinimumSize,
  • getBackground,
  • addMouseListener,
  • getBounds,
  • setForeground,
  • setCursor,
  • setSize,
  • requestFocus

Popular in Java

  • Running tasks concurrently on multiple threads
  • getResourceAsStream (ClassLoader)
  • findViewById (Activity)
  • compareTo (BigDecimal)
  • Graphics2D (java.awt)
    This Graphics2D class extends the Graphics class to provide more sophisticated control overgraphics
  • ByteBuffer (java.nio)
    A buffer for bytes. A byte buffer can be created in either one of the following ways: * #allocate
  • StringTokenizer (java.util)
    Breaks a string into tokens; new code should probably use String#split.> // Legacy code: StringTo
  • TreeMap (java.util)
    Walk the nodes of the tree left-to-right or right-to-left. Note that in descending iterations, next
  • TimeUnit (java.util.concurrent)
    A TimeUnit represents time durations at a given unit of granularity and provides utility methods to
  • FileUtils (org.apache.commons.io)
    General file manipulation utilities. Facilities are provided in the following areas: * writing to a
  • Best IntelliJ plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now