javax.swing.JPanel.getGraphics()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(5.9k)|赞(0)|评价(0)|浏览(138)

本文整理了Java中javax.swing.JPanel.getGraphics()方法的一些代码示例,展示了JPanel.getGraphics()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JPanel.getGraphics()方法的具体详情如下:
包路径:javax.swing.JPanel
类名称:JPanel
方法名:getGraphics

JPanel.getGraphics介绍

暂无

代码示例

代码示例来源:origin: fossasia/neurolab-desktop

this.trackPanelGraphics = this.trackPanel.getGraphics();

代码示例来源:origin: stackoverflow.com

JPanel jpanel = new JPanel();
Graphics g = jpanel.getGraphics();

代码示例来源:origin: stackoverflow.com

public void init(){
cgp = new CardGamePanel();
JPanel panel2 = new JPanel();
panel2.add(btnD);
btnD.addActionListener(new ActionListener(){

  public void actionPerformed(ActionEvent e){
    cgp.go(panel2.getGraphics());
  }
});
 add(cgp, BorderLayout.CENTER);
 add(panel2, BorderLayout.SOUTH);
 setSize(500,500);
}

代码示例来源:origin: locationtech/jts

private void paint()
{
 Graphics2D g = (Graphics2D) panel.getGraphics();
 if (g == null) return;
 GeometryPainter.paint(indicator, viewport, g, Color.RED, null);
}

代码示例来源:origin: edu.toronto.cs.medsavant/mfiume-component-transition

@Override
public void run() {
  Graphics g = canvas.getGraphics();
  painter.paintComponent(g);
  g.dispose();
}

代码示例来源:origin: stackoverflow.com

JFrame frame = new JFrame();
 JPanel panel = new JPanel();
 frame.add(panel);
 frame.setVisible(true);
 Graphics frameContext = frame.getGraphics();
 Graphics panelContext = panel.getGraphics();        
 if (frameContext.equals(panelContext)){
   System.out.println("The contexts are the same.");
 } else {
   System.out.println("The contexts are different.");
 }

代码示例来源:origin: edu.toronto.cs.medsavant/mfiume-component-transition

@Override
public void run() {
  Graphics g = canvas.getGraphics();
  painter.paintComponent(g);
  g.dispose();
}

代码示例来源:origin: edu.toronto.cs.medsavant/mfiume-component-transition

@Override
public void run() {
  Graphics g = canvas.getGraphics();
  painter.paintComponent(g);
  g.dispose();
}

代码示例来源:origin: stackoverflow.com

public static void drawMyStuff(JPanel panel, Color color, int startPoint, int endPoint) {
  // Declare and initialize a graphics object 
  // based on the supplied JPanel.
  Graphics g = panel.getGraphics();

  // Set the color we want to use...
  g.setColor(color);  // here we supply our color parameter

  // Draw a red line horizontally through the 
  // center of the supplied JPanel. Notice our 
  // new startPoint and endPoint parameters are
  // supplied here.
  g.drawLine(startPoint, panel.getHeight()/2, endPoint, panel.getHeight()/2);

  // Close the Graphics object, we don't need it anymore.
  g.dispose();

  // Update the supplied JPanel so as
  // to display what we've drawn.
  panel.revalidate(); 
}

代码示例来源:origin: us.ihmc/DarpaRoboticsChallenge

public void onNewMessage(sensor_msgs.CompressedImage message)
{
  if (cameraFrame.isVisible())
  {
    cameraImage = RosTools.bufferedImageFromRosMessageJpeg(colorModel, message);
    cameraPanel.getGraphics().drawImage(cameraImage.getScaledInstance(cameraImage.getWidth(), cameraImage.getHeight(), 0), 0, 0, null);
  }
}

代码示例来源:origin: stackoverflow.com

public static void drawMyStuff(JPanel panel) {
  // Declare and initialize a graphics object 
  // based on the supplied component.
  Graphics g = panel.getGraphics();

  // Set the color we want to use...
  g.setColor(Color.red);

  // Draw a red line horizontally through the 
  // center of the supplied component.
  g.drawLine(0, panel.getHeight()/2, panel.getWidth(), panel.getHeight()/2);

  // Close the Graphics object, we don't need it anymore.
  g.dispose();

  // Update the supplied component so as
  // to display what we've drawn.
  panel.revalidate(); 
}

代码示例来源:origin: josephw/titl

jp.getGraphics().drawImage(img, x, y, null);
Thread.sleep(100);

代码示例来源:origin: net.sf.jcgrid/jcgrid

public void endWorkingFor(WorkResult res) {
  lStatus.setText("done work for "+lastSessionName);
  Graphics graph=guiMandelWorkerPannel.this.pImage.getGraphics();
  
  if(graph!=null) {
    MandelWorkResult r=(MandelWorkResult)res;
    graph.setPaintMode();
    int w=guiMandelWorkerPannel.this.pImage.getWidth();
    int h=guiMandelWorkerPannel.this.pImage.getHeight();
    int fw=r.getIter().length;
    int fh=r.getIter()[0].length;
    for(int y=0;y<fh;y++) {
      for(int x=0;x<fw;x++) {
        graph.setColor(
          colorTable[((r.getIter())[x][y]) % colorTable.length]);
        graph.fillRect(w/2-fw/2+x,h/2-fh/2+(fh-y),1,1);
      }
    }
  }
}

代码示例来源:origin: EngineHub/CommandHelper

@Override
public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException {
  int windowID = Static.getInt32(args[0], t);
  int x = Static.getInt32(args[1], t);
  int y = Static.getInt32(args[2], t);
  int red = Static.getInt32(args[3], t);
  int green = Static.getInt32(args[4], t);
  int blue = Static.getInt32(args[5], t);
  Window w = windows.get(windowID);
  while(true) {
    try {
      JPanel panel = (JPanel) w.findComponentAt(x, y);
      panel.getGraphics().setColor(new Color(red, green, blue));
      panel.getGraphics().draw3DRect(x, y, 1, 1, true);
      return CVoid.VOID;
    } catch (ClassCastException ex) {
      //?
      return CVoid.VOID;
    }
  }
}

代码示例来源:origin: oskopek/javaanpr

@Override
  public void run() {
    try {
      parentFrame.car = new CarSnapshot(url);
      parentFrame.panelCarContent = parentFrame.car.duplicate().getImage();
      parentFrame.panelCarContent =
          Photo.linearResizeBi(parentFrame.panelCarContent, parentFrame.panelCar.getWidth(),
              parentFrame.panelCar.getHeight());
      parentFrame.panelCar.paint(parentFrame.panelCar.getGraphics());
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
}

代码示例来源:origin: uk.org.retep.templateEngine/templateEngine

int h = jPanel1.getHeight() - i.top - i.bottom;
final Graphics2D g = (Graphics2D) jPanel1.getGraphics();

代码示例来源:origin: org.rescarta.rc-cmgr/rc-cmgr

this.selectedCollectionJPanel.add(this.rcCollectionJPanel);
this.selectedCollectionJPanel.paintAll(selectedCollectionJPanel.getGraphics());
this.hideWaitCursor();

代码示例来源:origin: org.jgroups/com.springsource.org.jgroups

mainFrame.setVisible(true);
setTitle();
graphics=panel.getGraphics();
graphics.setColor(default_color);
mainFrame.setBackground(Color.white);

代码示例来源:origin: org.rescarta.rc-cmgr/rc-cmgr

this.rcObjMdJPanel.getMetadataContentJScrollPane().getVerticalScrollBar().setValue(yScrollPos);
this.selectedObjectMetadataJPanel.paintAll(selectedObjectMetadataJPanel.getGraphics());

代码示例来源:origin: org.rescarta.rc-cmgr/rc-cmgr

this.rcObjMdJPanel.getMetadataContentJScrollPane().getVerticalScrollBar().setValue(yScrollPos);
this.selectedObjectJPanel.paintAll(selectedObjectJPanel.getGraphics());

相关文章

微信公众号

最新文章

更多

JPanel类方法