Search in sources :

Example 1 with JInternalFrame

use of javax.swing.JInternalFrame in project GCViewer by chewiebug.

the class GCViewerGuiInternalFrameController method internalFrameClosing.

@Override
public void internalFrameClosing(InternalFrameEvent e) {
    JInternalFrame internalFrame = e.getInternalFrame();
    internalFrame.removeInternalFrameListener(this);
    internalFrame.getRootPane().remove(internalFrame);
    if (internalFrame.getRootPane().getComponentCount() == 0) {
        getActionMap(e).get(ActionCommands.ARRANGE.toString()).setEnabled(false);
    }
    // remove menuitem from menu and from button group
    JMenu windowMenu = getMenuBar(e).getWindowMenu();
    for (int i = 2; i < windowMenu.getItemCount(); i++) {
        JMenuItem item = windowMenu.getItem(i);
        if (((WindowMenuItemAction) item.getAction()).getInternalFrame() == internalFrame) {
            getMenuBar(e).removeFromWindowMenuGroup(item);
            break;
        }
    }
    // -> otherwise any settings done by the user are lost
    if (getGCViewerGui(e).getDesktopPane().getComponentCount() == 1) {
        updateMenuItemState(e);
        // set same menustate, when the last is closed as is set for deactivated
        internalFrameDeactivated(e);
    }
    // if some thread is still loading, it should stop now
    getSelectedGCDocument(e).getGCResources().stream().forEach(gcResource -> gcResource.setIsReadCancelled(true));
}
Also used : JMenuItem(javax.swing.JMenuItem) JInternalFrame(javax.swing.JInternalFrame) JMenu(javax.swing.JMenu)

Example 2 with JInternalFrame

use of javax.swing.JInternalFrame in project jdk8u_jdk by JetBrains.

the class DimensionEncapsulation method run.

@Override
public void run() {
    runTest(new Panel());
    runTest(new Button());
    runTest(new Checkbox());
    runTest(new Canvas());
    runTest(new Choice());
    runTest(new Label());
    runTest(new Scrollbar());
    runTest(new TextArea());
    runTest(new TextField());
    runTest(new Dialog(new JFrame()));
    runTest(new Frame());
    runTest(new Window(new JFrame()));
    runTest(new FileDialog(new JFrame()));
    runTest(new List());
    runTest(new ScrollPane());
    runTest(new JFrame());
    runTest(new JDialog(new JFrame()));
    runTest(new JWindow(new JFrame()));
    runTest(new JLabel("hi"));
    runTest(new JMenu());
    runTest(new JTree());
    runTest(new JTable());
    runTest(new JMenuItem());
    runTest(new JCheckBoxMenuItem());
    runTest(new JToggleButton());
    runTest(new JSpinner());
    runTest(new JSlider());
    runTest(Box.createVerticalBox());
    runTest(Box.createHorizontalBox());
    runTest(new JTextField());
    runTest(new JTextArea());
    runTest(new JTextPane());
    runTest(new JPasswordField());
    runTest(new JFormattedTextField());
    runTest(new JEditorPane());
    runTest(new JButton());
    runTest(new JColorChooser());
    runTest(new JFileChooser());
    runTest(new JCheckBox());
    runTest(new JInternalFrame());
    runTest(new JDesktopPane());
    runTest(new JTableHeader());
    runTest(new JLayeredPane());
    runTest(new JRootPane());
    runTest(new JMenuBar());
    runTest(new JOptionPane());
    runTest(new JRadioButton());
    runTest(new JRadioButtonMenuItem());
    runTest(new JPopupMenu());
    //runTest(new JScrollBar()); --> don't test defines max and min in
    // terms of preferred
    runTest(new JScrollPane());
    runTest(new JViewport());
    runTest(new JSplitPane());
    runTest(new JTabbedPane());
    runTest(new JToolBar());
    runTest(new JSeparator());
    runTest(new JProgressBar());
    if (!failures.isEmpty()) {
        System.out.println("These classes failed");
        for (final Component failure : failures) {
            System.out.println(failure.getClass());
        }
        throw new RuntimeException("Test failed");
    }
}
Also used : JDesktopPane(javax.swing.JDesktopPane) Choice(java.awt.Choice) JTextArea(javax.swing.JTextArea) TextArea(java.awt.TextArea) JTextArea(javax.swing.JTextArea) Label(java.awt.Label) JLabel(javax.swing.JLabel) JTableHeader(javax.swing.table.JTableHeader) JToggleButton(javax.swing.JToggleButton) JToggleButton(javax.swing.JToggleButton) Button(java.awt.Button) JRadioButton(javax.swing.JRadioButton) JButton(javax.swing.JButton) JFrame(javax.swing.JFrame) Checkbox(java.awt.Checkbox) JDialog(javax.swing.JDialog) FileDialog(java.awt.FileDialog) Dialog(java.awt.Dialog) JTextField(javax.swing.JTextField) TextField(java.awt.TextField) JFormattedTextField(javax.swing.JFormattedTextField) JSlider(javax.swing.JSlider) ArrayList(java.util.ArrayList) List(java.awt.List) Canvas(java.awt.Canvas) JWindow(javax.swing.JWindow) JRadioButtonMenuItem(javax.swing.JRadioButtonMenuItem) JOptionPane(javax.swing.JOptionPane) JCheckBoxMenuItem(javax.swing.JCheckBoxMenuItem) JCheckBox(javax.swing.JCheckBox) JTree(javax.swing.JTree) JFileChooser(javax.swing.JFileChooser) JPasswordField(javax.swing.JPasswordField) ScrollPane(java.awt.ScrollPane) JScrollPane(javax.swing.JScrollPane) JTable(javax.swing.JTable) JSpinner(javax.swing.JSpinner) JSplitPane(javax.swing.JSplitPane) JColorChooser(javax.swing.JColorChooser) JInternalFrame(javax.swing.JInternalFrame) JDialog(javax.swing.JDialog) JFrame(javax.swing.JFrame) Frame(java.awt.Frame) JInternalFrame(javax.swing.JInternalFrame) JRadioButton(javax.swing.JRadioButton) JLayeredPane(javax.swing.JLayeredPane) JTabbedPane(javax.swing.JTabbedPane) JButton(javax.swing.JButton) JProgressBar(javax.swing.JProgressBar) JTextField(javax.swing.JTextField) JSeparator(javax.swing.JSeparator) JTextPane(javax.swing.JTextPane) JMenuItem(javax.swing.JMenuItem) Component(java.awt.Component) Scrollbar(java.awt.Scrollbar) Window(java.awt.Window) JWindow(javax.swing.JWindow) JScrollPane(javax.swing.JScrollPane) JViewport(javax.swing.JViewport) JFormattedTextField(javax.swing.JFormattedTextField) JLabel(javax.swing.JLabel) JToolBar(javax.swing.JToolBar) JPopupMenu(javax.swing.JPopupMenu) Panel(java.awt.Panel) JEditorPane(javax.swing.JEditorPane) JRootPane(javax.swing.JRootPane) FileDialog(java.awt.FileDialog) JMenu(javax.swing.JMenu) JMenuBar(javax.swing.JMenuBar)

Example 3 with JInternalFrame

use of javax.swing.JInternalFrame in project jdk8u_jdk by JetBrains.

the class bug8020708 method testInternalFrameMnemonic.

static void testInternalFrameMnemonic() throws Exception {
    SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
    Robot robot = new Robot();
    robot.setAutoDelay(50);
    SwingUtilities.invokeAndWait(new Runnable() {

        @Override
        public void run() {
            frame = new JFrame("Test");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.setSize(300, 200);
            JDesktopPane desktop = new JDesktopPane();
            internalFrame = new JInternalFrame("Test");
            internalFrame.setSize(200, 100);
            internalFrame.setClosable(true);
            desktop.add(internalFrame);
            internalFrame.setVisible(true);
            internalFrame.setMaximizable(true);
            frame.getContentPane().add(desktop);
            frame.setVisible(true);
        }
    });
    toolkit.realSync();
    Point clickPoint = Util.getCenterPoint(internalFrame);
    robot.mouseMove(clickPoint.x, clickPoint.y);
    robot.mousePress(InputEvent.BUTTON1_MASK);
    robot.mouseRelease(InputEvent.BUTTON1_MASK);
    toolkit.realSync();
    Util.hitKeys(robot, KeyEvent.VK_CONTROL, KeyEvent.VK_SPACE);
    toolkit.realSync();
    Util.hitKeys(robot, KeyEvent.VK_C);
    toolkit.realSync();
    SwingUtilities.invokeAndWait(new Runnable() {

        @Override
        public void run() {
            if (internalFrame.isVisible()) {
                throw new RuntimeException("Close mnemonic does not work");
            }
            frame.dispose();
        }
    });
}
Also used : JDesktopPane(javax.swing.JDesktopPane) JFrame(javax.swing.JFrame) SunToolkit(sun.awt.SunToolkit) Point(java.awt.Point) Robot(java.awt.Robot) JInternalFrame(javax.swing.JInternalFrame)

Example 4 with JInternalFrame

use of javax.swing.JInternalFrame in project ats-framework by Axway.

the class SwingElementLocator method getContainerFixture.

/**
     * Change container by specified name or title.
     * For internal use
     * @param driver
     * @param containerProperties property with name inside
     * @return the {@link ContainerFinxture}
     */
public static ContainerFixture<?> getContainerFixture(SwingDriverInternal driver, UiElementProperties containerProperties) {
    String containerName = containerProperties.getProperty("name");
    final String containerTitle = containerProperties.getProperty("title");
    if (StringUtils.isNullOrEmpty(containerName) && StringUtils.isNullOrEmpty(containerTitle)) {
        throw new IllegalArgumentException("Illegal name/title (empty/null string) passed to search for container");
    }
    ContainerFixture<?> containerFixture = driver.getActiveContainerFixture();
    ContainerFixture<?> windowsFixture = driver.getWindowFixture();
    Robot robot = null;
    if (containerFixture != null) {
        // use the current robot instance
        robot = containerFixture.robot;
    } else {
        robot = BasicRobot.robotWithCurrentAwtHierarchy();
    }
    if (!StringUtils.isNullOrEmpty(containerName)) {
        try {
            Container cont = BasicComponentFinder.finderWithCurrentAwtHierarchy().findByName(windowsFixture.component(), containerName, Container.class);
            return new ContainerFixture<Container>(robot, cont) {
            };
        } catch (WaitTimedOutError wtoe) {
            throw new ElementNotFoundException("Unable to find container with name '" + containerName + "' under current window/dialog. If needed change current window first with swingEngineInstance.setActiveWindow()");
        }
    } else {
        try {
            Container cont = BasicComponentFinder.finderWithCurrentAwtHierarchy().find(windowsFixture.component(), new GenericTypeMatcher<Container>(Container.class, true) {

                @Override
                protected boolean isMatching(Container component) {
                    if (component instanceof Dialog) {
                        return ((Dialog) component).getTitle().equals(containerTitle);
                    } else if (component instanceof Frame) {
                        return ((Frame) component).getTitle().equals(containerTitle);
                    } else if (component instanceof JInternalFrame) {
                        return ((JInternalFrame) component).getTitle().equals(containerTitle);
                    }
                    return false;
                }
            });
            return new ContainerFixture<Container>(robot, cont) {
            };
        } catch (WaitTimedOutError wtoe) {
            throw new ElementNotFoundException("Unable to find container with title '" + containerName + "' under current window/dialog. If needed change current window first with swingEngineInstance.setActiveWindow()");
        }
    }
}
Also used : Frame(java.awt.Frame) JInternalFrame(javax.swing.JInternalFrame) ElementNotFoundException(com.axway.ats.uiengine.exceptions.ElementNotFoundException) WaitTimedOutError(org.fest.swing.exception.WaitTimedOutError) Container(java.awt.Container) Dialog(java.awt.Dialog) ContainerFixture(org.fest.swing.fixture.ContainerFixture) Robot(org.fest.swing.core.Robot) BasicRobot(org.fest.swing.core.BasicRobot) JInternalFrame(javax.swing.JInternalFrame)

Example 5 with JInternalFrame

use of javax.swing.JInternalFrame in project JMRI by JMRI.

the class TableFrames method openBlockPathFrame.

protected void openBlockPathFrame(String sysName) {
    JInternalFrame frame = _blockPathMap.get(sysName);
    if (frame == null) {
        OBlock block = InstanceManager.getDefault(jmri.jmrit.logix.OBlockManager.class).getBySystemName(sysName);
        if (block == null) {
            return;
        }
        frame = makeBlockPathFrame(block);
        _blockPathMap.put(sysName, frame);
        frame.setVisible(true);
        _desktop.add(frame);
        frame.moveToFront();
    } else {
        frame.setVisible(true);
        try {
            frame.setIcon(false);
        } catch (PropertyVetoException pve) {
            log.warn("BlockPath Table Frame for \"" + sysName + "\" vetoed setIcon " + pve.toString());
        }
        frame.moveToFront();
    }
}
Also used : PropertyVetoException(java.beans.PropertyVetoException) OBlockManager(jmri.jmrit.logix.OBlockManager) JInternalFrame(javax.swing.JInternalFrame) OBlock(jmri.jmrit.logix.OBlock)

Aggregations

JInternalFrame (javax.swing.JInternalFrame)36 Point (java.awt.Point)12 PropertyVetoException (java.beans.PropertyVetoException)12 Dimension (java.awt.Dimension)9 Component (java.awt.Component)7 JPanel (javax.swing.JPanel)7 JScrollPane (javax.swing.JScrollPane)7 JTable (javax.swing.JTable)7 BorderLayout (java.awt.BorderLayout)6 JButton (javax.swing.JButton)6 JLabel (javax.swing.JLabel)6 JComponent (javax.swing.JComponent)5 JMenu (javax.swing.JMenu)4 Jynstrument (jmri.jmrit.jython.Jynstrument)4 Container (java.awt.Container)3 JDesktopPane (javax.swing.JDesktopPane)3 JMenuBar (javax.swing.JMenuBar)3 JMenuItem (javax.swing.JMenuItem)3 TableRowSorter (javax.swing.table.TableRowSorter)3 ButtonEditor (jmri.util.table.ButtonEditor)3