javax.swing.JComponent.contains()方法的使用及代码示例

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

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

JComponent.contains介绍

暂无

代码示例

代码示例来源:origin: leMaik/swing-material

@Override
public boolean contains(int x, int y) {
  return animationRunning && super.contains(x, y);
}

代码示例来源:origin: xyz.cofe/docking-frames-core

@Override
public void mouseDragged( MouseEvent e ) {
  boolean inside = owner.contains( e.getX(), e.getY() );
  if( inside != mouseInside )
    setMouseInside( inside );
}
@Override

代码示例来源:origin: mikaelhg/openblocks

public boolean contains(int x, int y) {
  return this.navigator.getJComponent().contains(x, y);
}

代码示例来源:origin: uk.org.ponder.rsf/rsf-core-ponderutilcore

public void mouseReleased(MouseEvent me) {
  if (tolisten.contains(me.getPoint())) {
   tolisten.setBorder(noborder);
   eventfirer.fireEvent(new ButtonPressedEvent(tolisten));
  }
 }
};

代码示例来源:origin: xyz.cofe/docking-frames-core

@Override
  public void mouseReleased( MouseEvent e ) {
    if( mousePressed && e.getButton() == MouseEvent.BUTTON1 ){
      boolean inside = owner.contains( e.getX(), e.getY() );
      if( inside && isEnabled() ){
        trigger();
      }
      
      setMousePressed( false );
      if( mouseInside != inside )
        setMouseInside( inside );
    }
  }
}

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/napkinlaf

public void mouseClicked(MouseEvent ev) {
  Component w = (Window) ev.getSource();
  if (w instanceof Frame) {
    Frame f = (Frame) w;
    JComponent titlePane = getTitlePane();
    Point convertedPoint = SwingUtilities.convertPoint(w,
        ev.getPoint(), titlePane);
    int state = f.getExtendedState();
    if (titlePane != null && titlePane.contains(convertedPoint) &&
        ev.getClickCount() % 2 == 0 &&
        (ev.getModifiers() & BUTTON1_MASK) != 0 &&
        f.isResizable()) {
      f.setExtendedState((state & MAXIMIZED_BOTH) != 0 ?
          state & ~MAXIMIZED_BOTH :
          state | MAXIMIZED_BOTH);
    }
  }
}

代码示例来源:origin: com.jtattoo/JTattoo

public void mouseClicked(MouseEvent ev) {
  if (ev.getSource() instanceof Window) {
    Window window = (Window) ev.getSource();
    if (!(window instanceof Frame)) {
      return;
    }
    Frame frame = (Frame) window;
    Point convertedPoint = SwingUtilities.convertPoint(window, ev.getPoint(), internalGetTitlePane());
    int state = DecorationHelper.getExtendedState(frame);
    if (titlePane != null && titlePane instanceof TitlePane && titlePane.contains(convertedPoint) && frame.isResizable()) {
      if ((ev.getClickCount() % 2) == 0 && ((ev.getModifiers() & InputEvent.BUTTON1_MASK) != 0)) {
        if ((state & BaseRootPaneUI.MAXIMIZED_BOTH) != 0) {
          ((TitlePane) titlePane).restore();
        } else {
          ((TitlePane) titlePane).maximize();
        }
      }
    }
  }
}

代码示例来源:origin: ArlindNocaj/power-voronoi-diagram

@Override
  public boolean contains(int x, int y) {
//    return false;
    if (super.contains(x, y)){
      if (polygon==null) return true;
      return polygon.contains(x+this.getLocation().x,y+ getLocation().y);
    }else return false;
  }

代码示例来源:origin: ArlindNocaj/power-voronoi-diagram

@Override
  public boolean contains(Point p) {
//        return false;
    if (super.contains(p)){
      if (polygon==null) return true;
      return polygon.contains(p.x+getLocation().x,p.y+getLocation().y);
    }else return false;
  }

代码示例来源:origin: xyz.cofe/docking-frames-core

@Override
public boolean contains( int x, int y ) {
  if( !super.contains( x, y ))
    return false;
  
  double w = getWidth();
  double h = getHeight();
  
  double dx, dy;
  
  if( w > h ){
    double delta = h / w;
    dx = x;
    dy = delta * y;
    h = w;
  }
  else{
    double delta = w / h;
    dx = delta * x;
    dy = y;
    w = h;
  }
  
  dx -= w/2;
  dy -= h/2;
  
  double dist = dx*dx + dy*dy;
  return dist <= w*w/4;
}

代码示例来源:origin: cmu-phil/tetrad

public boolean contains(int x, int y) {
  if (getDisplayComp() != null) {
    return getDisplayComp().contains(x, y);
  }
  return super.contains(x, y);
}

代码示例来源:origin: freeplane/freeplane

@Override
public boolean contains(final int x, final int y) {
  if (super.contains(x, y))
    return true;
  for(int i = 0; i < getComponentCount(); i++){
  final Component comp = getComponent(i);
  if(comp.isVisible() && comp.contains(x-comp.getX(), y-comp.getY()))
    return true;
  }
  return false;
}

代码示例来源:origin: khuxtable/seaglass

/**
 * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
 */
public void mouseClicked(MouseEvent ev) {
  Window w = (Window) ev.getSource();
  Frame  f = null;
  if (w instanceof Frame) {
    f = (Frame) w;
  } else {
    return;
  }
  if (getTitlePane() != null) {
    Point convertedPoint = SwingUtilities.convertPoint(w, ev.getPoint(), getTitlePane());
    int state = f.getExtendedState();
    if (getTitlePane().contains(convertedPoint)) {
      if ((ev.getClickCount() % 2) == 0 && ((ev.getModifiers() & InputEvent.BUTTON1_MASK) != 0)) {
        if (f.isResizable()) {
          if ((state & Frame.MAXIMIZED_BOTH) != 0) {
            f.setExtendedState(state & ~Frame.MAXIMIZED_BOTH);
          } else {
            f.setExtendedState(state | Frame.MAXIMIZED_BOTH);
          }
          return;
        }
      }
    }
  }
}

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/skinlf

public void mouseClicked(MouseEvent ev) {
 java.awt.Window w = translateSource(ev);
 Frame f;
 if (w instanceof Frame) {
  f = (Frame)w;
 } else {
  return;
 }
 Point convertedPoint =
  SwingUtilities.convertPoint(w, ev.getPoint(), getTitlePane());
 int state = getExtendedState(f);
 if (getTitlePane() != null && getTitlePane().contains(convertedPoint)) {
  if ((ev.getClickCount() % 2) == 0
   && ((ev.getModifiers() & InputEvent.BUTTON1_MASK) != 0)) {
   if (f.isResizable()) {
    if ((state & Frame_MAXIMIZED_BOTH) != 0) {
     setExtendedState(f, state & ~Frame_MAXIMIZED_BOTH);
    } else {
     setExtendedState(f, state | Frame_MAXIMIZED_BOTH);
    }
    return;
   }
  }
 }
}

代码示例来源:origin: com.github.insubstantial/substance

&& windowTitlePane.contains(convertedPoint)) {
if (((ev.getClickCount() % 2) == 0)
    && ((ev.getModifiers() & InputEvent.BUTTON1_MASK) != 0)) {

代码示例来源:origin: org.java.net.substance/substance

@Override
public void mousePressed(MouseEvent ev) {
  JRootPane rootPane = SubstanceRootPaneUI.this.getRootPane();
  if (rootPane.getWindowDecorationStyle() == JRootPane.NONE) {
    return;
  }
  Point dragWindowOffset = ev.getPoint();
  Component source = (Component) ev.getSource();
  Point convertedDragWindowOffset = SwingUtilities.convertPoint(
      source, dragWindowOffset, getTitlePane());
  dragWindowOffset = SwingUtilities.convertPoint(source,
      dragWindowOffset, SubstanceRootPaneUI.this.window);
  if (getTitlePane() != null
      && getTitlePane().contains(convertedDragWindowOffset)) {
    if (SubstanceRootPaneUI.this.window != null) {
      SubstanceRootPaneUI.this.window.toFront();
      dragOffset = dragWindowOffset;
    }
  }
}

代码示例来源:origin: com.github.insubstantial/substance

@Override
public void mousePressed(MouseEvent ev) {
  JRootPane rootPane = SubstanceRootPaneUI.this.getRootPane();
  if (rootPane.getWindowDecorationStyle() == JRootPane.NONE) {
    return;
  }
  Point dragWindowOffset = ev.getPoint();
  Component source = (Component) ev.getSource();
  Point convertedDragWindowOffset = SwingUtilities.convertPoint(
      source, dragWindowOffset, getTitlePane());
  dragWindowOffset = SwingUtilities.convertPoint(source,
      dragWindowOffset, SubstanceRootPaneUI.this.window);
  if (getTitlePane() != null
      && getTitlePane().contains(convertedDragWindowOffset)) {
    if (SubstanceRootPaneUI.this.window != null) {
      SubstanceRootPaneUI.this.window.toFront();
      dragOffset = dragWindowOffset;
    }
  }
}

代码示例来源:origin: com.github.insubstantial/substance

@Override
  public void mouseClicked(MouseEvent ev) {
    Frame f;
    if (SubstanceRootPaneUI.this.window instanceof Frame) {
      f = (Frame) SubstanceRootPaneUI.this.window;
    } else {
      return;
    }
    Point convertedPoint = SwingUtilities.convertPoint(
        SubstanceRootPaneUI.this.window, ev.getPoint(),
        SubstanceRootPaneUI.this.getTitlePane());
    int state = f.getExtendedState();
    if ((SubstanceRootPaneUI.this.getTitlePane() != null)
        && SubstanceRootPaneUI.this.getTitlePane().contains(
            convertedPoint)) {
      if (((ev.getClickCount() % 2) == 0)
          && ((ev.getModifiers() & InputEvent.BUTTON1_MASK) != 0)) {
        if (f.isResizable()) {
          if ((state & Frame.MAXIMIZED_BOTH) != 0) {
            setMaximized();
            f.setExtendedState(state & ~Frame.MAXIMIZED_BOTH);
          } else {
            setMaximized();
            f.setExtendedState(state | Frame.MAXIMIZED_BOTH);
          }
        }
      }
    }
  }
}

代码示例来源:origin: org.java.net.substance/substance

&& SubstanceRootPaneUI.this.getTitlePane().contains(
      convertedPoint)) {
if (((ev.getClickCount() % 2) == 0)

代码示例来源:origin: xyz.cofe/docking-frames-core

@Override
public boolean contains( int x, int y ){
  if( !super.contains( x, y ))
    return false;
  
  int w = getWidth();
  int h = getHeight();
  RoundRectangle2D rect;
  
  if( model.getOrientation().isHorizontal() )
    rect = new RoundRectangle2D.Double( 0, 0, w, h, h, h );
  else
    rect = new RoundRectangle2D.Double( 0, 0, w, h, w, w );
  
  return rect.contains( x, y );
}

相关文章

JComponent类方法