List of usage examples for java.awt Frame Frame
public Frame() throws HeadlessException
From source file:Main.java
public static void main() { Frame frame = new Frame(); WindowListener listener = new WindowAdapter() { public void windowOpened(WindowEvent evt) { Frame frame = (Frame) evt.getSource(); System.out.println(frame.getTitle()); }//from w w w. j ava 2 s. com public void windowClosing(WindowEvent evt) { Frame frame = (Frame) evt.getSource(); System.out.println(frame.getTitle()); } public void windowClosed(WindowEvent evt) { Frame frame = (Frame) evt.getSource(); System.out.println(frame.getTitle()); } }; frame.addWindowListener(listener); frame.setVisible(true); }
From source file:Main.java
public static void main() { Frame frame = new Frame(); WindowStateListener listener = new WindowAdapter() { public void windowStateChanged(WindowEvent evt) { int oldState = evt.getOldState(); int newState = evt.getNewState(); if ((oldState & Frame.ICONIFIED) == 0 && (newState & Frame.ICONIFIED) != 0) { System.out.println("Frame was iconized"); } else if ((oldState & Frame.ICONIFIED) != 0 && (newState & Frame.ICONIFIED) == 0) { System.out.println("Frame was deiconized"); }//ww w. j ava 2 s . c om if ((oldState & Frame.MAXIMIZED_BOTH) == 0 && (newState & Frame.MAXIMIZED_BOTH) != 0) { System.out.println("Frame was maximized"); } else if ((oldState & Frame.MAXIMIZED_BOTH) != 0 && (newState & Frame.MAXIMIZED_BOTH) == 0) { System.out.println("Frame was minimized"); } } }; frame.addWindowStateListener(listener); frame.setVisible(true); }
From source file:Main.java
public Main(BufferedImage pic) { super(new Frame()); this.pic = pic; addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { System.exit(0);/*w w w . j ava2 s . co m*/ } }); }
From source file:MainClass.java
public MainClass(BufferedImage pic) { super(new Frame()); this.pic = pic; addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { System.exit(0);//from w w w.j a va2 s.c om } }); }
From source file:SplashScreen.java
/** * Create a new splash screen object of the specified image. * The image file is located and referred to through the deployment, not * the local file system; A typical value might be "/com/company/splash.jpg". * /* www . j av a 2 s . c o m*/ * @param imageFileName Name of image file resource to act as splash screen. */ public SplashScreen(String imageFileName) { super(new Frame()); try { Toolkit toolkit = Toolkit.getDefaultToolkit(); URL imageUrl = getClass().getResource(imageFileName); image_ = toolkit.getImage(imageUrl); MediaTracker mediaTracker = new MediaTracker(this); mediaTracker.addImage(image_, 0); mediaTracker.waitForID(0); width_ = image_.getWidth(this); height_ = image_.getHeight(this); Dimension screenSize = toolkit.getScreenSize(); x_ = (screenSize.width - width_) / 2; y_ = (screenSize.height - height_) / 2; } catch (Exception exception) { exception.printStackTrace(); image_ = null; } }
From source file:Win.java
public static Frame findFrameOrMakeFrame(Component parent) { return (parent != null) ? findFrame(parent) : new Frame(); }
From source file:eu.planets_project.tb.impl.data.util.ImageThumbnail.java
/** * Create a reduced jpeg version of an image. The width/height ratio is * preserved.//from www . j a v a 2s .c o m * * @param data * raw data of the image * @param thumbWidth * maximum width of the reduced image * @param thumbHeight * maximum heigth of the reduced image * @param quality * jpeg quality of the reduced image * @param out * produce a reduced jpeg image if the image represented by data * is bigger than the maximum dimensions of the reduced image, * otherwise data is written to this stream */ public static void createThumb(byte[] data, int thumbWidth, int thumbHeight, OutputStream out) throws Exception { // NOTE that this support JPEG, PNG or GIF only. Image image = Toolkit.getDefaultToolkit().createImage(data); MediaTracker mediaTracker = new MediaTracker(new Frame()); int trackID = 0; mediaTracker.addImage(image, trackID); mediaTracker.waitForID(trackID); if (image.getWidth(null) <= thumbWidth && image.getHeight(null) <= thumbHeight) out.write(data); else createThumb(image, thumbWidth, thumbHeight, out); }
From source file:com.tag.FramePreferences.java
@SuppressWarnings("serial") public FramePreferences(final JInternalFrame frame, String pathName) { setFrame(new Frame() { @Override/*from www. jav a2 s . c o m*/ public synchronized int getExtendedState() { if (frame.isMaximum()) { return Frame.MAXIMIZED_BOTH; } else if (frame.isIcon()) { return Frame.ICONIFIED; } else { return Frame.NORMAL; } } @Override public synchronized void setExtendedState(int state) { try { switch (state) { case Frame.MAXIMIZED_HORIZ: case Frame.MAXIMIZED_VERT: case Frame.MAXIMIZED_BOTH: frame.setMaximum(true); break; case Frame.ICONIFIED: frame.setIcon(true); break; case Frame.NORMAL: frame.setIcon(false); frame.setMaximum(false); break; } } catch (PropertyVetoException e) { e.printStackTrace(); } } @Override public synchronized void addWindowStateListener(final WindowStateListener l) { final Frame source = this; frame.addInternalFrameListener(new InternalFrameAdapter() { @Override public void internalFrameIconified(InternalFrameEvent e) { l.windowStateChanged(new WindowEvent(source, WindowEvent.WINDOW_ICONIFIED)); } @Override public void internalFrameDeiconified(InternalFrameEvent e) { l.windowStateChanged(new WindowEvent(source, WindowEvent.WINDOW_DEICONIFIED)); } }); } @Override public synchronized void removeWindowStateListener(WindowStateListener l) { super.removeWindowStateListener(l); } @Override public GraphicsConfiguration getGraphicsConfiguration() { return frame.getGraphicsConfiguration(); } public Point getLocation() { return frame.getLocation(); } @Override public void setLocation(Point p) { frame.setLocation(p); } @Override public Dimension getSize() { return frame.getSize(); } @Override public void setSize(Dimension size) { frame.setSize(size); } @Override public synchronized void addComponentListener(ComponentListener l) { frame.addComponentListener(l); } @Override public synchronized void removeComponentListener(ComponentListener l) { frame.addComponentListener(l); } }); setPathName(pathName); }
From source file:org.pentaho.reporting.engine.classic.core.function.PaintComponentFunction.java
/** * DefaultConstructor.//from w w w . j av a 2 s .c o m */ public PaintComponentFunction() { if (PaintComponentFunction.isHeadless() == false) { peerSupply = new Frame(); peerSupply.setLayout(new BorderLayout()); } this.scale = 1; }
From source file:ustc.sse.rjava.RJavaInterface.java
public String rChooseFile(Rengine re, int newFile) { FileDialog fd = new FileDialog(new Frame(), (newFile == 0) ? "Select a file" : "Select a new file", (newFile == 0) ? FileDialog.LOAD : FileDialog.SAVE); fd.setVisible(true);/*from w ww . j av a 2s .c o m*/ String res = null; if (fd.getDirectory() != null) res = fd.getDirectory(); if (fd.getFile() != null) res = (res == null) ? fd.getFile() : (res + fd.getFile()); return res; }