List of usage examples for javax.swing SwingUtilities convertPointFromScreen
@SuppressWarnings("deprecation") public static void convertPointFromScreen(Point p, Component c)
From source file:Main.java
public static void main(String[] argv) { JButton component = new JButton(); Point pt = new Point(component.getLocation()); SwingUtilities.convertPointFromScreen(pt, component); }
From source file:Main.java
/** * <p>/*from w w w . j a v a 2 s . co m*/ * Determines if the component is visible in its window at the given screen location. * </p> * * @param location A location on the screen. * @param component A component in a window. * @return True if the component is visible in its window at the given screen location. */ public static boolean locationInComponentVisible(Point location, Component component) { // Get the root component in the window. JRootPane rootPane = getRootPane(component); if (rootPane != null) { Component rootComponent = rootPane.getContentPane(); if (rootComponent != null) { // Get the location relative to this root component. Point locationInRoot = new Point(location); SwingUtilities.convertPointFromScreen(locationInRoot, rootComponent); // Get the deepest visible component at the given location. Component deepestComponent = SwingUtilities.getDeepestComponentAt(rootComponent, locationInRoot.x, locationInRoot.y); if (deepestComponent != null) { boolean result = SwingUtilities.isDescendingFrom(deepestComponent, component); return result; } } } return false; }
From source file:com.epiq.bitshark.ui.FrequencyDomainPanel.java
/** * *///from w ww. j av a2 s .c o m protected void updateMouseMarker() { if (markerAnnotation.isVisible()) { Point screenPoint = MouseInfo.getPointerInfo().getLocation(); SwingUtilities.convertPointFromScreen(screenPoint, chartPanel); updateMouseMarker(screenPoint); } }
From source file:org.isatools.isacreator.spreadsheet.Spreadsheet.java
public void mousePressed(MouseEvent event) { if (event.getSource() instanceof JLabel) { } else {/*from w w w . jav a 2 s . com*/ if (SwingUtilities.isRightMouseButton(event)) { String columnName = table.getColumnModel().getColumn(table.columnAtPoint(event.getPoint())) .getHeaderValue().toString(); SwingUtilities.convertPointFromScreen(event.getPoint(), table); spreadsheetPopups.popupMenu(table, event.getX() + 10, event.getY() + 10, columnName); } if (SwingUtilities.isLeftMouseButton(event)) { startRow = table.rowAtPoint(event.getPoint()); startCol = table.columnAtPoint(event.getPoint()); } } }
From source file:org.isatools.isacreator.spreadsheet.Spreadsheet.java
public void mouseReleased(MouseEvent event) { if (SwingUtilities.isLeftMouseButton(event) && (table.rowAtPoint(event.getPoint()) - startRow) > 1) { SwingUtilities.convertPointFromScreen(event.getPoint(), table); spreadsheetPopups.dragCellPopupMenu(table, event.getX(), event.getY()); }/* ww w. j a v a 2 s .c o m*/ }
From source file:tvbrowser.ui.mainframe.MainFrame.java
/** * Switch the fullscreen mode of TV-Browser *//*from w w w . j a v a 2s .c o m*/ public void switchFullscreenMode() { dispose(); SwingUtilities.invokeLater(new Runnable() { public void run() { GraphicsDevice device = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(); if (isFullScreenMode()) { // switch back from fullscreen device.setFullScreenWindow(null); setUndecorated(false); setBounds(mXPos, mYPos, mWidth, mHeight); if (mMenuBar != null) { mMenuBar.setFullscreenItemChecked(false); mMenuBar.setVisible(true); } if (mToolBarPanel != null) { mToolBarPanel.setVisible(Settings.propIsToolbarVisible.getBoolean()); } if (mStatusBar != null) { mStatusBar.setVisible(Settings.propIsStatusbarVisible.getBoolean()); } if (mChannelChooser != null) { mChannelChooser.setVisible(Settings.propShowChannels.getBoolean()); } if (mFinderPanel != null) { mFinderPanel.getComponent().setVisible(Settings.propShowDatelist.getBoolean()); } setVisible(true); setShowPluginOverview(Settings.propShowPluginView.getBoolean(), false); setShowTimeButtons(Settings.propShowTimeButtons.getBoolean(), false); setShowDatelist(Settings.propShowDatelist.getBoolean(), false); setShowChannellist(Settings.propShowChannels.getBoolean(), false); } else { // switch into fullscreen mXPos = getX(); mYPos = getY(); mWidth = getWidth(); mHeight = getHeight(); setShowPluginOverview(false, false); setShowTimeButtons(false, false); setShowDatelist(false, false); setShowChannellist(false, false); if (mStatusBar != null) { mMenuBar.setFullscreenItemChecked(true); mStatusBar.setVisible(false); } if (mChannelChooser != null) { mChannelChooser.setVisible(false); } if (mMenuBar != null) { mMenuBar.setVisible(false); } if (mToolBarPanel != null) { mToolBarPanel.setVisible(false); } if (mFinderPanel != null) { mFinderPanel.getComponent().setVisible(false); } setUndecorated(true); final Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); if (device.isFullScreenSupported() && OperatingSystem.isMacOs()) { device.setFullScreenWindow(MainFrame.getInstance()); } else { setLocation(0, 0); setSize(screen); } setVisible(true); mProgramTableScrollPane.requestFocusInWindow(); new Thread("Fullscreen border detection") { public void run() { setPriority(Thread.MIN_PRIORITY); while (isFullScreenMode()) { final Point p = MouseInfo.getPointerInfo().getLocation(); SwingUtilities.convertPointFromScreen(p, MainFrame.this); if (isActive()) { // mouse pointer is at top if (p.y <= 10) { if (mToolBarPanel != null && mToolBar.getToolbarLocation() .compareTo(BorderLayout.NORTH) == 0) { if (!mToolBarPanel.isVisible()) { mToolBarPanel .setVisible(Settings.propIsToolbarVisible.getBoolean()); } } if (p.y <= 0) { mMenuBar.setVisible(true); } } else if (p.y > (mMenuBar != null && mMenuBar.isVisible() ? mMenuBar.getHeight() : 0) + (Settings.propIsToolbarVisible.getBoolean() ? mToolBarPanel.getHeight() : 0)) { if (mMenuBar.isVisible()) { mMenuBar.setVisible(!isFullScreenMode()); } if (mToolBarPanel != null && mToolBarPanel.isVisible() && mToolBar .getToolbarLocation().compareTo(BorderLayout.NORTH) == 0) { mToolBarPanel.setVisible(!isFullScreenMode()); } } // mouse pointer is at the bottom if (p.y >= screen.height - 1) { if (mStatusBar != null && !mStatusBar.isVisible()) { mStatusBar.setVisible(Settings.propIsStatusbarVisible.getBoolean()); } } else if (mStatusBar != null && mStatusBar.isVisible() && p.y < screen.height - mStatusBar.getHeight()) { mStatusBar.setVisible(!isFullScreenMode()); } // mouse pointer is on the left side if (p.x <= 5) { if (p.x == 0 && mToolBarPanel != null && mToolBar.getToolbarLocation() .compareTo(BorderLayout.WEST) == 0) { if (!mToolBarPanel.isVisible()) { mToolBarPanel .setVisible(Settings.propIsToolbarVisible.getBoolean()); } } if (Settings.propPluginViewIsLeft.getBoolean()) { if (Settings.propShowPluginView.getBoolean()) { SwingUtilities.invokeLater(new Runnable() { public void run() { setShowPluginOverview(true, false); } }); } } else { checkIfToShowTimeDateChannelList(); } } else { int toolBarWidth = (mToolBarPanel != null && mToolBarPanel.isVisible() && mToolBar.getToolbarLocation().compareTo(BorderLayout.WEST) == 0) ? mToolBarPanel.getWidth() : 0; if (p.x > toolBarWidth && toolBarWidth != 0) { mToolBarPanel.setVisible(!isFullScreenMode()); } if (Settings.propPluginViewIsLeft.getBoolean()) { if (Settings.propShowPluginView.getBoolean() && mPluginView != null && mPluginView.isVisible() && p.x > mPluginView.getWidth() + toolBarWidth + 25) { SwingUtilities.invokeLater(new Runnable() { public void run() { setShowPluginOverview(!isFullScreenMode(), false); } }); } } else if (Settings.propShowChannels.getBoolean() || Settings.propShowDatelist.getBoolean() || Settings.propShowTimeButtons.getBoolean()) { SwingUtilities.invokeLater(new Runnable() { public void run() { if (mChannelChooser != null && mChannelChooser.isVisible() && p.x > mChannelChooser.getWidth()) { setShowChannellist(!isFullScreenMode(), false); } if (mFinderPanel != null && mFinderPanel.getComponent().isVisible() && p.x > mFinderPanel.getComponent().getWidth()) { setShowDatelist(!isFullScreenMode(), false); } if (mTimeChooserPanel != null && mTimeChooserPanel.isVisible() && p.x > mTimeChooserPanel.getWidth()) { setShowTimeButtons(!isFullScreenMode(), false); } } }); } } // mouse pointer is on the right side if (p.x >= screen.width - 1) { if (!Settings.propPluginViewIsLeft.getBoolean()) { if (Settings.propShowPluginView.getBoolean()) { SwingUtilities.invokeLater(new Runnable() { public void run() { setShowPluginOverview(true, false); } }); } } else { checkIfToShowTimeDateChannelList(); } } else { if (!Settings.propPluginViewIsLeft.getBoolean()) { if (Settings.propShowPluginView.getBoolean() && mPluginView != null && mPluginView.isVisible() && p.x < screen.width - mPluginView.getWidth()) { SwingUtilities.invokeLater(new Runnable() { public void run() { setShowPluginOverview(!isFullScreenMode(), false); } }); } } else if (Settings.propShowChannels.getBoolean() || Settings.propShowDatelist.getBoolean() || Settings.propShowTimeButtons.getBoolean()) { SwingUtilities.invokeLater(new Runnable() { public void run() { if (mChannelChooser != null && mChannelChooser.isVisible() && p.x < screen.width - mChannelChooser.getWidth()) { setShowChannellist(!isFullScreenMode(), false); } if (mFinderPanel != null && mFinderPanel.getComponent().isVisible() && p.x < screen.width - mFinderPanel.getComponent().getWidth()) { setShowDatelist(!isFullScreenMode(), false); } if (mTimeChooserPanel != null && mTimeChooserPanel.isVisible() && p.x < screen.width - mTimeChooserPanel.getWidth()) { setShowTimeButtons(!isFullScreenMode(), false); } } }); } } } try { Thread.sleep(200); } catch (Exception e) { } } } }.start(); } } }); }