本文整理匯總了Java中java.awt.Frame.setUndecorated方法的典型用法代碼示例。如果您正苦於以下問題:Java Frame.setUndecorated方法的具體用法?Java Frame.setUndecorated怎麽用?Java Frame.setUndecorated使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.awt.Frame
的用法示例。
在下文中一共展示了Frame.setUndecorated方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: doTest
import java.awt.Frame; //導入方法依賴的package包/類
boolean doTest() {
Dimension beforeMaximizeCalled = new Dimension(300,300);
frame = new Frame("Test Frame");
frame.setUndecorated(true);
frame.setFocusable(true);
frame.setSize(beforeMaximizeCalled);
frame.setVisible(true);
frame.setExtendedState(Frame.MAXIMIZED_BOTH);
frame.setExtendedState(Frame.NORMAL);
Dimension afterMaximizedCalled= frame.getBounds().getSize();
frame.dispose();
if (beforeMaximizeCalled.equals(afterMaximizedCalled)) {
return true;
}
return false;
}
示例2: main
import java.awt.Frame; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
GraphicsDevice[] sds = GraphicsEnvironment.getLocalGraphicsEnvironment()
.getScreenDevices();
for (final GraphicsDevice gd : sds) {
fail = true;
Robot robot = new Robot(gd);
robot.setAutoDelay(100);
robot.setAutoWaitForIdle(true);
Frame frame = new Frame(gd.getDefaultConfiguration());
frame.setUndecorated(true);
frame.setSize(400, 400);
frame.setVisible(true);
robot.waitForIdle();
frame.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
System.out.println("e = " + e);
fail = false;
}
});
Rectangle bounds = frame.getBounds();
robot.mouseMove(bounds.x + bounds.width / 2,
bounds.y + bounds.height / 2);
robot.mousePress(MouseEvent.BUTTON1_DOWN_MASK);
robot.mouseRelease(MouseEvent.BUTTON1_DOWN_MASK);
frame.dispose();
if (fail) {
System.err.println("Frame bounds = " + bounds);
throw new RuntimeException("Click in the wrong location");
}
}
}
示例3: main
import java.awt.Frame; //導入方法依賴的package包/類
public static void main(String[] args) throws AWTException
{
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice[] gds = ge.getScreenDevices();
if (gds.length < 2) {
System.out.println("It's a multiscreen test... skipping!");
return;
}
for (int i = 0; i < gds.length; ++i) {
GraphicsDevice gd = gds[i];
GraphicsConfiguration gc = gd.getDefaultConfiguration();
Rectangle screen = gc.getBounds();
Robot robot = new Robot(gd);
// check Robot.mouseMove()
robot.mouseMove(screen.x + mouseOffset.x, screen.y + mouseOffset.y);
Point mouse = MouseInfo.getPointerInfo().getLocation();
Point point = screen.getLocation();
point.translate(mouseOffset.x, mouseOffset.y);
if (!point.equals(mouse)) {
throw new RuntimeException(getErrorText("Robot.mouseMove", i));
}
// check Robot.getPixelColor()
Frame frame = new Frame(gc);
frame.setUndecorated(true);
frame.setSize(100, 100);
frame.setLocation(screen.x + frameOffset.x, screen.y + frameOffset.y);
frame.setBackground(color);
frame.setVisible(true);
robot.waitForIdle();
Rectangle bounds = frame.getBounds();
if (!Util.testBoundsColor(bounds, color, 5, 1000, robot)) {
throw new RuntimeException(getErrorText("Robot.getPixelColor", i));
}
// check Robot.createScreenCapture()
BufferedImage image = robot.createScreenCapture(bounds);
int rgb = color.getRGB();
if (image.getRGB(0, 0) != rgb
|| image.getRGB(image.getWidth() - 1, 0) != rgb
|| image.getRGB(image.getWidth() - 1, image.getHeight() - 1) != rgb
|| image.getRGB(0, image.getHeight() - 1) != rgb) {
throw new RuntimeException(
getErrorText("Robot.createScreenCapture", i));
}
frame.dispose();
}
System.out.println("Test PASSED!");
}
示例4: main
import java.awt.Frame; //導入方法依賴的package包/類
public static void main(final String[] args) throws AWTException {
final Frame frame = new Frame();
final Component label = new PaintNativeOnUpdate();
frame.setBackground(Color.RED);
frame.add(label);
frame.setSize(300, 300);
frame.setUndecorated(true);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
sleep();
label.repaint();// first paint
sleep();
label.repaint();// incremental paint
sleep();
Robot robot = new Robot();
robot.setAutoDelay(50);
Point point = label.getLocationOnScreen();
Color color = robot.getPixelColor(point.x + label.getWidth() / 2,
point.y + label.getHeight() / 2);
if (!color.equals(Color.GREEN)) {
System.err.println("Expected color = " + Color.GREEN);
System.err.println("Actual color = " + color);
throw new RuntimeException();
}
frame.dispose();
}
示例5: SharedMemoryPixmapsTest
import java.awt.Frame; //導入方法依賴的package包/類
/** Creates a new instance of SharedMemoryPixmapsTest */
public SharedMemoryPixmapsTest() {
testFrame = new Frame("SharedMemoryPixmapsTest");
testFrame.add(new TestComponent());
testFrame.setUndecorated(true);
testFrame.setResizable(false);
testFrame.pack();
testFrame.setLocationRelativeTo(null);
testFrame.setVisible(true);
testFrame.toFront();
}
示例6: testFrame
import java.awt.Frame; //導入方法依賴的package包/類
static void testFrame(boolean isUndecorated) throws Exception {
Frame frame = new Frame();
try {
Robot robot = new Robot();
robot.setAutoDelay(100);
frame.setUndecorated(isUndecorated);
GraphicsConfiguration gc = GraphicsEnvironment.getLocalGraphicsEnvironment()
.getDefaultScreenDevice().getDefaultConfiguration();
Rectangle bounds = gc.getBounds();
Insets insets = Toolkit.getDefaultToolkit().getScreenInsets(gc);
int x = bounds.x + insets.left;
int y = bounds.y + insets.top;
int width = bounds.width - insets.left - insets.right;
int height = bounds.height - insets.top - insets.bottom;
Rectangle rect = new Rectangle(x, y, width, height);
frame.pack();
frame.setBounds(rect);
frame.setVisible(true);
robot.waitForIdle();
robot.delay(500);
if (frame.getWidth() <= width / 2
|| frame.getHeight() <= height / 2) {
throw new RuntimeException("Frame size is small!");
}
if (!isUndecorated && frame.getExtendedState() != Frame.MAXIMIZED_BOTH) {
throw new RuntimeException("Frame state does not equal"
+ " MAXIMIZED_BOTH!");
}
} finally {
frame.dispose();
}
}
示例7: main
import java.awt.Frame; //導入方法依賴的package包/類
public static void main(final String[] args) throws Exception {
Applet applet = new Applet();
Frame frame = new Frame();
try {
frame.setSize(10, 10);
frame.add(applet);
frame.setUndecorated(true);
frame.setVisible(true);
test(applet);
System.out.println("ok");
} finally {
frame.dispose();
}
}
示例8: main
import java.awt.Frame; //導入方法依賴的package包/類
public static void main(final String[] args) throws AWTException {
ExtendedRobot robot = new ExtendedRobot();
robot.setAutoDelay(50);
final Frame frame = new Frame();
final Component label = new PaintNativeOnUpdate();
frame.setBackground(Color.RED);
frame.add(label);
frame.setSize(300, 300);
frame.setUndecorated(true);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
robot.waitForIdle(1000);
label.repaint();// first paint
robot.waitForIdle(1000);
label.repaint();// incremental paint
robot.waitForIdle(1000);
Point point = label.getLocationOnScreen();
Color color = robot.getPixelColor(point.x + label.getWidth() / 2,
point.y + label.getHeight() / 2);
if (!color.equals(Color.GREEN)) {
System.err.println("Expected color = " + Color.GREEN);
System.err.println("Actual color = " + color);
throw new RuntimeException();
}
frame.dispose();
}
示例9: setupInstance
import java.awt.Frame; //導入方法依賴的package包/類
protected void setupInstance(Frame instance) {
super.setupInstance(instance);
instance.setUndecorated(undecorated);
if (image != null) instance.setIconImage(image);
}
示例10: main
import java.awt.Frame; //導入方法依賴的package包/類
public static void main(final String[] args) {
final GraphicsDevice[] devices =
GraphicsEnvironment.getLocalGraphicsEnvironment()
.getScreenDevices();
if (devices.length < 2 || devices[0].getDisplayModes().length < 2
|| !devices[0].isFullScreenSupported()
|| !devices[1].isFullScreenSupported()) {
System.err.println("Testcase is not applicable");
return;
}
final DisplayMode defaultDM = devices[0].getDisplayMode();
final DisplayMode[] dms = devices[0].getDisplayModes();
DisplayMode nonDefaultDM = null;
for (final DisplayMode dm : dms) {
if (!dm.equals(defaultDM)) {
nonDefaultDM = dm;
break;
}
}
if (nonDefaultDM == null) {
System.err.println("Testcase is not applicable");
return;
}
final Frame frame = new Frame();
frame.setBackground(Color.GREEN);
frame.setUndecorated(true);
try {
devices[0].setFullScreenWindow(frame);
sleep();
devices[0].setDisplayMode(nonDefaultDM);
sleep();
devices[1].setFullScreenWindow(frame);
sleep();
if (!defaultDM.equals(devices[0].getDisplayMode())) {
throw new RuntimeException("DisplayMode is not restored");
}
} finally {
// cleaning up
devices[0].setFullScreenWindow(null);
devices[1].setFullScreenWindow(null);
frame.dispose();
}
}
示例11: main
import java.awt.Frame; //導入方法依賴的package包/類
public static void main(String[] args) throws InterruptedException {
OSInfo.OSType type = OSInfo.getOSType();
if (type != OSInfo.OSType.LINUX && type != OSInfo.OSType.SOLARIS) {
System.out.println("This test is for Solaris and Linux only..." +
"skipping!");
return;
}
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice[] gds = ge.getScreenDevices();
if (gds.length < 2) {
System.out.println("It's a multi-screen test... skipping!");
return;
}
for (int screen = 0; screen < gds.length; ++screen) {
GraphicsDevice gd = gds[screen];
GraphicsConfiguration gc = gd.getDefaultConfiguration();
Rectangle bounds = gc.getBounds();
Insets insets = Toolkit.getDefaultToolkit().getScreenInsets(gc);
Frame frame = new Frame(gc);
frame.setLocation(bounds.x + (bounds.width - SIZE) / 2,
bounds.y + (bounds.height - SIZE) / 2);
frame.setSize(SIZE, SIZE);
frame.setUndecorated(true);
frame.setVisible(true);
// Maximize Frame to reach the struts
frame.setExtendedState(java.awt.Frame.MAXIMIZED_BOTH);
Thread.sleep(2000);
Rectangle frameBounds = frame.getBounds();
frame.dispose();
if (bounds.x + insets.left != frameBounds.x
|| bounds.y + insets.top != frameBounds.y
|| bounds.width - insets.right - insets.left != frameBounds.width
|| bounds.height - insets.bottom - insets.top != frameBounds.height) {
throw new RuntimeException("Test FAILED! Wrong screen #" +
screen + " insets: " + insets);
}
}
System.out.println("Test PASSED!");
}
示例12: main
import java.awt.Frame; //導入方法依賴的package包/類
public static void main(final String[] args) {
final GraphicsDevice[] devices =
GraphicsEnvironment.getLocalGraphicsEnvironment()
.getScreenDevices();
if (devices.length < 2 || devices[0].getDisplayModes().length < 2
|| !devices[0].isFullScreenSupported()
|| !devices[1].isFullScreenSupported()) {
System.err.println("Testcase is not applicable");
return;
}
final DisplayMode defaultDM = devices[0].getDisplayMode();
final DisplayMode[] dms = devices[0].getDisplayModes();
DisplayMode nonDefaultDM = null;
for (final DisplayMode dm : dms) {
if (!dm.equals(defaultDM)) {
nonDefaultDM = dm;
break;
}
}
if (nonDefaultDM == null) {
System.err.println("Testcase is not applicable");
return;
}
try {
robot = new ExtendedRobot();
}catch(Exception ex) {
ex.printStackTrace();
throw new RuntimeException("Unexpected failure");
}
final Frame frame = new Frame();
frame.setBackground(Color.GREEN);
frame.setUndecorated(true);
try {
devices[0].setFullScreenWindow(frame);
sleep();
devices[0].setDisplayMode(nonDefaultDM);
sleep();
devices[1].setFullScreenWindow(frame);
sleep();
if (!defaultDM.equals(devices[0].getDisplayMode())) {
throw new RuntimeException("DisplayMode is not restored");
}
} finally {
// cleaning up
devices[0].setFullScreenWindow(null);
devices[1].setFullScreenWindow(null);
frame.dispose();
}
}
示例13: run
import java.awt.Frame; //導入方法依賴的package包/類
public void run() {
frame = new Frame();
final DragSourceListener dragSourceListener = new DragSourceAdapter() {
public void dragDropEnd(DragSourceDropEvent e) {
dropSuccess = e.getDropSuccess();
System.err.println("Drop was successful: " + dropSuccess);
}
};
DragGestureListener dragGestureListener = new DragGestureListener() {
public void dragGestureRecognized(DragGestureEvent dge) {
dge.startDrag(null, new StringSelection("OK"), dragSourceListener);
}
};
new DragSource().createDefaultDragGestureRecognizer(frame, DnDConstants.ACTION_MOVE,
dragGestureListener);
DropTargetAdapter dropTargetListener = new DropTargetAdapter() {
public void drop(DropTargetDropEvent dtde) {
dtde.acceptDrop(DnDConstants.ACTION_MOVE);
dtde.dropComplete(true);
System.err.println("Drop");
}
};
new DropTarget(frame, dropTargetListener);
//What would normally go into main() will probably go here.
//Use System.out.println for diagnostic messages that you want
//to read after the test is done.
frame.setUndecorated(true);
frame.setBounds(100, 100, 200, 200);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
Robot robot = Util.createRobot();
Util.waitForIdle(robot);
Point startPoint = frame.getLocationOnScreen();
Point endPoint = new Point(startPoint);
startPoint.translate(50, 50);
endPoint.translate(150, 150);
Util.drag(robot, startPoint, endPoint, InputEvent.BUTTON2_MASK);
Util.waitForIdle(robot);
robot.delay(500);
if (dropSuccess) {
System.err.println("test passed");
} else {
throw new RuntimeException("test failed: drop was not successful");
}
}