java.awt.event.MouseAdapter#java.awt.Dimension源码实例Demo

下面列出了java.awt.event.MouseAdapter#java.awt.Dimension 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: hortonmachine   文件: ImageViewer.java
/**
 * Opens a JDialog with the image viewer in it.
 * 
 * @param image the image to show.
 * @param title the title of the dialog.
 * @param modal if <code>true</code>, the dialog is modal.
 */
public static void show( BufferedImage image, String title, boolean modal ) {
    JDialog f = new JDialog();
    f.add(new ImageViewer(image), BorderLayout.CENTER);
    f.setTitle(title);
    f.setIconImage(ImageCache.getInstance().getBufferedImage(ImageCache.HORTONMACHINE_FRAME_ICON));
    f.setModal(modal);
    f.pack();
    int h = image.getHeight();
    int w = image.getWidth();
    if (h > w) {
        f.setSize(new Dimension(600, 800));
    } else {
        f.setSize(new Dimension(800, 600));
    }
    f.setLocationRelativeTo(null); // Center on screen
    f.setVisible(true);
    f.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    f.getRootPane().registerKeyboardAction(e -> {
        f.dispose();
    }, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_IN_FOCUSED_WINDOW);
}
 
源代码2 项目: FCMFrame   文件: FrameTool.java
/**
   * 屏幕居中方法
   */
  public static void setCenter(JFrame jframe) {
      Toolkit kit = Toolkit.getDefaultToolkit();
      Dimension screenSize = kit.getScreenSize();
      int screenHeight = screenSize.height;
      int screenWidth = screenSize.width;
      jframe.setSize(screenWidth*2/3, screenHeight*2/3);
      int frameH = jframe.getHeight();
      int frameW = jframe.getWidth();
      jframe.setLocation((screenWidth - frameW) / 2, (screenHeight - frameH) / 2);
try {
	String src = "images/logo.gif";
	File f = new File(src);
	Image image = ImageIO.read(f);
	jframe.setIconImage(image);
} catch (IOException e) {
	e.printStackTrace();
}
  }
 
源代码3 项目: littleluck   文件: LuckMenuUI.java
/**
 * <p>
 * 重写方法,设置菜单的最小高度为20, 否则会出现菜单项大小不一致的情况。
 * </p>
 *
 * <p>
 * Rewrite method, set the minimum height of the menu is 20, otherwise the
 * menu item size will be inconsistent situation.
 * </p>
 */
protected Dimension getPreferredMenuItemSize(JComponent c,
                                             Icon checkIcon,
                                             Icon arrowIcon,
                                             int defaultTextIconGap)
{
    Dimension dimension = super.getPreferredMenuItemSize(c, checkIcon,
            arrowIcon, defaultTextIconGap);

    if (dimension != null && dimension.height < 20)
    {
        dimension.setSize(dimension.width, 20);
    }

    return dimension;
}
 
源代码4 项目: jdk8u_jdk   文件: Test7163696.java
public void run() {
    if (this.bar == null) {
        this.bar = new JScrollBar(JScrollBar.HORIZONTAL, 50, 10, 0, 100);
        this.bar.setPreferredSize(new Dimension(400, 20));

        JFrame frame = new JFrame();
        frame.add(this.bar);
        frame.pack();
        frame.setVisible(true);
    }
    else if (40 != this.bar.getValue()) {
        System.out.println("name = " + UIManager.getLookAndFeel().getName());
        System.out.println("value = " + this.bar.getValue());
    }
    else {
        SwingUtilities.getWindowAncestor(this.bar).dispose();
        this.bar = null;
    }
}
 
源代码5 项目: Pixelitor   文件: PushTransition2D.java
@Override
public Transition2DInstruction[] getInstructions(float progress, Dimension size) {
    AffineTransform transform1 = new AffineTransform();
    AffineTransform transform2 = new AffineTransform();

    if (type == LEFT) {
        transform2.translate(size.width * (1 - progress), 0);
        transform1.translate(size.width * (1 - progress) - size.width, 0);
    } else if (type == RIGHT) {
        transform2.translate(size.width * (progress - 1), 0);
        transform1.translate(size.width * (progress - 1) + size.width, 0);
    } else if (type == UP) {
        transform2.translate(0, size.height * (1 - progress));
        transform1.translate(0, size.height * (1 - progress) - size.height);
    } else {
        transform2.translate(0, size.height * (progress - 1));
        transform1.translate(0, size.height * (progress - 1) + size.height);
    }

    return new Transition2DInstruction[]{
            new ImageInstruction(true, transform1, null),
            new ImageInstruction(false, transform2, null)
    };
}
 
源代码6 项目: javamelody   文件: Utilities.java
/**
 * Fixe la taille exacte d'une JTable à celle nécessaire pour afficher les données.
 * @param table JTable
 */
public static void adjustTableHeight(final JTable table) {
	table.setPreferredScrollableViewportSize(
			new Dimension(-1, table.getPreferredSize().height));
	// on utilise invokeLater pour configurer le scrollPane car lors de l'exécution ce cette méthode
	// la table n'est pas encore dans son scrollPane parent
	SwingUtilities.invokeLater(new Runnable() {
		@Override
		public void run() {
			final JScrollPane scrollPane = MSwingUtilities.getAncestorOfClass(JScrollPane.class,
					table);
			scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
			// Puisqu'il n'y a pas d'ascenceur sur ce scrollPane,
			// il est inutile que la mollette de souris serve à bouger cet ascenseur,
			// mais il est très utile en revanche que ce scrollPane ne bloque pas l'utilisation
			// de la mollette de souris pour le scrollPane global de l'onglet principal.
			// On commence par enlever le listener au cas où la méthode soit appelée deux fois sur la même table.
			scrollPane.removeMouseWheelListener(DELEGATE_TO_PARENT_MOUSE_WHEEL_LISTENER);
			scrollPane.addMouseWheelListener(DELEGATE_TO_PARENT_MOUSE_WHEEL_LISTENER);
		}
	});
}
 
源代码7 项目: netbeans   文件: ErrorPanel.java
private void btnStackActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnStackActionPerformed
    StringWriter sw = new StringWriter();
    exception.printStackTrace(new PrintWriter(sw));
    JPanel pnl = new JPanel();
    pnl.setLayout(new BorderLayout());
    pnl.setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6));
    JTextArea ta = new JTextArea();
    ta.setText(sw.toString());
    ta.setEditable(false);
    JScrollPane pane = new JScrollPane(ta);
    pnl.add(pane);
    pnl.setMaximumSize(new Dimension(600, 300));
    pnl.setPreferredSize(new Dimension(600, 300));
    NotifyDescriptor.Message nd = new NotifyDescriptor.Message(pnl);
    DialogDisplayer.getDefault().notify(nd);

}
 
源代码8 项目: 3Dscript   文件: EditorPane.java
/**
	 * @return this EditorPane wrapped in a {@link RTextScrollPane}.
	 */
	public RTextScrollPane wrappedInScrollbars() {
		final RTextScrollPane sp = new RTextScrollPane(this);
		sp.setPreferredSize(new Dimension(600, 350));
		sp.setIconRowHeaderEnabled(true);

		gutter = sp.getGutter();
//		iconGroup = new IconGroup("bullets", "images/", null, "png", null);
//		gutter.setBookmarkIcon(iconGroup.getIcon("var"));

//		URL url = ClassLoader.getSystemClassLoader().getResource("eye.png");
//		ImageIcon icon = new ImageIcon(url);
//		gutter.setBookmarkIcon(icon);
//		gutter.setBookmarkingEnabled(true);

		return sp;
	}
 
源代码9 项目: openjdk-8   文件: WPrinterJob.java
private void init(Component parent, String  title, String message,
                  String buttonText) {
    Panel p = new Panel();
    add("Center", new Label(message));
    Button btn = new Button(buttonText);
    btn.addActionListener(this);
    p.add(btn);
    add("South", p);
    pack();

    Dimension dDim = getSize();
    if (parent != null) {
        Rectangle fRect = parent.getBounds();
        setLocation(fRect.x + ((fRect.width - dDim.width) / 2),
                    fRect.y + ((fRect.height - dDim.height) / 2));
    }
}
 
源代码10 项目: uima-uimaj   文件: LogFileViewer.java
/**
 * Inits the.
 *
 * @param file the file
 * @param d the d
 */
public void init(File file, Dimension d) {
	createMenus();
	this.logFile = file;
	this.textArea = new JTextArea();
	// Copy
	Action copyAction = this.textArea.getActionMap().get(DefaultEditorKit.copyAction);
	copyAction.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_C,
			InputEvent.CTRL_MASK));
	copyAction.setEnabled(true);
	this.scrollPane = new JScrollPane(this.textArea);
	this.setContentPane(this.scrollPane);
	this.scrollPane.setPreferredSize(d);
	boolean doneLoadingFile = loadFile();
	if (!doneLoadingFile) {
		this.dispose();
		return;
	}
	this.pack();
	this.setVisible(true);
}
 
源代码11 项目: Course_Generator   文件: JMapViewer.java
public JMapViewer(TileCache tileCache, int downloadThreadCount) {
	super();
	JobDispatcher.setMaxWorkers(downloadThreadCount);
	tileSource = new OsmTileSource.Mapnik();
	tileController = new TileController(tileSource, tileCache, this);
	mapMarkerList = new LinkedList<>();
	mapPolygonList = new LinkedList<>();
	mapRectangleList = new LinkedList<>();
	mapMarkersVisible = true;
	mapRectanglesVisible = true;
	mapPolygonsVisible = true;
	tileGridVisible = false;
	setLayout(null);
	initializeZoomSlider();
	setMinimumSize(new Dimension(tileSource.getTileSize(), tileSource.getTileSize()));
	setPreferredSize(new Dimension(400, 400));
	setDisplayPosition(new Coordinate(50, 9), 3);
	// setToolTipText("");
}
 
源代码12 项目: littleluck   文件: FrameDemo.java
private static JComponent createFrameSpaceholder(JFrame frame) {
    JPanel framePlaceholder = new JPanel();
    Dimension prefSize = frame.getPreferredSize();
    prefSize.width += 12;
    prefSize.height += 12;
    framePlaceholder.setPreferredSize(prefSize);

    return framePlaceholder;
}
 
源代码13 项目: Pixie   文件: GUILabelingTool.java
/**
 * Pack the window and set a new min size in order to avoid the resize to a
 * value where the components do no longer fit.
 */
private void packGUI() {
    // avoid a min size greater than the new arrangement of panel size
    this.setMinimumSize(new Dimension(0, 0));

    this.pack();

    // make the screen the minimum size when the components still fit
    this.setMinimumSize(this.getSize());
}
 
源代码14 项目: netbeans   文件: StringTableCellEditor.java
public StringTableCellEditor(final JTextField textField) {
    super(textField);
    customEditorButton.addActionListener(this);

    // ui-tweaking
    customEditorButton.setFocusable(false);
    customEditorButton.setFocusPainted(false);
    customEditorButton.setMargin(new Insets(0, 0, 0, 0));
    customEditorButton.setPreferredSize(new Dimension(20, 10));
}
 
源代码15 项目: openjdk-jdk8u-backup   文件: MultiSeparatorUI.java
/**
 * Invokes the <code>getMaximumSize</code> method on each UI handled by this object.
 *
 * @return the value obtained from the first UI, which is
 * the UI obtained from the default <code>LookAndFeel</code>
 */
public Dimension getMaximumSize(JComponent a) {
    Dimension returnValue =
        ((ComponentUI) (uis.elementAt(0))).getMaximumSize(a);
    for (int i = 1; i < uis.size(); i++) {
        ((ComponentUI) (uis.elementAt(i))).getMaximumSize(a);
    }
    return returnValue;
}
 
源代码16 项目: jdk8u-jdk   文件: MultiPopupMenuUI.java
/**
 * Invokes the <code>getMaximumSize</code> method on each UI handled by this object.
 *
 * @return the value obtained from the first UI, which is
 * the UI obtained from the default <code>LookAndFeel</code>
 */
public Dimension getMaximumSize(JComponent a) {
    Dimension returnValue =
        ((ComponentUI) (uis.elementAt(0))).getMaximumSize(a);
    for (int i = 1; i < uis.size(); i++) {
        ((ComponentUI) (uis.elementAt(i))).getMaximumSize(a);
    }
    return returnValue;
}
 
源代码17 项目: JDKSourceCode1.8   文件: MultiScrollPaneUI.java
/**
 * Invokes the <code>getPreferredSize</code> method on each UI handled by this object.
 *
 * @return the value obtained from the first UI, which is
 * the UI obtained from the default <code>LookAndFeel</code>
 */
public Dimension getPreferredSize(JComponent a) {
    Dimension returnValue =
        ((ComponentUI) (uis.elementAt(0))).getPreferredSize(a);
    for (int i = 1; i < uis.size(); i++) {
        ((ComponentUI) (uis.elementAt(i))).getPreferredSize(a);
    }
    return returnValue;
}
 
源代码18 项目: RipplePower   文件: ButtonUI.java
protected void paintButtonPressed(Graphics g, AbstractButton b) {
	if (b.isContentAreaFilled()) {
		if (b instanceof RPButton) {
			RPButton link = (RPButton) b;
			if (link.getBtnGroup() != null && link.isLeftNode()) {
				float width = link.getWidth();
				float height = link.getHeight();
				int arc = link.getBtnGroup().getArc();

				Graphics2D g2 = (Graphics2D) g.create();
				g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
				g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE);

				RoundRectangle2D rect = new RoundRectangle2D.Float(0, 0, width, height, link.getBtnGroup().getArc(),
						arc);
				g2.setColor(getSelectColor());
				g2.fill(rect);

				Rectangle2D rectFix = new Rectangle((int) width - arc, 0, (int) arc, (int) height);
				g2.fill(rectFix);

				g2.dispose();
			} else {
				Dimension size = b.getSize();
				g.setColor(getSelectColor());
				g.fillRect(0, 0, size.width, size.height);
			}
		}
	}
}
 
源代码19 项目: JDKSourceCode1.8   文件: BasicToolBarSeparatorUI.java
public Dimension getPreferredSize( JComponent c )
{
    Dimension size = ( (JToolBar.Separator)c ).getSeparatorSize();

    if ( size != null )
    {
        return size.getSize();
    }
    else
    {
        return null;
    }
}
 
源代码20 项目: netbeans   文件: PropertiesPanel.java
private void makeDialogWider(int delta) {
    Window w = SwingUtilities.getWindowAncestor(this);
    if (w != null) {
        Dimension size = w.getSize();
        size.width += delta;
        w.setSize(size);
    }
}
 
源代码21 项目: jdk8u_jdk   文件: JScrollBar.java
/**
 * The scrollbar is flexible along it's scrolling axis and
 * rigid along the other axis.
 */
public Dimension getMinimumSize() {
    Dimension pref = getPreferredSize();
    if (orientation == VERTICAL) {
        return new Dimension(pref.width, 5);
    } else {
        return new Dimension(5, pref.height);
    }
}
 
源代码22 项目: dsworkbench   文件: TimePicker.java
private void updateSize() {
    if (minutesExpanded) {
        setMinimumSize(new Dimension(260, 220));
        setMaximumSize(getMinimumSize());
        setPreferredSize(getMinimumSize());
    } else {
        setMinimumSize(new Dimension(260, 160));
        setMaximumSize(getMinimumSize());
        setPreferredSize(getMinimumSize());
    }
    
    if (pParent != null) {
        pParent.pack();
    }
}
 
源代码23 项目: netbeans   文件: CompletionLayoutPopup.java
/**
 * Sets maximum size for appropriate JComponent, depending on wheteher
 * additional items are present
 */
private void setMaxSize(JComponent comp, Dimension maxSize) {
    if (comp instanceof JPanel) {
        comp.getComponent(0).setMaximumSize(maxSize); // JScrollPane
    } else {
        comp.setMaximumSize(maxSize);
    }
}
 
源代码24 项目: lams   文件: ImageHeaderBitmap.java
public ImageHeaderBitmap(byte data[], int offset) {
    BufferedImage img = null;
    try {
        img = ImageIO.read(new ByteArrayInputStream(data, offset, data.length-offset));
    } catch (IOException e) {
        LOG.log(POILogger.WARN, "Can't determine image dimensions", e);
    }
    // set dummy size, in case of dummy dimension can't be set
    size = (img == null)
        ? new Dimension(200,200)
        : new Dimension(
            (int)Units.pixelToPoints(img.getWidth()),
            (int)Units.pixelToPoints(img.getHeight())
        );
}
 
源代码25 项目: pumpernickel   文件: SquaresTransition2D.java
protected float findMax(float t0, float t1) {
	if (t1 - t0 < .0001)
		return Math.max(t0, t1);

	Rectangle2D r = new Rectangle2D.Float(0, 0, 100, 100);
	float mid = t0 / 2f + t1 / 2f;
	Transition2DInstruction[] instrA = getInstructions(t0, new Dimension(
			100, 100));
	Transition2DInstruction[] instrB = getInstructions(mid, new Dimension(
			100, 100));
	Transition2DInstruction[] instrC = getInstructions(t1, new Dimension(
			100, 100));
	boolean validA = false;
	boolean validB = false;
	boolean validC = false;
	for (int a = 1; a < instrA.length; a++) {
		if (r.intersects((Rectangle2D) ((ImageInstruction) instrA[a]).clipping)) {
			validA = true;
		}
		if (r.intersects((Rectangle2D) ((ImageInstruction) instrB[a]).clipping)) {
			validB = true;
		}
		if (r.intersects((Rectangle2D) ((ImageInstruction) instrC[a]).clipping)) {
			validC = true;
		}
	}
	if (validA && validC)
		return Math.max(t0, t1);
	if (validA) {
		if (validB) {
			return findMax(mid, t1);
		} else {
			return findMax(t0, mid);
		}
	} else {
		throw new RuntimeException();
	}
}
 
源代码26 项目: hottub   文件: MetalScrollBarUI.java
public Dimension getPreferredSize( JComponent c )
{
    if ( scrollbar.getOrientation() == JScrollBar.VERTICAL )
    {
        return new Dimension( scrollBarWidth, scrollBarWidth * 3 + 10 );
    }
    else  // Horizontal
    {
        return new Dimension( scrollBarWidth * 3 + 10, scrollBarWidth );
    }

}
 
源代码27 项目: GVGAI_GYM   文件: LanderAvatar.java
public LanderAvatar(Vector2d position, Dimension size, SpriteContent cnt)
{
    //Init the sprite
    this.init(position, size);

    //Specific class default parameter values.
    loadDefaults();

    //Parse the arguments.
    this.parseParameters(cnt);
}
 
源代码28 项目: JDKSourceCode1.8   文件: MultiScrollBarUI.java
/**
 * Invokes the <code>getMinimumSize</code> method on each UI handled by this object.
 *
 * @return the value obtained from the first UI, which is
 * the UI obtained from the default <code>LookAndFeel</code>
 */
public Dimension getMinimumSize(JComponent a) {
    Dimension returnValue =
        ((ComponentUI) (uis.elementAt(0))).getMinimumSize(a);
    for (int i = 1; i < uis.size(); i++) {
        ((ComponentUI) (uis.elementAt(i))).getMinimumSize(a);
    }
    return returnValue;
}
 
源代码29 项目: netbeans   文件: JavaHelp.java
private void init(Runnable run) {
    this.run = run;
    JComponent c = ProgressHandleFactory.createProgressComponent(progressHandle);
    c.setPreferredSize(new Dimension(3 * c.getPreferredSize().width, 3 * c.getPreferredSize().height));
    c.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
    getContentPane().add(c);
    progressHandle.start();
    getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(JavaHelp.class, "ACSD_Loading_Dialog"));  //NOI18N
    pack();
    Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
    Dimension me = getSize();
    setLocation((screen.width - me.width) / 2, (screen.height - me.height) / 2);
}
 
源代码30 项目: xyTalk-pc   文件: GraphicUtils.java
/**
    * Centers the window over a component (usually another window). The window
    * must already have been sized.
    * 
    * @param window
    *            Window to center.
    * @param over
    *            Component to center over.
    */
   public static void centerWindowOnComponent(Window window, Component over) {
if ((over == null) || !over.isShowing()) {
    centerWindowOnScreen(window);
    return;
}

Point parentLocation = over.getLocationOnScreen();
Dimension parentSize = over.getSize();
Dimension size = window.getSize();

// Center it.
int x = parentLocation.x + (parentSize.width - size.width) / 2;
int y = parentLocation.y + (parentSize.height - size.height) / 2;

// Now, make sure it's onscreen
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();

// This doesn't actually work on the Mac, where the screen
// doesn't necessarily start at 0,0
if (x + size.width > screenSize.width)
    x = screenSize.width - size.width;

if (x < 0)
    x = 0;

if (y + size.height > screenSize.height)
    y = screenSize.height - size.height;

if (y < 0)
    y = 0;

window.setLocation(x, y);
   }