Example usage for javax.swing JInternalFrame setSize

List of usage examples for javax.swing JInternalFrame setSize

Introduction

In this page you can find the example usage for javax.swing JInternalFrame setSize.

Prototype

public void setSize(Dimension d) 

Source Link

Document

Resizes this component so that it has width d.width and height d.height .

Usage

From source file:Main.java

/**
 * Creates (and displays) a JInternalFrame for a specified component. <br />
 * The size of the JInternalFrame will be <code>frameSize</code>. <br />
 * The frame is <i>just</i> closeable. <br />
 * /*from   w  w w  .j a  v a 2 s .  co m*/
 * @param desktop the JDesktopPane
 * @param comp the component to display in the created frame
 * @param title the title of the frame
 * @param frameSize the size of the frame
 * @return the created and displayed frame
 */
public static JInternalFrame showInternalFrame(JDesktopPane desktop, JComponent comp, String title,
        Dimension frameSize) {
    JInternalFrame frm = new JInternalFrame(title);
    frm.setClosable(true);
    frm.setLayout(new BorderLayout());
    frm.add(comp, BorderLayout.CENTER);
    frm.setSize(frameSize);
    frm.setVisible(true);

    Dimension size = frm.getSize();
    frm.setLocation(desktop.getWidth() / 2 - size.width / 2, desktop.getHeight() / 2 - size.height / 2);
    desktop.add(frm, 0);

    try {
        frm.setSelected(true);
    } catch (java.beans.PropertyVetoException e) {
    }

    return frm;
}

From source file:Main.java

/**
 * Shows a specified JInternalFrame in the middle of the specified JDesktopPane. <br />
 * The size of the JInternalFrame will be <code>frameSize</code>. <br />
 * The frame is <i>just</i> closeable. <br />
 * /*from w w  w  .  j  av a  2 s . c  o m*/
 * @param desktop the JDesktopPane
 * @param frm the JInternalFrame
 * @param content the component which will be added to the JInternalFrame
 * @param frameSize the size of the JInternalFrame
 */
public static void showInternalFrame(JDesktopPane desktop, JInternalFrame frm, JComponent content,
        Dimension frameSize) {
    frm.setClosable(true);
    frm.setLayout(new BorderLayout());
    frm.add(content, BorderLayout.CENTER);
    frm.setSize(frameSize);
    frm.setVisible(true);

    Dimension size = frm.getSize();
    frm.setLocation(desktop.getWidth() / 2 - size.width / 2, desktop.getHeight() / 2 - size.height / 2);
    desktop.add(frm, 0);

    try {
        frm.setSelected(true);
    } catch (java.beans.PropertyVetoException e) {
    }
}

From source file:de.codesourcery.jasm16.ide.ui.viewcontainers.Perspective.java

@Override
public IView addView(final IView view) {
    if (view == null) {
        throw new IllegalArgumentException("view must not be NULL");
    }//from  w w  w  .  ja v a 2  s.c om
    final JInternalFrame internalFrame = new JInternalFrame(view.getTitle(), true, true, true, true);

    internalFrame.setBackground(Color.BLACK);
    internalFrame.setForeground(Color.GREEN);

    internalFrame.getContentPane().add(view.getPanel(this));

    SizeAndLocation sizeAndLoc = applicationConfig.getViewCoordinates(getUniqueID(view));
    if (sizeAndLoc != null) {
        internalFrame.setSize(sizeAndLoc.getSize());
        internalFrame.setLocation(sizeAndLoc.getLocation());
    } else {
        internalFrame.setSize(200, 150);
        internalFrame.setLocation(0, 0);
        internalFrame.pack();
    }

    internalFrame.setVisible(true);

    final InternalFrameWithView frameAndView = new InternalFrameWithView(internalFrame, view);

    final InternalFrameListener listener = new InternalFrameAdapter() {

        @Override
        public void internalFrameClosing(InternalFrameEvent e) {
            disposeView(view);
        }
    };

    internalFrame.setDefaultCloseOperation(JInternalFrame.DO_NOTHING_ON_CLOSE);
    internalFrame.addInternalFrameListener(listener);

    views.add(frameAndView);
    desktop.add(internalFrame);
    return view;
}

From source file:CSSDFarm.UserInterface.java

/**
 * Configure JxBrowser to be displayed. Load map.html from file to string data, load
 * this data into JxBrowser and add the browser to the panel.
 *///  w w  w . j av a  2 s.  c  om
public void displayHeatmap() {
    LoggerProvider.getChromiumProcessLogger().setLevel(Level.OFF);
    LoggerProvider.getIPCLogger().setLevel(Level.OFF);
    LoggerProvider.getBrowserLogger().setLevel(Level.OFF);
    BrowserView view = new BrowserView(browser);
    JPanel toolBar = new JPanel();

    Dimension dimension = panelHeatmap.getSize();

    JInternalFrame internalFrame = new JInternalFrame();
    internalFrame.add(view, BorderLayout.CENTER);
    internalFrame.add(toolBar, BorderLayout.NORTH);
    internalFrame.setSize(dimension);
    internalFrame.setLocation(0, 0);
    internalFrame.setBorder(null);
    internalFrame.setVisible(true);
    ((javax.swing.plaf.basic.BasicInternalFrameUI) internalFrame.getUI()).setNorthPane(null);

    URL url = getClass().getResource("map.html");
    File html = new File(url.getPath());

    String htmlString = null;
    try {
        htmlString = FileUtils.readFileToString(html);
    } catch (IOException ex) {
        Logger.getLogger(UserInterface.class.getName()).log(Level.SEVERE, null, ex);
    }

    browser.loadHTML(htmlString);

    panelHeatmap.add(internalFrame);
}

From source file:com.tag.FramePreferences.java

@SuppressWarnings("serial")
public FramePreferences(final JInternalFrame frame, String pathName) {
    setFrame(new Frame() {

        @Override/*from   ww w  .j av a 2 s . co  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.processmining.analysis.performance.PerformanceAnalysisGUI.java

/**
 * Creates a new frame, containing the current PerformanceConfiguration. In
 * the new frame, the user can change the current settings, after which the
 * PerformanceAnalysisGUI is updated.//from  ww  w  .  j  a v a 2s. co m
 */
private void createPerformanceOptionsScreen() {
    // initialize the settings screen
    JPanel firstPanel = new JPanel(new BorderLayout());
    JPanel secondPanel = new JPanel();
    JButton okButton = new JButton("Apply Changes");
    JButton cancelButton = new JButton("Cancel");
    String sel = (String) sb1.getSelectedItem();
    Dimension dim = new Dimension(380, 460);
    // create a new PerformanceConfiguration-object, containing the current
    // settings
    final PerformanceConfiguration performanceOptions = new PerformanceConfiguration(levelColors, bounds,
            timeSort, decimalPlaces, advancedSettings.clone());
    if (boxMap.get(sel) instanceof ExtendedPlace) {
        // adjust the performanceOptions to the settings of the selected
        // place
        performanceOptions.changeDisplay((ExtendedPlace) boxMap.get(sel));
        dim = new Dimension(380, 525);
    } else {
        performanceOptions.changeDisplay(null);
    }
    JScrollPane scroll = new JScrollPane(performanceOptions);
    firstPanel.add(scroll, BorderLayout.CENTER);
    firstPanel.add(secondPanel, BorderLayout.SOUTH);
    secondPanel.setLayout(new BoxLayout(secondPanel, BoxLayout.X_AXIS));
    secondPanel.add(Box.createRigidArea(new Dimension(40, 0)));
    secondPanel.add(okButton);
    secondPanel.add(Box.createRigidArea(new Dimension(20, 0)));
    secondPanel.add(cancelButton);
    okButton.addActionListener(new ActionListener() {
        // the action to be taken when the OK-button is pressed
        public void actionPerformed(ActionEvent e) {
            if (performanceOptions.getAllSelected()) {
                // settings should be applied to all places
                timeDivider = performanceOptions.getTimeDivider();
                timeSort = performanceOptions.getTimesort();
                decimalPlaces = performanceOptions.getDecimalPlaces();
                bounds = performanceOptions.getBoundaries();
                levelColors = performanceOptions.getColors();
                advancedSettings = performanceOptions.getAdvancedSettings().clone();
                manualSettings = true;
                ListIterator lit = extendedPetriNet.getPlaces().listIterator();
                while (lit.hasNext()) {
                    ExtendedPlace p = (ExtendedPlace) lit.next();
                    p.setHasOwnSettings(false);
                }
            } else {
                // apply settings to the selected place only
                performanceOptions.getSelectedPlace().setOwnSettings(performanceOptions.getBoundaries(),
                        performanceOptions.getColors());
                timeDivider = performanceOptions.getTimeDivider();
                timeSort = performanceOptions.getTimesort();
                decimalPlaces = performanceOptions.getDecimalPlaces();
                advancedSettings = performanceOptions.getAdvancedSettings().clone();
                manualSettings = true;
            }
            // close all frames containing AdvancedSettings opened from
            // performanceOptions
            performanceOptions.closeAdvancedFrames();
            // close the performanceOptions-frame
            MainUI.getInstance().getDesktop().getSelectedFrame().doDefaultCloseAction();
            // adjust the PerformanceAnalysisGUI
            adjustGUI();
        }
    });
    cancelButton.addActionListener(new ActionListener() {
        // the action to be taken when the cancel button has been pressed
        public void actionPerformed(ActionEvent e) {
            // close all frames containing AdvancedSettings opened from
            // performanceOptions
            performanceOptions.closeAdvancedFrames();
            // close the PerformanceOptions-frame
            MainUI.getInstance().getDesktop().getSelectedFrame().doDefaultCloseAction();
        }
    });
    // show the panel in a new frame
    MainUI.getInstance().createFrame("Performance analysis options:", firstPanel);
    JInternalFrame frame = MainUI.getInstance().getDesktop().getSelectedFrame();
    frame.setSize(dim);
}

From source file:org.prom5.analysis.performance.PerformanceAnalysisGUI.java

/**
 * Creates a new frame, containing the current PerformanceConfiguration.
 * In the new frame, the user can change the current settings, after which
 * the PerformanceAnalysisGUI is updated.
 *//*ww w. ja va  2s.c o  m*/
private void createPerformanceOptionsScreen() {
    //initialize the settings screen
    JPanel firstPanel = new JPanel(new BorderLayout());
    JPanel secondPanel = new JPanel();
    JButton okButton = new JButton("Apply Changes");
    JButton cancelButton = new JButton("Cancel");
    String sel = (String) sb1.getSelectedItem();
    Dimension dim = new Dimension(380, 460);
    //create a new PerformanceConfiguration-object, containing the current
    //settings
    final PerformanceConfiguration performanceOptions = new PerformanceConfiguration(levelColors, bounds,
            timeSort, decimalPlaces, advancedSettings.clone());
    if (boxMap.get(sel) instanceof ExtendedPlace) {
        //adjust the performanceOptions to the settings of the selected place
        performanceOptions.changeDisplay((ExtendedPlace) boxMap.get(sel));
        dim = new Dimension(380, 525);
    } else {
        performanceOptions.changeDisplay(null);
    }
    JScrollPane scroll = new JScrollPane(performanceOptions);
    firstPanel.add(scroll, BorderLayout.CENTER);
    firstPanel.add(secondPanel, BorderLayout.SOUTH);
    secondPanel.setLayout(new BoxLayout(secondPanel, BoxLayout.X_AXIS));
    secondPanel.add(Box.createRigidArea(new Dimension(40, 0)));
    secondPanel.add(okButton);
    secondPanel.add(Box.createRigidArea(new Dimension(20, 0)));
    secondPanel.add(cancelButton);
    okButton.addActionListener(new ActionListener() {
        // the action to be taken when the OK-button is pressed
        public void actionPerformed(ActionEvent e) {
            if (performanceOptions.getAllSelected()) {
                //settings should be applied to all places
                timeDivider = performanceOptions.getTimeDivider();
                timeSort = performanceOptions.getTimesort();
                decimalPlaces = performanceOptions.getDecimalPlaces();
                bounds = performanceOptions.getBoundaries();
                levelColors = performanceOptions.getColors();
                advancedSettings = performanceOptions.getAdvancedSettings().clone();
                manualSettings = true;
                ListIterator lit = extendedPetriNet.getPlaces().listIterator();
                while (lit.hasNext()) {
                    ExtendedPlace p = (ExtendedPlace) lit.next();
                    p.setHasOwnSettings(false);
                }
            } else {
                //apply settings to the selected place only
                performanceOptions.getSelectedPlace().setOwnSettings(performanceOptions.getBoundaries(),
                        performanceOptions.getColors());
                timeDivider = performanceOptions.getTimeDivider();
                timeSort = performanceOptions.getTimesort();
                decimalPlaces = performanceOptions.getDecimalPlaces();
                advancedSettings = performanceOptions.getAdvancedSettings().clone();
                manualSettings = true;
            }
            //close all frames containing AdvancedSettings opened from performanceOptions
            performanceOptions.closeAdvancedFrames();
            //close the performanceOptions-frame
            MainUI.getInstance().getDesktop().getSelectedFrame().doDefaultCloseAction();
            //adjust the PerformanceAnalysisGUI
            adjustGUI();
        }
    });
    cancelButton.addActionListener(new ActionListener() {
        // the action to be taken when the cancel button has been pressed
        public void actionPerformed(ActionEvent e) {
            //close all frames containing AdvancedSettings opened from performanceOptions
            performanceOptions.closeAdvancedFrames();
            //close the PerformanceOptions-frame
            MainUI.getInstance().getDesktop().getSelectedFrame().doDefaultCloseAction();
        }
    });
    //show the panel in a new frame
    MainUI.getInstance().createFrame("Performance analysis options:", firstPanel);
    JInternalFrame frame = MainUI.getInstance().getDesktop().getSelectedFrame();
    frame.setSize(dim);
}