當前位置: 首頁>>代碼示例>>Java>>正文


Java Utilities.getUsableScreenBounds方法代碼示例

本文整理匯總了Java中org.openide.util.Utilities.getUsableScreenBounds方法的典型用法代碼示例。如果您正苦於以下問題:Java Utilities.getUsableScreenBounds方法的具體用法?Java Utilities.getUsableScreenBounds怎麽用?Java Utilities.getUsableScreenBounds使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.openide.util.Utilities的用法示例。


在下文中一共展示了Utilities.getUsableScreenBounds方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: findPopupBounds

import org.openide.util.Utilities; //導入方法依賴的package包/類
/**
 * Find bounds of the popup based on knowledge of the preferred size
 * of the content component and the preference of the displaying
 * of the popup either above or below the occupied bounds.
 *
 * @param occupiedBounds bounds of the rectangle above or below which
 *   the bounds should be found.
 * @param aboveOccupiedBounds whether the bounds should be found for position
 *   above or below the occupied bounds.
 * @return rectangle with absolute screen bounds of the popup.
 */
private Rectangle findPopupBounds(Rectangle occupiedBounds, boolean aboveOccupiedBounds) {
    Rectangle screen = Utilities.getUsableScreenBounds();
    Dimension prefSize = getPreferredSize();
    Rectangle popupBounds = new Rectangle();
    
    popupBounds.x = Math.min(occupiedBounds.x,
            (screen.x + screen.width) - prefSize.width);
    popupBounds.x = Math.max(popupBounds.x, screen.x);
    popupBounds.width = Math.min(prefSize.width, screen.width);
    
    if (aboveOccupiedBounds) {
        popupBounds.height = Math.min(prefSize.height,
                occupiedBounds.y - screen.y - CompletionLayout.POPUP_VERTICAL_GAP);
        popupBounds.y = occupiedBounds.y - CompletionLayout.POPUP_VERTICAL_GAP - popupBounds.height;
    } else { // below caret
        popupBounds.y = occupiedBounds.y
                + occupiedBounds.height + CompletionLayout.POPUP_VERTICAL_GAP;
        popupBounds.height = Math.min(prefSize.height,
                (screen.y + screen.height) - popupBounds.y);
    }
    return popupBounds;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:34,代碼來源:CompletionLayoutPopup.java

示例2: computePopupBounds

import org.openide.util.Utilities; //導入方法依賴的package包/類
@Override
protected Rectangle computePopupBounds(int px, int py, int pw, int ph) {
    if( ComboBoxAutoCompleteSupport.isAutoCompleteInstalled( comboBox ) )
            return super.computePopupBounds( px, py, pw, ph );
    Dimension d = list.getPreferredSize();
    Rectangle r = Utilities.getUsableScreenBounds();

    if (pw < d.width) {
        pw = Math.min(d.width, r.width - px);
    }

    if (ph < d.height) {
        ph = Math.min(r.height - py, d.height);
    }

    if ((px + pw) > (r.width - px)) {
        px -= (r.width - pw);
    }

    Rectangle result = new Rectangle(px, py, pw, ph);

    return result;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:24,代碼來源:CleanComboUI.java

示例3: SwitcherTable

import org.openide.util.Utilities; //導入方法依賴的package包/類
/**
 * Creates a new instance of SwitcherTable. Height of created table will be
 * computed according to given y coordinate. Height will be used during the
 * number of row computing.
 */
public SwitcherTable(SwitcherTableItem[] items, int y) {
    super();
    init();
    // get rid of the effect when popup seems to be higher that screen height
    int gap = (y == 0 ? 10 : 5);
    int height = Utilities.getUsableScreenBounds().height - y - gap;
    setModel(new SwitcherTableModel(items, getRowHeight(), height));
    getSelectionModel().clearSelection();
    getSelectionModel().setAnchorSelectionIndex(-1);
    getSelectionModel().setLeadSelectionIndex(-1);
    setAutoscrolls( false );
    boolean hasIcons = false;
    for( SwitcherTableItem i : items ) {
        if( i.getIcon() != null && i.getIcon().getIconWidth() > 0 ) {
            hasIcons = true;
            break;
        }
    }
    showIcons = hasIcons;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:26,代碼來源:SwitcherTable.java

示例4: showPopupMenu

import org.openide.util.Utilities; //導入方法依賴的package包/類
/** Shows given popup on given coordinations and takes care about the
 * situation when menu can exceed screen limits */
private static void showPopupMenu (JPopupMenu popup, Point p, Component comp) {
    if (NO_POPUP_PLACEMENT_HACK) {
        popup.show(comp, p.x, p.y);
        return;
    }

    SwingUtilities.convertPointToScreen (p, comp);
    Dimension popupSize = popup.getPreferredSize ();
    Rectangle screenBounds = Utilities.getUsableScreenBounds(comp.getGraphicsConfiguration());

    if (p.x + popupSize.width > screenBounds.x + screenBounds.width) {
        p.x = screenBounds.x + screenBounds.width - popupSize.width;
    }
    if (p.y + popupSize.height > screenBounds.y + screenBounds.height) {
        p.y = screenBounds.y + screenBounds.height - popupSize.height;
    }

    SwingUtilities.convertPointFromScreen (p, comp);
    popup.show(comp, p.x, p.y);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:23,代碼來源:CommandManager.java

示例5: getPreferredScrollableViewportSize

import org.openide.util.Utilities; //導入方法依賴的package包/類
@Override
public Dimension getPreferredScrollableViewportSize() {
    if( needCalcRowHeight ) {
        calcRowHeight( getOffscreenGraphics() );
        prefSize = null;
    }
    if( null == prefSize ) {
        Dimension dim = new Dimension();
        for( int i=0; i<getColumnCount(); i++ ) {
            TableColumn tc = getColumnModel().getColumn( i );
            dim.width += tc.getPreferredWidth();
        }
        int rowCount = Math.min( MAX_VISIBLE_ROWS, getRowCount() );
        dim.height = rowCount*getRowHeight();
        Rectangle screen = Utilities.getUsableScreenBounds();
        dim.width = Math.min( dim.width, screen.width-100 );
        dim.height = Math.min( dim.height, screen.height-100 );
        prefSize = dim;
    }
    return prefSize;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:22,代碼來源:Table.java

示例6: VerticalGridLayout

import org.openide.util.Utilities; //導入方法依賴的package包/類
public VerticalGridLayout() {
    super();
    TopComponent activated = TopComponent.getRegistry().getActivated();
    if (activated != null) {
        Rectangle screenParams = Utilities.getUsableScreenBounds(activated.getGraphicsConfiguration());
        //half of the size is used, b/c sometimes it is submenu not visible at the top
        this.screenHeight = (int)(screenParams.height * 0.5);
    } else {
        this.screenHeight = (int)(WindowManager.getDefault().getMainWindow().getSize().height * 0.5);
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:12,代碼來源:VerticalGridLayout.java

示例7: mousePressed

import org.openide.util.Utilities; //導入方法依賴的package包/類
public void mousePressed(MouseEvent e) {
    if (e.getComponent().isEnabled()) {
        // open the popup menu
        Node context = null;

        if (!root) {
            Node[] sel = explorerManager.getSelectedNodes();

            if (sel.length > 0) {
                context = sel[0];
            }
        }

        if (context == null) {
            context = explorerManager.getRootContext();
        }

        Menu menu = new Menu(context, listener);

        JPopupMenu popupMenu = menu.getPopupMenu();
        java.awt.Point p = new java.awt.Point(e.getX(), e.getY());
        p.x = e.getX() - p.x;
        p.y = e.getY() - p.y;
        SwingUtilities.convertPointToScreen(p, e.getComponent());

        Dimension popupSize = popupMenu.getPreferredSize();
        Rectangle screenBounds = Utilities.getUsableScreenBounds(getGraphicsConfiguration());

        if ((p.x + popupSize.width) > (screenBounds.x + screenBounds.width)) {
            p.x = (screenBounds.x + screenBounds.width) - popupSize.width;
        }

        if ((p.y + popupSize.height) > (screenBounds.y + screenBounds.height)) {
            p.y = (screenBounds.y + screenBounds.height) - popupSize.height;
        }

        SwingUtilities.convertPointFromScreen(p, e.getComponent());
        popupMenu.show(e.getComponent(), p.x, p.y);
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:41,代碼來源:MenuView.java

示例8: SwitcherTable

import org.openide.util.Utilities; //導入方法依賴的package包/類
/**
 * Creates a new instance of SwitcherTable. Height of created table will be
 * computed according to given y coordinate. Height will be used during the
 * number of row computing.
 */
public SwitcherTable(SwitcherTableItem[] items, int y) {
    super();
    init();
    // get rid of the effect when popup seems to be higher that screen height
    int gap = (y == 0 ? 10 : 5);
    int height = Utilities.getUsableScreenBounds().height - y - gap;
    setModel(new SwitcherTableModel(items, getRowHeight(), height));
    getSelectionModel().clearSelection();
    getSelectionModel().setAnchorSelectionIndex(-1);
    getSelectionModel().setLeadSelectionIndex(-1);
    setAutoscrolls( false );
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:18,代碼來源:SwitcherTable.java

示例9: setData

import org.openide.util.Utilities; //導入方法依賴的package包/類
void setData(List data, int selectedIndex) {
    smartIndex = -1;
    if (data != null) {
        int itemCount = data.size();
        ListCellRenderer renderer = getCellRenderer();
        int width = 0;
        int maxWidth = getParent().getParent().getMaximumSize().width;
        boolean stop = false;
        for(int index = 0; index < itemCount; index++) {
            Object value = data.get(index);
            if (value instanceof LazyCompletionItem) {
                maxWidth = (int)(Utilities.getUsableScreenBounds().width * CompletionLayoutPopup.COMPL_COVERAGE);
            }
            Component c = renderer.getListCellRendererComponent(this, value, index, false, false);
            if (c != null) {
                Dimension cellSize = c.getPreferredSize();
                if (cellSize.width > width) {
                    width = cellSize.width;
                    if (width >= maxWidth)
                        stop = true;                    
                }
            }
            if (smartIndex < 0 && value instanceof CompletionItem && ((CompletionItem)value).getSortPriority() >= 0)
                smartIndex = index;
            if (stop && smartIndex >= 0)
                break;
        }
        setFixedCellWidth(width);
        LazyListModel lm = LazyListModel.create( new Model(data), CompletionImpl.filter, 1.0d, LocaleSupport.getString("completion-please-wait") ); //NOI18N
        setModel(lm);
        
        if (itemCount > 0) {
            setSelectedIndex(selectedIndex < 0 ? 0 : lm.findExternalIndex(selectedIndex));
        }
        int visibleRowCount = Math.min(itemCount, maxVisibleRowCount);
        setVisibleRowCount(visibleRowCount);
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:39,代碼來源:CompletionJList.java

示例10: getPreferredSize

import org.openide.util.Utilities; //導入方法依賴的package包/類
final Dimension getPreferredSize() {
    JComponent comp = getContentComponent();

    if (comp == null) {
        return new Dimension(0, 0);
    }

    int screenWidth = Utilities.getUsableScreenBounds().width;

    Dimension maxSize = new Dimension((int) (screenWidth * MAX_COMPL_COVERAGE),
            comp.getMaximumSize().height); //set maximum part of screen covered
    setMaxSize(comp, maxSize);

    return comp.getPreferredSize();
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:16,代碼來源:CompletionLayoutPopup.java

示例11: createPopup

import org.openide.util.Utilities; //導入方法依賴的package包/類
void createPopup(int xpos, int ypos, boolean contextMenu) {
    if (manager == null) {
        return;
    }

    if (!popupAllowed) {
        return;
    }
    
    if (!isShowing()) {
        return;
    }

    JPopupMenu popup;

    if (contextMenu) {
        popup = Utilities.actionsToPopup(manager.getExploredContext().getActions(true), this);
    } else {
        Action[] actions = NodeOp.findActions(manager.getSelectedNodes());
        popup = Utilities.actionsToPopup(actions, this);
    }

    if ((popup != null) && (popup.getSubElements().length > 0)) {
        Point p = getViewport().getViewPosition();
        p.x = xpos - p.x;
        p.y = ypos - p.y;

        SwingUtilities.convertPointToScreen(p, ListView.this);

        Dimension popupSize = popup.getPreferredSize();
        Rectangle screenBounds = Utilities.getUsableScreenBounds(getGraphicsConfiguration());

        if ((p.x + popupSize.width) > (screenBounds.x + screenBounds.width)) {
            p.x = (screenBounds.x + screenBounds.width) - popupSize.width;
        }

        if ((p.y + popupSize.height) > (screenBounds.y + screenBounds.height)) {
            p.y = (screenBounds.y + screenBounds.height) - popupSize.height;
        }

        SwingUtilities.convertPointFromScreen(p, ListView.this);
        popup.show(this, p.x, p.y);
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:45,代碼來源:ListView.java

示例12: showAlongOrNextOccupiedBounds

import org.openide.util.Utilities; //導入方法依賴的package包/類
/**
 * Displays popup right, left of currently occupied bounds if possible,
 * otherwise fallback to above/below
 * @param occupiedBounds bounds of CC popup
 * @param unionBounds bounds occupied by all popups
 */
void showAlongOrNextOccupiedBounds(Rectangle occupiedBounds, Rectangle unionBounds) {
    if (occupiedBounds != null) {
        Rectangle screen = Utilities.getUsableScreenBounds();
        Dimension prefSize = getPreferredSize();
        Rectangle bounds = new Rectangle();
        boolean aboveCaret;

        if (isEnoughSpace(occupiedBounds, preferDisplayAboveCaret)) {
            aboveCaret = preferDisplayAboveCaret;
        } else {
            aboveCaret = false;
        }

        boolean left = false;
        boolean right = false;

        // Right of CC
        if (occupiedBounds.x + occupiedBounds.width + prefSize.width < screen.width
                && occupiedBounds.y + prefSize.height < screen.height) {
            bounds.x = occupiedBounds.x + occupiedBounds.width + ScrollCompletionPane.POPUP_VERTICAL_GAP;
            right = true;
        }

        // Left of CC
        if (!right && occupiedBounds.x - prefSize.width > 0 && occupiedBounds.y + prefSize.height < screen.height) {
            bounds.x = occupiedBounds.x - prefSize.width - ScrollCompletionPane.POPUP_VERTICAL_GAP;
            left = true;
        }

        if (right || left) {
            bounds.width = prefSize.width;
            bounds.height = Math.min(prefSize.height, screen.height);
            if (aboveCaret) {
                bounds.y = occupiedBounds.y + occupiedBounds.height - prefSize.height;
            } else {
                bounds.y = occupiedBounds.y;
            }
            show(bounds, aboveCaret);
            return;
        }
    }

    // Fallback to Above/Below
    showAlongOccupiedBounds(unionBounds);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:52,代碼來源:CompletionLayoutPopup.java

示例13: getBounds

import org.openide.util.Utilities; //導入方法依賴的package包/類
public Rectangle getBounds() {
    return Utilities.getUsableScreenBounds();
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:4,代碼來源:DummyWindowManager.java

示例14: showAlongOrNextOccupiedBounds

import org.openide.util.Utilities; //導入方法依賴的package包/類
/**
 * Displays popup right, left of currently occupied bounds if possible,
 * otherwise fallback to above/below
 * @param occupiedBounds bounds of CC popup
 * @param unionBounds bounds occupied by all popups
 */
void showAlongOrNextOccupiedBounds(Rectangle occupiedBounds, Rectangle unionBounds) {
    if (occupiedBounds != null) {
        Rectangle screen = Utilities.getUsableScreenBounds();
        Dimension prefSize = getPreferredSize();
        Rectangle bounds = new Rectangle();
        boolean aboveCaret;

        if (isEnoughSpace(occupiedBounds, preferDisplayAboveCaret)) {
            aboveCaret = preferDisplayAboveCaret;
        } else
            aboveCaret = false;

        boolean left = false;
        boolean right = false;

        // Right of CC
        if (occupiedBounds.x + occupiedBounds.width + prefSize.width < screen.width &&
                occupiedBounds.y + prefSize.height < screen.height) {
            bounds.x = occupiedBounds.x + occupiedBounds.width + CompletionLayout.POPUP_VERTICAL_GAP;
            right = true;
        }

        // Left of CC
        if (!right && occupiedBounds.x - prefSize.width > 0 && occupiedBounds.y + prefSize.height < screen.height) {
            bounds.x = occupiedBounds.x - prefSize.width - CompletionLayout.POPUP_VERTICAL_GAP;
            left = true;
        }

        if (right || left) {
            bounds.width = prefSize.width;
            bounds.height = Math.min(prefSize.height, screen.height);
            if (aboveCaret) {
                bounds.y = occupiedBounds.y + occupiedBounds.height - prefSize.height;
            } else {
                bounds.y = occupiedBounds.y;
            }
            show(bounds, aboveCaret);
            return;
        }
    }

    // Fallback to Above/Below
    showAlongOccupiedBounds(unionBounds);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:51,代碼來源:CompletionLayoutPopup.java

示例15: isMoreSpaceAbove

import org.openide.util.Utilities; //導入方法依賴的package包/類
boolean isMoreSpaceAbove(Rectangle bounds) {
    Rectangle screen = Utilities.getUsableScreenBounds();
    int above = bounds.y - screen.y;
    int below = (screen.y + screen.height) - (bounds.y + bounds.height);
    return (above > below);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:7,代碼來源:CompletionLayoutPopup.java


注:本文中的org.openide.util.Utilities.getUsableScreenBounds方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。