Search in sources :

Example 11 with WindowEvent

use of java.awt.event.WindowEvent in project processing by processing.

the class JavaTextAreaPainter method stopTweakMode.

protected void stopTweakMode() {
    tweakMode = false;
    if (colorSelector != null) {
        colorSelector.hide();
        WindowEvent windowEvent = new WindowEvent(colorSelector.frame, WindowEvent.WINDOW_CLOSING);
        colorSelector.frame.dispatchEvent(windowEvent);
    }
    setCursor(new Cursor(Cursor.TEXT_CURSOR));
    repaint();
}
Also used : WindowEvent(java.awt.event.WindowEvent) Cursor(java.awt.Cursor)

Example 12 with WindowEvent

use of java.awt.event.WindowEvent in project AozoraEpub3 by hmdev.

the class AozoraEpub3Applet method main.

////////////////////////////////////////////////////////////////
// JFrame
////////////////////////////////////////////////////////////////
/** Jar実行用 */
public static void main(String[] args) {
    //LookAndFeel変更
    try {
        String lafName = UIManager.getSystemLookAndFeelClassName();
        //lafName = "";
        if (lafName.startsWith("com.sun.java.swing.plaf.windows.")) {
            UIManager.setLookAndFeel(lafName);
        } else {
            //Windows以外はMetalのままでFontはPLAIN
            UIDefaults defaultTable = UIManager.getLookAndFeelDefaults();
            for (Object o : defaultTable.keySet()) {
                if (o.toString().toLowerCase().endsWith("font")) {
                    FontUIResource font = (FontUIResource) UIManager.get(o);
                    font = new FontUIResource(font.getName(), Font.PLAIN, font.getSize());
                    UIManager.put(o, font);
                }
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    //フレーム初期化
    final JFrame jFrame = new JFrame("AozoraEpub3");
    //アップレット生成と初期化
    final AozoraEpub3Applet applet = new AozoraEpub3Applet(jFrame);
    applet.iconImage = java.awt.Toolkit.getDefaultToolkit().createImage(AozoraEpub3Applet.class.getResource("images/icon.png"));
    applet.init();
    //アイコン設定
    jFrame.setIconImage(applet.iconImage);
    //最小サイズ
    jFrame.setMinimumSize(new Dimension(520, 320));
    jFrame.setPreferredSize(new Dimension(520, 400));
    try {
        int x = (int) Float.parseFloat(applet.props.getProperty("PosX"));
        int y = (int) Float.parseFloat(applet.props.getProperty("PosY"));
        jFrame.setLocation(x, y);
    } catch (Exception e) {
    }
    jFrame.setSize(applet.getSize());
    try {
        int w = (int) Float.parseFloat(applet.props.getProperty("SizeW"));
        int h = (int) Float.parseFloat(applet.props.getProperty("SizeH"));
        jFrame.setSize(w, h);
    } catch (Exception e) {
    }
    jFrame.addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent evt) {
            try {
                //Window位置を割くに設定しておく
                Point location = jFrame.getLocation();
                Dimension size = jFrame.getSize();
                applet.props.setProperty("PosX", "" + location.getX());
                applet.props.setProperty("PosY", "" + location.getY());
                applet.props.setProperty("SizeW", "" + size.getWidth());
                applet.props.setProperty("SizeH", "" + size.getHeight());
                //props保存と終了処理
                applet.finalize();
            } catch (Throwable e) {
                e.printStackTrace();
            }
            System.exit(0);
        }
    });
    jFrame.add(applet);
    jFrame.setVisible(true);
    //引数にファイルが指定されていたら変換実行
    for (String fileName : args) {
        File file = new File(fileName);
        Vector<File> vecFiles = new Vector<File>();
        if (file.exists())
            vecFiles.add(file);
        if (vecFiles.size() > 0) {
            File[] files = new File[vecFiles.size()];
            for (int i = 0; i < files.length; i++) files[i] = vecFiles.get(i);
            applet.startConvertWorker(vecFiles, null, null, null);
        }
    }
    //Focus
    applet.jTabbedPane.requestFocus();
}
Also used : UIDefaults(javax.swing.UIDefaults) FontUIResource(javax.swing.plaf.FontUIResource) WindowAdapter(java.awt.event.WindowAdapter) Dimension(java.awt.Dimension) Point(java.awt.Point) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) Point(java.awt.Point) JFrame(javax.swing.JFrame) WindowEvent(java.awt.event.WindowEvent) File(java.io.File) Vector(java.util.Vector)

Example 13 with WindowEvent

use of java.awt.event.WindowEvent in project jreversepro by akkumar.

the class GUIMain method addListeners.

/**
   * Method to add property listeners to MenuItems and the MainFrame.
   */
private void addListeners() {
    mMbrGen.onFileOpen.addActionListener(this);
    mMbrGen.onFileSave.addActionListener(this);
    mMbrGen.onFileExit.addActionListener(this);
    mMbrGen.onEditCut.addActionListener(this);
    mMbrGen.onEditCopy.addActionListener(this);
    mMbrGen.onViewCPool.addActionListener(this);
    mMbrGen.onOptFont.addActionListener(this);
    mMbrGen.onHelpAbout.addActionListener(this);
    addWindowListener(new WindowAdapter() {

        /**
       * WindowClosing event handler.
       * 
       * @param aEvent
       *          Event generated.
       */
        @Override
        public void windowClosing(WindowEvent aEvent) {
            appClose();
            super.windowClosing(aEvent);
        }
    });
}
Also used : WindowEvent(java.awt.event.WindowEvent) WindowAdapter(java.awt.event.WindowAdapter)

Example 14 with WindowEvent

use of java.awt.event.WindowEvent in project qi4j-sdk by Qi4j.

the class Envisage method showMainFrame.

private void showMainFrame() {
    mainFrame = new EnvisageFrame(application);
    mainFrame.setLocationByPlatform(true);
    mainFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    mainFrame.setSize(new Dimension(1024, 768));
    mainFrame.setVisible(true);
    mainFrame.addWindowListener(new WindowAdapter() {

        @Override
        public void windowOpened(WindowEvent evt) {
            SwingUtilities.invokeLater(new Runnable() {

                @Override
                public void run() {
                    mainFrame.initQi4J();
                }
            });
        }
    });
}
Also used : WindowEvent(java.awt.event.WindowEvent) WindowAdapter(java.awt.event.WindowAdapter) Dimension(java.awt.Dimension)

Example 15 with WindowEvent

use of java.awt.event.WindowEvent in project L42 by ElvisResearchGroup.

the class Frame method createNew.

private static Frame createNew(String wName, String html, int x, int y) {
    FutureTask<Frame> future = new FutureTask<>(() -> {
        final Frame frame = new Frame(Frame.extractTitle(html));
        JFXPanel jfxPanel = new JFXPanel();
        frame.createHtmlContent(jfxPanel, html);
        frame.getContentPane().add(jfxPanel);
        frame.setMinimumSize(new Dimension(x, y));
        frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        frame.addWindowListener(new WindowAdapter() {

            public void windowClosing(WindowEvent e) {
                Frame.close(wName);
            }
        });
        frame.setVisible(true);
        return frame;
    });
    SwingUtilities.invokeLater(future);
    try {
        return future.get();
    } catch (ExecutionException e) {
        throw propagateException(e.getCause());
    } catch (InterruptedException e) {
        throw propagateException(e);
    }
}
Also used : JFrame(javax.swing.JFrame) JFXPanel(javafx.embed.swing.JFXPanel) FutureTask(java.util.concurrent.FutureTask) WindowEvent(java.awt.event.WindowEvent) WindowAdapter(java.awt.event.WindowAdapter) Dimension(java.awt.Dimension) ExecutionException(java.util.concurrent.ExecutionException)

Aggregations

WindowEvent (java.awt.event.WindowEvent)201 WindowAdapter (java.awt.event.WindowAdapter)140 JPanel (javax.swing.JPanel)44 JButton (javax.swing.JButton)40 JFrame (javax.swing.JFrame)40 BorderLayout (java.awt.BorderLayout)36 ActionEvent (java.awt.event.ActionEvent)34 Dimension (java.awt.Dimension)32 JLabel (javax.swing.JLabel)30 JScrollPane (javax.swing.JScrollPane)26 ActionListener (java.awt.event.ActionListener)25 GridBagConstraints (java.awt.GridBagConstraints)19 GridBagLayout (java.awt.GridBagLayout)19 FlowLayout (java.awt.FlowLayout)18 Frame (java.awt.Frame)15 Insets (java.awt.Insets)15 JDialog (javax.swing.JDialog)13 JTextArea (javax.swing.JTextArea)13 Container (java.awt.Container)12 WindowListener (java.awt.event.WindowListener)10