Search in sources :

Example 46 with WindowEvent

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

the class VOnlyCurrentDays method jbInit.

/**
	 * 	Static Initializer
	 * 	@throws Exception
	 */
private void jbInit() throws Exception {
    this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    bShowAll.setText(Msg.getMsg(Env.getCtx(), "All"));
    bShowAll.addActionListener(this);
    bShowAll.setMargin(s_margin);
    bShowYear.setText(Msg.getMsg(Env.getCtx(), "Year"));
    bShowYear.addActionListener(this);
    bShowYear.setMargin(s_margin);
    bShowMonth.setText(Msg.getMsg(Env.getCtx(), "Month"));
    bShowMonth.addActionListener(this);
    bShowMonth.setMargin(s_margin);
    bShowWeek.setText(Msg.getMsg(Env.getCtx(), "Week"));
    bShowWeek.addActionListener(this);
    bShowWeek.setMargin(s_margin);
    bShowDay.setText(Msg.getMsg(Env.getCtx(), "Day"));
    bShowDay.addActionListener(this);
    bShowDay.setMargin(s_margin);
    bShowDay.setDefaultCapable(true);
    //
    mainPanel.add(bShowDay, null);
    mainPanel.add(bShowWeek, null);
    mainPanel.add(bShowMonth, null);
    mainPanel.add(bShowYear, null);
    mainPanel.add(bShowAll, null);
    //
    mainPanel.setToolTipText(Msg.getMsg(Env.getCtx(), "VOnlyCurrentDays", false));
    this.getContentPane().add(mainPanel, BorderLayout.CENTER);
    this.getRootPane().setDefaultButton(bShowDay);
    // 
    addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent e) {
            m_isCancel = true;
        }
    });
}
Also used : WindowEvent(java.awt.event.WindowEvent) WindowAdapter(java.awt.event.WindowAdapter)

Example 47 with WindowEvent

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

the class VPOS method init.

@Override
public void init(int WindowNo, FormFrame frame) {
    this.frame = frame.getCFrame();
    this.frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
    this.frame.setResizable(true);
    //	
    logger.info("init - SalesRep_ID=" + Env.getAD_User_ID(getCtx()));
    setWindowNo(WindowNo);
    frame.setJMenuBar(null);
    if (!loadPOS()) {
        EventQueue.invokeLater(new Runnable() {

            public void run() {
                CFrame closeFrame = frame.getCFrame();
                closeFrame.dispatchEvent(new WindowEvent(closeFrame, WindowEvent.WINDOW_CLOSING));
                dispose();
            }
        });
        return;
    }
    userPinListener = new POSUserPinListener(this);
    //Delay 5 seconds by default
    userPinTimer = new javax.swing.Timer((getPINEntryTimeout() + 10) * 1000, userPinListener);
    if (isPresentElectronicScales()) {
        scalesListener = new POSScalesListener(this);
        scalesTimer = new javax.swing.Timer(400, scalesListener);
    }
    isCorrectUserPin = null;
    settingKeyboardFocusManager();
    if (getM_POS() == null) {
        if (this.frame != null)
            this.frame.dispose();
        return;
    }
    //
    try {
        if (!dynInit()) {
            dispose();
            return;
        }
        //	Add to frame
        frame.getContentPane().add(mainPanel, BorderLayout.CENTER);
    } catch (AdempierePOSException exception) {
        ADialog.error(getWindowNo(), this.frame, exception.getLocalizedMessage());
        dispose();
        return;
    }
    logger.config("PosPanel.init - " + mainPanel.getPreferredSize());
    if (getAutoLogoutDelay() > 0 && logoutTimer == null) {
        logoutTimer = new javax.swing.Timer(1000, new ActionListener() {

            PointerInfo pi = null;

            long lastMouseMove = System.currentTimeMillis();

            long lastKeyboardEvent = System.currentTimeMillis();

            public void actionPerformed(ActionEvent actionEvent) {
                try {
                    long now = actionEvent.getWhen();
                    PointerInfo newPi = MouseInfo.getPointerInfo();
                    // mouse moved
                    if (newPi != null && pi != null && !pi.getLocation().equals(newPi.getLocation())) {
                        lastMouseMove = now;
                    }
                    pi = newPi;
                    if (isVirtualKeyboard())
                        lastKeyboardEvent = focusManager.getLastWhen();
                    else
                        lastKeyboardEvent = 0;
                    if (getAutoLogoutDelay() * 1000 < now - Math.max(lastKeyboardEvent, lastMouseMove)) {
                    //	new PosLogin(this);
                    }
                } catch (AdempiereException exception) {
                    ADialog.error(getWindowNo(), getFrame(), exception.getLocalizedMessage());
                }
            }
        });
        logoutTimer.start();
    }
    if (isVirtualKeyboard())
        focusManager.start();
}
Also used : ActionEvent(java.awt.event.ActionEvent) CFrame(org.compiere.swing.CFrame) PointerInfo(java.awt.PointerInfo) ActionListener(java.awt.event.ActionListener) AdempiereException(org.adempiere.exceptions.AdempiereException) WindowEvent(java.awt.event.WindowEvent) Timer(javax.swing.Timer)

Example 48 with WindowEvent

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

the class Find method jbInit.

/**
	 *	Static Init.
	 *  <pre>
	 *  tabbedPane
	 *      simplePanel
	 *          scontentPanel
	 *          confirmPanelS
	 *      advancedPanel
	 *          toolBar
	 *          GC
	 *          confirmPanelA
	 *  southPanel
	 *      statusBar
	 *  </pre>
	 *  @throws Exception
	 */
private void jbInit() throws Exception {
    spaceE = Box.createHorizontalStrut(8);
    spaceN = Box.createVerticalStrut(8);
    spaceW = Box.createHorizontalStrut(8);
    spaceS = Box.createVerticalStrut(8);
    bIgnore.setIcon(new ImageIcon(org.compiere.Adempiere.class.getResource("images/Ignore24.gif")));
    bIgnore.setMargin(new Insets(2, 2, 2, 2));
    bIgnore.setToolTipText(Msg.getMsg(Env.getCtx(), "Ignore"));
    bIgnore.addActionListener(this);
    fQueryName.setToolTipText(m_sToolTipText);
    fQueryName.setEditable(true);
    fQueryName.addActionListener(this);
    fQueryName.getEditor().getEditorComponent().addFocusListener(new FocusListener() {

        public void focusGained(FocusEvent arg0) {
            // fQueryName received the focus - delete the tip text so the user can type without 
            // having to delete the tip.
            int index = fQueryName.getSelectedIndex();
            if (index < 0) {
                if (fQueryName.getSelectedItem() == null || fQueryName.getSelectedItem().equals(m_sTipText)) {
                    fQueryName.setSelectedIndex(-1);
                    fQueryName.setSelectedItem("");
                }
            }
        }

        public void focusLost(FocusEvent arg0) {
            // fQueryName lost the focus. If the field is blank, replace the tip text.
            if (fQueryName.getSelectedItem() != null && fQueryName.getSelectedItem().equals("")) {
                fQueryName.setSelectedItem(m_sTipText);
            }
        }
    });
    bSave.setIcon(new ImageIcon(org.compiere.Adempiere.class.getResource("images/Save24.gif")));
    bSave.setMargin(new Insets(2, 2, 2, 2));
    bSave.setToolTipText(Msg.getMsg(Env.getCtx(), "Save"));
    bSave.addActionListener(this);
    bNew.setIcon(new ImageIcon(org.compiere.Adempiere.class.getResource("images/New24.gif")));
    bNew.setMargin(new Insets(2, 2, 2, 2));
    bNew.setToolTipText(Msg.getMsg(Env.getCtx(), "New"));
    bNew.addActionListener(this);
    bDelete.setIcon(new ImageIcon(org.compiere.Adempiere.class.getResource("images/Delete24.gif")));
    bDelete.setMargin(new Insets(2, 2, 2, 2));
    bDelete.setToolTipText(Msg.getMsg(Env.getCtx(), "Delete"));
    bDelete.addActionListener(this);
    //
    southPanel.setLayout(southLayout);
    valueLabel.setLabelFor(valueField);
    valueLabel.setText(Msg.translate(Env.getCtx(), "Value"));
    nameLabel.setLabelFor(nameField);
    nameLabel.setText(Msg.translate(Env.getCtx(), "Name"));
    descriptionLabel.setLabelFor(descriptionField);
    descriptionLabel.setText(Msg.translate(Env.getCtx(), "Description"));
    valueField.setText("%");
    valueField.setColumns(FIELDLENGTH);
    nameField.setText("%");
    nameField.setColumns(FIELDLENGTH);
    descriptionField.setText("%");
    descriptionField.setColumns(FIELDLENGTH);
    scontentPanel.setToolTipText(Msg.getMsg(Env.getCtx(), "FindTip"));
    docNoLabel.setLabelFor(docNoField);
    docNoLabel.setText(Msg.translate(Env.getCtx(), "DocumentNo"));
    docNoField.setText("%");
    docNoField.setColumns(FIELDLENGTH);
    advancedScrollPane.setPreferredSize(new Dimension(540, 410));
    southPanel.add(statusBar, BorderLayout.SOUTH);
    this.getContentPane().add(southPanel, BorderLayout.SOUTH);
    //
    scontentPanel.setLayout(scontentLayout);
    simplePanel.setLayout(simpleLayout);
    simplePanel.add(confirmPanelS, BorderLayout.SOUTH);
    simplePanel.add(scontentPanel, BorderLayout.CENTER);
    scontentPanel.add(valueLabel, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(7, 5, 0, 5), 0, 0));
    scontentPanel.add(nameLabel, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(7, 5, 0, 5), 0, 0));
    scontentPanel.add(descriptionLabel, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(7, 5, 5, 5), 0, 0));
    scontentPanel.add(valueField, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 0, 5), 0, 0));
    scontentPanel.add(descriptionField, new GridBagConstraints(2, 4, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 5), 0, 0));
    scontentPanel.add(docNoLabel, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(7, 5, 0, 5), 0, 0));
    scontentPanel.add(nameField, new GridBagConstraints(2, 3, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 0, 5), 0, 0));
    scontentPanel.add(docNoField, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 0, 5), 0, 0));
    //
    scontentPanel.add(spaceE, new GridBagConstraints(3, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(10, 10, 10, 10), 0, 0));
    scontentPanel.add(spaceN, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(10, 10, 10, 10), 0, 0));
    scontentPanel.add(spaceW, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(10, 10, 10, 10), 0, 0));
    scontentPanel.add(spaceS, new GridBagConstraints(2, 15, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(10, 10, 10, 10), 0, 0));
    //
    //	tabbedPane.add(simplePanel, Msg.getMsg(Env.getCtx(),"Find"));
    tabbedPane.add(simplePanel, Msg.getMsg(Env.getCtx(), "Find"));
    //
    toolBar.add(bIgnore, null);
    toolBar.addSeparator();
    toolBar.add(bNew, null);
    toolBar.add(bDelete, null);
    toolBar.add(fQueryName, null);
    toolBar.add(bSave, null);
    advancedPanel.setLayout(advancedLayout);
    advancedPanel.add(toolBar, BorderLayout.NORTH);
    advancedPanel.add(confirmPanelA, BorderLayout.SOUTH);
    advancedPanel.add(advancedScrollPane, BorderLayout.CENTER);
    advancedScrollPane.getViewport().add(advancedTable, null);
    //	tabbedPane.add(advancedPanel, Msg.getMsg(Env.getCtx(),"Advanced"));
    tabbedPane.add(advancedPanel, Msg.getMsg(Env.getCtx(), "Advanced"));
    //
    this.getContentPane().add(tabbedPane, BorderLayout.CENTER);
    //
    confirmPanelA.addActionListener(this);
    confirmPanelS.addActionListener(this);
    //
    JButton b = ConfirmPanel.createNewButton(true);
    confirmPanelS.addComponent(b);
    b.addActionListener(this);
    // teo_sarca, [ 1670847 ] Find dialog: closing and canceling need same functionality
    addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent e) {
            cmd_cancel();
        }
    });
}
Also used : ImageIcon(javax.swing.ImageIcon) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) WindowEvent(java.awt.event.WindowEvent) JButton(javax.swing.JButton) WindowAdapter(java.awt.event.WindowAdapter) Dimension(java.awt.Dimension) FocusListener(java.awt.event.FocusListener) FocusEvent(java.awt.event.FocusEvent)

Example 49 with WindowEvent

use of java.awt.event.WindowEvent in project poi by apache.

the class POIBrowser method run.

protected void run(String[] args) {
    addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    });
    /* Create the tree model with a root node. The latter is
         * invisible but it must be present because a tree model
         * always needs a root. */
    rootNode = new DefaultMutableTreeNode("POI Filesystems");
    DefaultTreeModel treeModel = new DefaultTreeModel(rootNode);
    /* Create the tree UI element. */
    final JTree treeUI = new JTree(treeModel);
    getContentPane().add(new JScrollPane(treeUI));
    /* Add the POI filesystems to the tree. */
    int displayedFiles = 0;
    for (int i = 0; i < args.length; i++) {
        final String filename = args[i];
        try {
            FileInputStream fis = new FileInputStream(filename);
            POIFSReader r = new POIFSReader();
            r.registerListener(new TreeReaderListener(filename, rootNode));
            r.read(fis);
            fis.close();
            displayedFiles++;
        } catch (IOException ex) {
            System.err.println(filename + ": " + ex);
        } catch (Exception t) {
            System.err.println("Unexpected exception while reading \"" + filename + "\":");
            t.printStackTrace(System.err);
        }
    }
    /* Exit if there is no file to display (none specified or only
         * files with problems). */
    if (displayedFiles == 0) {
        System.out.println("No POI filesystem(s) to display.");
        System.exit(0);
    }
    /* Make the tree UI element visible. */
    treeUI.setRootVisible(true);
    treeUI.setShowsRootHandles(true);
    ExtendableTreeCellRenderer etcr = new ExtendableTreeCellRenderer();
    etcr.register(DocumentDescriptor.class, new DocumentDescriptorRenderer());
    etcr.register(PropertySetDescriptor.class, new PropertySetDescriptorRenderer());
    treeUI.setCellRenderer(etcr);
    setSize(600, 450);
    setTitle("POI Browser 0.09");
    setVisible(true);
}
Also used : JScrollPane(javax.swing.JScrollPane) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) WindowAdapter(java.awt.event.WindowAdapter) DefaultTreeModel(javax.swing.tree.DefaultTreeModel) IOException(java.io.IOException) FileInputStream(java.io.FileInputStream) IOException(java.io.IOException) JTree(javax.swing.JTree) WindowEvent(java.awt.event.WindowEvent) POIFSReader(org.apache.poi.poifs.eventfilesystem.POIFSReader)

Example 50 with WindowEvent

use of java.awt.event.WindowEvent in project joda-time by JodaOrg.

the class DateTimeBrowser method go.

// usage
/*
     * go This method reads the file, creates the table to display,
     * the window to display it in, and displays the window.
     * @param fileName the name of the file to read.
     * @param tryLines An estimate of the number of lines in
     * the file.
     */
private void go(String[] args) {
    mainArgs = args;
    // let user override if needed
    setDefaultTimeZone();
    // setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    //
    JMenuBar menuBar = new JMenuBar();
    setJMenuBar(menuBar);
    addMenus(menuBar);
    /*
         * Add a fast close listener
         */
    addWindowListener(new WindowAdapter() {

        public void windowClosing(WindowEvent e) {
            setVisible(false);
            dispose();
            System.exit(0);
        }
    });
    //
    // Load current file, prime tables and JFrame.
    //
    currFile = new LoadedFile(mainArgs[0]);
    TableView tView = getDefaultTableView();
    resetDefaults(tView);
    //
    // Set max size at start, and display the window.
    //
    Dimension screenMax = Toolkit.getDefaultToolkit().getScreenSize();
    setSize(screenMax);
    setVisible(true);
}
Also used : WindowEvent(java.awt.event.WindowEvent) WindowAdapter(java.awt.event.WindowAdapter) Dimension(java.awt.Dimension) JMenuBar(javax.swing.JMenuBar)

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