本文整理汇总了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);
}
示例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
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
}
示例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);
}
}
}
示例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) {}
}
}
示例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) {}
}
}
示例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;
}
示例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());
}
示例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
}
}
示例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);
}
}