List of usage examples for javax.swing JInternalFrame add
public Component add(String name, Component comp)
From source file:InternalFramePropertyChangeHandler.java
public static void main(final String[] args) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JDesktopPane desktop = new JDesktopPane(); JInternalFrame internalFrame = new JInternalFrame("Can Do All", true, true, true, true); InternalFramePropertyChangeHandler ins = new InternalFramePropertyChangeHandler(); // Add listener for iconification events internalFrame.addPropertyChangeListener(ins); desktop.add(internalFrame);/* w w w .j a v a 2 s. c o m*/ internalFrame.setBounds(25, 25, 200, 100); JLabel label = new JLabel(internalFrame.getTitle(), JLabel.CENTER); internalFrame.add(label, BorderLayout.CENTER); internalFrame.setVisible(true); frame.add(desktop, BorderLayout.CENTER); frame.setSize(500, 300); frame.setVisible(true); }
From source file:InternalFrameIconifyListener.java
public static void main(final String[] args) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JDesktopPane desktop = new JDesktopPane(); JInternalFrame internalFrame = new JInternalFrame("Can Do All", true, true, true, true); InternalFrameListener internalFrameListener = new InternalFrameIconifyListener(); // Add listener for iconification events internalFrame.addInternalFrameListener(internalFrameListener); desktop.add(internalFrame);/*w ww.j a va 2s.c om*/ internalFrame.setBounds(25, 25, 200, 100); JLabel label = new JLabel(internalFrame.getTitle(), JLabel.CENTER); internalFrame.add(label, BorderLayout.CENTER); internalFrame.setVisible(true); frame.add(desktop, BorderLayout.CENTER); frame.setSize(500, 300); frame.setVisible(true); }
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 ww . ja v a 2s. 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
/** * 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 w w w . j a va 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) { 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. j a v a 2s . com * @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
/** * 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 a v a 2 s.c om * @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:Main.java
private JInternalFrame createFrame(final Image image) { frames++;/*from w w w . ja v a 2s. 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: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); }//from w w w. j av a 2s . 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); }//from w ww .java 2 s. c om 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:Controlador.ControladorLecturas.java
public JInternalFrame graficoTemperatura() { DefaultCategoryDataset defaultCategoryDataset = new DefaultCategoryDataset(); for (Object row : vectorTemperatura()) { 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); }/*from w ww . j av a 2s. co m*/ JFreeChart jFreeChart = ChartFactory.createLineChart(null, "Hora", "Grados", defaultCategoryDataset, PlotOrientation.VERTICAL, true, true, true); ChartPanel chartPanel = new ChartPanel(jFreeChart); JInternalFrame jInternalFrame = new JInternalFrame("Grafico de Temperatura Ambiental", true, true, true, true); jInternalFrame.add(chartPanel, BorderLayout.CENTER); jInternalFrame.pack(); return jInternalFrame; }