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


Java IllegalComponentStateException類代碼示例

本文整理匯總了Java中java.awt.IllegalComponentStateException的典型用法代碼示例。如果您正苦於以下問題:Java IllegalComponentStateException類的具體用法?Java IllegalComponentStateException怎麽用?Java IllegalComponentStateException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: saveWindowLocation

import java.awt.IllegalComponentStateException; //導入依賴的package包/類
/**
     * This static method can be used to save the window x,y, position (but not
     * size). This statis method saves the window origin but not the size, based
     * on a classname-based key in the supplied preferences node.
     *
     * @param window the window to save for
     * @param prefs user preferences node
     * @see #restoreWindowLocation
     */
    public static void saveWindowLocation(Window window, Preferences prefs) {
        String name = window.getClass().getName();
        Point p = new Point(0, 0);
        try {
            p = window.getLocationOnScreen();
        } catch (IllegalComponentStateException e) {
            p = window.getLocation();
        }
        prefs.putInt(name + ".XPosition", (int) p.getX());
        prefs.putInt(name + ".YPosition", (int) p.getY());
//        log.info("saved location for window "+name);
    }
 
開發者ID:SensorsINI,項目名稱:jaer,代碼行數:22,代碼來源:WindowSaver.java

示例2: setLocation

import java.awt.IllegalComponentStateException; //導入依賴的package包/類
public void setLocation(JTextField textField){
 Container container = textField.getParent();
 while (container != null && !(container instanceof Window))
    container = container.getParent();
    
 int offset = 0;
 if (container instanceof JFrame) {
    ((JFrame)container).setGlassPane(this);
    offset = 4;
 }
 else if (container instanceof JDialog)
    ((JDialog)container).setGlassPane(this);
    
 try{
    Point textFieldLocation = textField.getLocationOnScreen();
    Point windowLocation = container.getLocationOnScreen();
    list.setLocation(textFieldLocation.x - windowLocation.x, textFieldLocation.y - windowLocation.y + offset);
    completionList.setLocation(textFieldLocation.x - windowLocation.x, textFieldLocation.y - windowLocation.y + offset);
 }
 catch (IllegalComponentStateException ex){
    // TODO
 }
}
 
開發者ID:StottlerHenkeAssociates,項目名稱:SimBionic,代碼行數:24,代碼來源:SB_Autocomplete.java

示例3: showFullScreen

import java.awt.IllegalComponentStateException; //導入依賴的package包/類
/**
 * This method activates the fullscreen-mode, if it's not already activated yet. To have a 
 * fullscreen-window without decoration, the frame is disposed first, then the decoration
 * will be removed and the window made visible again.
 */
private void showFullScreen() {
    // check whether fullscreen is supported, and if we currently have a fullscreen-window
    if (graphicdevice.isFullScreenSupported() && null==graphicdevice.getFullScreenWindow()) {
        // dispose frame, so we can remove the decoration when setting full screen mode
        searchframe.dispose();
        // hide menubar
        searchMenuBar.setVisible(false);
        // set frame non-resizable
        searchframe.setResizable(false);
        try {
            // remove decoration
            searchframe.setUndecorated(true);
        }
        catch (IllegalComponentStateException e) {
            Constants.zknlogger.log(Level.SEVERE,e.getLocalizedMessage());
        }
        // show frame again
        searchframe.setVisible(true);
        // set fullscreen mode to this window
        graphicdevice.setFullScreenWindow(this);
    }
}
 
開發者ID:sjPlot,項目名稱:Zettelkasten,代碼行數:28,代碼來源:SearchResultsFrame.java

示例4: quitFullScreen

import java.awt.IllegalComponentStateException; //導入依賴的package包/類
/**
 * This method <i>de</i>activates the fullscreen-mode, if it's not already deactivated yet.
 */
private void quitFullScreen() {
    // check whether fullscreen is supported, and if we currently have a fullscreen-window
    if (graphicdevice.isFullScreenSupported() && graphicdevice.getFullScreenWindow()!=null) {
        // disable fullscreen-mode
        graphicdevice.setFullScreenWindow(null);
        // hide menubar
        searchMenuBar.setVisible(true);
        // make frame resizable again
        searchframe.setResizable(true);
        // dispose frame, so we can restore the decoration
        searchframe.dispose();
        try {
            // set decoration
            searchframe.setUndecorated(false);
        }
        catch (IllegalComponentStateException e) {
            Constants.zknlogger.log(Level.SEVERE,e.getLocalizedMessage());
        }
        // show frame again
        searchframe.setVisible(true);
    }
}
 
開發者ID:sjPlot,項目名稱:Zettelkasten,代碼行數:26,代碼來源:SearchResultsFrame.java

示例5: showFullScreen

import java.awt.IllegalComponentStateException; //導入依賴的package包/類
/**
 * This method activates the fullscreen-mode, if it's not already activated
 * yet. To have a fullscreen-window without decoration, the frame is
 * disposed first, then the decoration will be removed and the window made
 * visible again.
 */
private void showFullScreen() {
    // check whether fullscreen is supported, and if we currently have a fullscreen-window
    if (graphicdevice.isFullScreenSupported() && null == graphicdevice.getFullScreenWindow()) {
        // dispose frame, so we can remove the decoration when setting full screen mode
        mainframe.dispose();
        // hide menubar
        jMenuBarDesktop.setVisible(false);
        // set frame non-resizable
        mainframe.setResizable(false);
        try {
            // remove decoration
            mainframe.setUndecorated(true);
        } catch (IllegalComponentStateException e) {
            Constants.zknlogger.log(Level.SEVERE, e.getLocalizedMessage());
        }
        // show frame again
        mainframe.setVisible(true);
        // set fullscreen mode to this window
        graphicdevice.setFullScreenWindow(this);
    }
}
 
開發者ID:sjPlot,項目名稱:Zettelkasten,代碼行數:28,代碼來源:DesktopFrame.java

示例6: quitFullScreen

import java.awt.IllegalComponentStateException; //導入依賴的package包/類
/**
 * This method <i>de</i>activates the fullscreen-mode, if it's not already
 * deactivated yet.
 */
private void quitFullScreen() {
    // check whether fullscreen is supported, and if we currently have a fullscreen-window
    if (graphicdevice.isFullScreenSupported() && graphicdevice.getFullScreenWindow() != null) {
        // disable fullscreen-mode
        graphicdevice.setFullScreenWindow(null);
        // hide menubar
        jMenuBarDesktop.setVisible(true);
        // make frame resizable again
        mainframe.setResizable(true);
        // dispose frame, so we can restore the decoration
        mainframe.dispose();
        try {
            // set decoration
            mainframe.setUndecorated(false);
        } catch (IllegalComponentStateException e) {
            Constants.zknlogger.log(Level.SEVERE, e.getLocalizedMessage());
        }
        // show frame again
        mainframe.setVisible(true);
    }
}
 
開發者ID:sjPlot,項目名稱:Zettelkasten,代碼行數:26,代碼來源:DesktopFrame.java

示例7: executeAction

import java.awt.IllegalComponentStateException; //導入依賴的package包/類
@Override
public void executeAction(WorkflowContext ctx) {
	//configure a new transformer for execution
	SpelObjectTranformer t = new SpelObjectTranformer();
	if(getConfiguration() == null){
		throw new IllegalComponentStateException();
	}
	configureTransformer(t);
	
	TransformConfiguration config = (TransformConfiguration) getConfiguration();
	if(config !=null){
		Object input =null;
		//set input object to the configured one or with the context
		if(config.getInputObjectId()!=null){
			input = ctx.getContextElement(config.getInputObjectId());
		}else{
			input = ctx;
		}
		t.setOutputObject(ctx.getContextElement(config.getOutputObjectId()));
		Object output = t.transform(input);
		ctx.addContextElement(config.getOutputObjectId(), output);
	}
}
 
開發者ID:geosolutions-it,項目名稱:OpenSDI-Manager2,代碼行數:24,代碼來源:TransformAction.java

示例8: notifyListeners

import java.awt.IllegalComponentStateException; //導入依賴的package包/類
public void notifyListeners() {
    if (log.isLoggable(PlatformLogger.Level.FINEST)) {
        log.finest("notifyListeners");
    }
// This method is implemented by making a clone of the set of listeners,
// and then iterating over the clone.  This is because during the course
// of responding to a display change, it may be appropriate for a
// DisplayChangedListener to add or remove itself from a SunDisplayChanger.
// If the set itself were iterated over, rather than a clone, it is
// trivial to get a ConcurrentModificationException by having a
// DisplayChangedListener remove itself from its list.
// Because all display change handling is done on the event thread,
// synchronization provides no protection against modifying the listener
// list while in the middle of iterating over it.  -bchristi 7/10/2001

    Set<DisplayChangedListener> cloneSet;

    synchronized(listeners) {
        cloneSet = new HashSet<DisplayChangedListener>(listeners.keySet());
    }

    Iterator<DisplayChangedListener> itr = cloneSet.iterator();
    while (itr.hasNext()) {
        DisplayChangedListener current = itr.next();
        try {
            if (log.isLoggable(PlatformLogger.Level.FINEST)) {
                log.finest("displayChanged for listener: " + current);
            }
            current.displayChanged();
        } catch (IllegalComponentStateException e) {
            // This DisplayChangeListener is no longer valid.  Most
            // likely, a top-level window was dispose()d, but its
            // Java objects have not yet been garbage collected.  In any
            // case, we no longer need to track this listener, though we
            // do need to remove it from the original list, not the clone.
            listeners.remove(current);
        }
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:40,代碼來源:SunDisplayChanger.java

示例9: notifyPaletteChanged

import java.awt.IllegalComponentStateException; //導入依賴的package包/類
public void notifyPaletteChanged() {
    if (log.isLoggable(PlatformLogger.Level.FINEST)) {
        log.finest("notifyPaletteChanged");
    }
// This method is implemented by making a clone of the set of listeners,
// and then iterating over the clone.  This is because during the course
// of responding to a display change, it may be appropriate for a
// DisplayChangedListener to add or remove itself from a SunDisplayChanger.
// If the set itself were iterated over, rather than a clone, it is
// trivial to get a ConcurrentModificationException by having a
// DisplayChangedListener remove itself from its list.
// Because all display change handling is done on the event thread,
// synchronization provides no protection against modifying the listener
// list while in the middle of iterating over it.  -bchristi 7/10/2001

    Set<DisplayChangedListener> cloneSet;

    synchronized (listeners) {
        cloneSet = new HashSet<DisplayChangedListener>(listeners.keySet());
    }
    Iterator<DisplayChangedListener> itr = cloneSet.iterator();
    while (itr.hasNext()) {
        DisplayChangedListener current = itr.next();
        try {
            if (log.isLoggable(PlatformLogger.Level.FINEST)) {
                log.finest("paletteChanged for listener: " + current);
            }
            current.paletteChanged();
        } catch (IllegalComponentStateException e) {
            // This DisplayChangeListener is no longer valid.  Most
            // likely, a top-level window was dispose()d, but its
            // Java objects have not yet been garbage collected.  In any
            // case, we no longer need to track this listener, though we
            // do need to remove it from the original list, not the clone.
            listeners.remove(current);
        }
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:39,代碼來源:SunDisplayChanger.java

示例10: waitTillShownEx

import java.awt.IllegalComponentStateException; //導入依賴的package包/類
public static void waitTillShownEx(final Component comp) throws InterruptedException {
    while (true) {
        try {
            Thread.sleep(100);
            comp.getLocationOnScreen();
            break;
        } catch (IllegalComponentStateException e) {}
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:10,代碼來源:Util.java

示例11: waitTillShown

import java.awt.IllegalComponentStateException; //導入依賴的package包/類
public static void waitTillShown(final Component comp) throws InterruptedException {
    while (true) {
        try {
            Thread.sleep(100);
            comp.getLocationOnScreen();
            break;
        } catch (IllegalComponentStateException e) {}
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:10,代碼來源:Flag.java

示例12: pressOK

import java.awt.IllegalComponentStateException; //導入依賴的package包/類
private static boolean pressOK(Component comp) {

        JInternalFrame internalFrame
                = findModalInternalFrame(comp, QUESTION);

        if (internalFrame == null) {
            return false;
        }

        JButton button = (JButton) findButton(internalFrame);

        if (button == null) {
            return false;
        }

        try {
            Robot robot = new Robot();
            Point location = button.getLocationOnScreen();
            Rectangle bounds = button.getBounds();
            int centerX = (int) (location.getX() + bounds.getWidth() / 2);
            int centerY = (int) (location.getY() + bounds.getHeight() / 2);
            robot.mouseMove(centerX, centerY);
            robot.mousePress(InputEvent.BUTTON1_MASK);
            robot.mouseRelease(InputEvent.BUTTON1_MASK);
        } catch (IllegalComponentStateException ignore) {
            return false;
        } catch (AWTException e) {
            throw new RuntimeException(e);
        }
        return true;
    }
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:32,代碼來源:bug6219960.java

示例13: savePreferences

import java.awt.IllegalComponentStateException; //導入依賴的package包/類
public void savePreferences() {
	AppPreferences.TICK_FREQUENCY.set(Double.valueOf(proj.getSimulator().getTickFrequency()));
	AppPreferences.LAYOUT_SHOW_GRID.setBoolean(layoutZoomModel.getShowGrid());
	AppPreferences.LAYOUT_ZOOM.set(Double.valueOf(layoutZoomModel.getZoomFactor()));
	if (appearance != null) {
		ZoomModel aZoom = appearance.getZoomModel();
		AppPreferences.APPEARANCE_SHOW_GRID.setBoolean(aZoom.getShowGrid());
		AppPreferences.APPEARANCE_ZOOM.set(Double.valueOf(aZoom.getZoomFactor()));
	}
	int state = getExtendedState() & ~java.awt.Frame.ICONIFIED;
	AppPreferences.WINDOW_STATE.set(Integer.valueOf(state));
	Dimension dim = getSize();
	AppPreferences.WINDOW_WIDTH.set(Integer.valueOf(dim.width));
	AppPreferences.WINDOW_HEIGHT.set(Integer.valueOf(dim.height));
	Point loc;
	try {
		loc = getLocationOnScreen();
	} catch (IllegalComponentStateException e) {
		loc = Projects.getLocation(this);
	}
	if (loc != null) {
		AppPreferences.WINDOW_LOCATION.set(loc.x + "," + loc.y);
	}
	AppPreferences.WINDOW_LEFT_SPLIT.set(Double.valueOf(leftRegion.getFraction()));
	AppPreferences.WINDOW_MAIN_SPLIT.set(Double.valueOf(mainRegion.getFraction()));
	AppPreferences.DIALOG_DIRECTORY.set(JFileChoosers.getCurrentDirectory());
}
 
開發者ID:LogisimIt,項目名稱:Logisim,代碼行數:28,代碼來源:Frame.java

示例14: setLocation

import java.awt.IllegalComponentStateException; //導入依賴的package包/類
public void setLocation(JComponent editingComponent){
	Container container = editingComponent.getParent();
	while (container != null && !(container instanceof Window))
		container = container.getParent();

	int verticalOffset = 0;
	int horizontalOffset = 0;
	if (editingComponent instanceof JTextArea) {
		JTextArea textArea = (JTextArea)editingComponent;
		if ( textArea.getCaret()!=null && textArea.getCaret().getMagicCaretPosition()!=null) {
			verticalOffset = textArea.getCaret().getMagicCaretPosition().y;
			horizontalOffset = textArea.getCaret().getMagicCaretPosition().x;
		}
	}


	if (container instanceof JFrame) {
		((JFrame)container).setGlassPane(this);
		verticalOffset += 4;
	}
	else if (container instanceof JDialog)
		((JDialog)container).setGlassPane(this);

	try{
		Point textFieldLocation = editingComponent.getLocationOnScreen();

		Point windowLocation = container.getLocationOnScreen();
		completionList.setLocation(textFieldLocation.x - windowLocation.x + horizontalOffset, textFieldLocation.y - windowLocation.y + verticalOffset);
	}
	catch (IllegalComponentStateException ex){
		// TODO
	}
}
 
開發者ID:StottlerHenkeAssociates,項目名稱:SimBionic,代碼行數:34,代碼來源:SB_GlassPane.java

示例15: getMousePos

import java.awt.IllegalComponentStateException; //導入依賴的package包/類
/**
 * Returns the mouse coordinates relative to the image.<br> 
 * If the ImageWindow is not open -1,-1 is returned
 * @return java.awt.Point
 */
public Point getMousePos() {
	try {
		Point mousePoint=MouseInfo.getPointerInfo().getLocation();
		Point componentPoint=this.getLocationOnScreen();
		Point p = new Point(mousePoint.x-componentPoint.x,mousePoint.y-componentPoint.y);
		return p;
	} catch (IllegalComponentStateException e) {
		return new Point (-1,-1);
	}
}
 
開發者ID:flakibr,項目名稱:UniBasel-Erweiterte-GdP,代碼行數:16,代碼來源:ImageWindow.java


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