Example usage for javax.swing JInternalFrame pack

List of usage examples for javax.swing JInternalFrame pack

Introduction

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

Prototype

public void pack() 

Source Link

Document

Causes subcomponents of this JInternalFrame to be laid out at their preferred size.

Usage

From source file:Main.java

public static void main(String[] args) {
    String TITLE = "Full Screen Test";
    JFrame f = new JFrame(TITLE);
    JDesktopPane jdp = new JDesktopPane();

    GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice dev = env.getDefaultScreenDevice();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JInternalFrame jif = new JInternalFrame(TITLE, true, true, true);
    jif.add(new JLabel(TITLE + " " + TITLE), BorderLayout.NORTH);
    jif.add(new JLabel(TITLE + " " + TITLE), BorderLayout.CENTER);
    jif.add(new JLabel(TITLE + " " + TITLE), BorderLayout.SOUTH);
    jif.pack();
    jif.setLocation(100, 100);//from  w  w w.  j  av  a  2  s. c  o  m
    jif.setVisible(true);
    jdp.add(jif);
    f.add(jdp, BorderLayout.CENTER);
    dev.setFullScreenWindow(f);

}

From source file:Main.java

/**
 * Creates (and displays) a JInternalFrame for a specified component. <br />
 * The size of the JInternalFrame will be setted with calling <code>pack()</code>. <br />
 * //from   ww w  . ja v  a  2  s.  c o 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) {
    JInternalFrame frm = new JInternalFrame(title);
    frm.setClosable(true);
    frm.setLayout(new BorderLayout());
    frm.add(comp, BorderLayout.CENTER);

    desktop.add(frm, 0);
    frm.pack();
    frm.setVisible(true);

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

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

    return frm;
}

From source file:Main.java

/**
 * Displays a specified <code>JFileChooser</code> in a JInternalFrame. <br />
 * The JInternalFrame will close when the dialog is closed. <br />
 * //from   ww  w  .ja  v a  2 s . co m
 * @param desktop the JDesktopPane on which to display the JFileChooser
 * @param ch the JFileChooser to display
 */
public static void showInternalFileChooser(JDesktopPane desktop, final JFileChooser ch) {
    final JInternalFrame frm = new JInternalFrame(ch.getDialogTitle());
    frm.setClosable(true);
    frm.setResizable(true);
    frm.setLayout(new BorderLayout());
    frm.add(ch, BorderLayout.CENTER);
    frm.setVisible(true);

    frm.pack();

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

    ch.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent ae) {
            frm.dispose();
            ch.removeActionListener(this);
        }
    });

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

From source file:Main.java

private JInternalFrame createFrame(final Image image) {
    frames++;/*from   w  ww  . j  a  va2s.  c  om*/
    final JInternalFrame frame = new JInternalFrame("Picture " + frames);
    frame.add(BorderLayout.CENTER, new JLabel(new ImageIcon(image)));
    frame.pack();
    frame.setVisible(true);
    frame.setLocation(40 * frames, 40 * frames);
    return frame;
}

From source file:ScrollDesktop.java

public Main() {
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JDesktopPane desk = new ScrollDesktop();
    desk.setPreferredSize(new Dimension(1000, 1000));
    getContentPane().add(new JScrollPane(desk), "Center");
    JInternalFrame f1 = new JInternalFrame("Frame 1");
    f1.getContentPane().add(new JLabel("This is frame f1"));
    f1.setResizable(true);//w w  w .j av a  2s. c om
    f1.pack();
    f1.setVisible(true);
    desk.add(f1, new Integer(10));

    JInternalFrame f2 = new JInternalFrame("Frame 2");
    f2.getContentPane().add(new JLabel("Content for f2"));
    f2.setResizable(true);
    f2.pack();
    f2.setVisible(true);
    desk.add(f2, new Integer(20));

    JInternalFrame f3 = new JInternalFrame("Frame 3");
    f3.getContentPane().add(new JLabel("Content for f3"));
    f3.setResizable(true);
    f3.pack();
    f3.setVisible(true);
    desk.add(f3, new Integer(20));

    f3.toFront();
    try {
        f3.setSelected(true);
    } catch (java.beans.PropertyVetoException ignored) {
    }

    pack();
    setSize(300, 300);
    setVisible(true);
}

From source file:org.jfree.chart.demo.InternalFrameDemo.java

/**
 * Creates a new instance of the demo.//from  w  w w  .  j a va  2  s  .c  om
 * 
 * @param title  the title.
 */
public InternalFrameDemo(final String title) {
    super(title);
    final JDesktopPane desktopPane = new JDesktopPane();
    desktopPane.setPreferredSize(new Dimension(600, 400));
    final JInternalFrame frame1 = createFrame1();
    desktopPane.add(frame1);
    frame1.pack();
    frame1.setVisible(true);
    final JInternalFrame frame2 = createFrame2();
    desktopPane.add(frame2);
    frame2.pack();
    frame2.setLocation(100, 200);
    frame2.setVisible(true);
    getContentPane().add(desktopPane);
}

From source file:Main.java

public Main() {
    JInternalFrame frame1 = new JInternalFrame("Frame 1", true, true, true, true);

    JInternalFrame frame2 = new JInternalFrame("Frame 2", true, true, true, true);

    frame1.getContentPane().add(new JLabel("Frame 1  contents..."));
    frame1.pack();
    frame1.setVisible(true);//from ww  w.j a  v a 2  s .co  m

    frame2.getContentPane().add(new JLabel("Frame 2  contents..."));
    frame2.pack();
    frame2.setVisible(true);

    int x2 = frame1.getX() + frame1.getWidth() + 10;
    int y2 = frame1.getY();
    frame2.setLocation(x2, y2);

    desktopPane.add(frame1);
    desktopPane.add(frame2);

    this.add(desktopPane, BorderLayout.CENTER);

    this.setMinimumSize(new Dimension(300, 300));
}

From source file:Controlador.ControladorLecturas.java

public JInternalFrame graficoHumedadAmbiental() {
    DefaultCategoryDataset defaultCategoryDataset = new DefaultCategoryDataset();
    for (Object row : vectorHumedadAmbiental()) {
        int porcentaje = Integer.parseInt(((Vector) row).elementAt(0).toString());
        String rowKey = "Sensor 1";
        String columnKey = ((Vector) row).elementAt(1).toString();
        defaultCategoryDataset.addValue(porcentaje, rowKey, columnKey);
    }//www  .  java 2  s  .  c  o m
    JFreeChart jFreeChart = ChartFactory.createLineChart(null, "Hora", "Porcentaje Humedad",
            defaultCategoryDataset, PlotOrientation.VERTICAL, true, true, true);
    ChartPanel chartPanel = new ChartPanel(jFreeChart);
    JInternalFrame jInternalFrame = new JInternalFrame("Grafico de Humedad Ambiental", true, true, true, true);
    jInternalFrame.add(chartPanel, BorderLayout.CENTER);
    jInternalFrame.pack();
    return jInternalFrame;
}

From source file:Controlador.ControladorLecturas.java

public JInternalFrame graficoHumedadSuelo() {
    DefaultCategoryDataset defaultCategoryDataset = new DefaultCategoryDataset();
    for (Object row : vectorHumedadSuelo()) {
        int grados = Integer.parseInt(((Vector) row).elementAt(0).toString());
        String rowKey = "Sensor 1";
        String columnKey = ((Vector) row).elementAt(1).toString();
        defaultCategoryDataset.addValue(grados, rowKey, columnKey);
    }/*  w  ww  .j ava2s  .  c  o  m*/
    JFreeChart jFreeChart = ChartFactory.createLineChart(null, "Hora", "Humedad", defaultCategoryDataset,
            PlotOrientation.VERTICAL, true, true, true);
    ChartPanel chartPanel = new ChartPanel(jFreeChart);
    JInternalFrame jInternalFrame = new JInternalFrame("Grafico de Humedad del Suelo", true, true, true, true);
    jInternalFrame.add(chartPanel, BorderLayout.CENTER);
    jInternalFrame.pack();
    return jInternalFrame;
}

From source file:fr.crnan.videso3d.ihm.PLNSPanel.java

private void addChart(JFreeChart chart) {
    ChartPanel panel = new ChartPanel(chart);
    chartPanels.add(panel);//  w  ww  .ja  v a2 s  . c  o m
    JInternalFrame frame = new JInternalFrame(chart.getTitle().getText(), true, false, true, true);
    frame.add(panel);
    frame.pack();
    frame.setVisible(true);
    desktop.add(frame);
    desktop.tile(true);
    if (chartMouseListener != null) {
        panel.addChartMouseListener(chartMouseListener);
    }
}