Example usage for javax.swing JInternalFrame getContentPane

List of usage examples for javax.swing JInternalFrame getContentPane

Introduction

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

Prototype

public Container getContentPane() 

Source Link

Document

Returns the content pane for this internal frame.

Usage

From source file:CascadeDemo.java

public void newFrame() {
    JInternalFrame jif = new JInternalFrame("Frame " + m_count, true, true, true, true);
    jif.setBounds(20 * (m_count % 10) + m_tencount * 80, 20 * (m_count % 10), 200, 200);

    JLabel label = new JLabel(EARTH);
    jif.getContentPane().add(new JScrollPane(label));

    m_desktop.add(jif);/*from ww  w  .ja  v a 2  s .  co m*/
    try {
        jif.setSelected(true);
    } catch (PropertyVetoException pve) {
        System.out.println("Could not select " + jif.getTitle());
    }

    m_count++;
    if (m_count % 10 == 0) {
        if (m_tencount < 3)
            m_tencount++;
        else
            m_tencount = 0;
    }
}

From source file:InternalFrameListenerDemo.java

public void newFrame() {
    JInternalFrame jif = new JInternalFrame("Frame " + m_count, true, true, true, true);
    jif.addInternalFrameListener(this);
    jif.setBounds(20 * (m_count % 10) + m_tencount * 80, 20 * (m_count % 10), 200, 200);
    JLabel label = new JLabel();
    label.setBackground(Color.white);
    label.setOpaque(true);//from w ww  .j a  v  a2  s.  c  o  m
    jif.getContentPane().add(label);
    m_desktop.add(jif);
    try {
        jif.setSelected(true);
    } catch (PropertyVetoException pve) {
        System.out.println("Could not select " + jif.getTitle());
    }
    m_count++;
    if (m_count % 10 == 0) {
        if (m_tencount < 3)
            m_tencount++;
        else
            m_tencount = 0;
    }
}

From source file:DesktopManagerDemo.java

public void newFrame() {
    JInternalFrame jif = new JInternalFrame("Frame " + m_count, true, true, true, true);
    jif.setBounds(20 * (m_count % 10) + m_tencount * 80, 20 * (m_count % 10), 200, 200);
    JLabel label = new JLabel();
    label.setBackground(Color.white);
    label.setOpaque(true);/*  w  ww.j av a 2 s  . c  o  m*/
    jif.getContentPane().add(label);
    m_desktop.add(jif);
    try {
        jif.setSelected(true);
    } catch (PropertyVetoException pve) {
        System.out.println("Could not select " + jif.getTitle());
    }
    m_count++;
    if (m_count % 10 == 0) {
        if (m_tencount < 3)
            m_tencount++;
        else
            m_tencount = 0;
    }
}

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");
    }/*  w  w w  .ja v  a  2s. 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:JavaXWin.java

public void newFrame() {
    JInternalFrame jif = new JInternalFrame("Frame " + m_count, true, true, true, true);
    jif.setBounds(20 * (m_count % 10) + m_tencount * 80, 20 * (m_count % 10), 200, 200);

    JTextArea text = new JTextArea();
    JScrollPane scroller = new JScrollPane();
    scroller.getViewport().add(text);//from ww w . j  av a2  s.c  om
    try {
        FileReader fileStream = new FileReader("");
        text.read(fileStream, "JavaLinux.txt");
    } catch (Exception e) {
        text.setText("* Could not read JavaLinux.txt *");
    }
    jif.getContentPane().add(scroller);

    m_desktop.add(jif);
    try {
        jif.setSelected(true);
    } catch (PropertyVetoException pve) {
        System.out.println("Could not select " + jif.getTitle());
    }

    m_count++;
    if (m_count % 10 == 0) {
        if (m_tencount < 3)
            m_tencount++;
        else
            m_tencount = 0;
    }
}

From source file:com.moss.bdbadmin.client.ui.BdbAdminClient.java

private void showInDialog(String title, Component ancestor) {

    //      final JDialog dialog;

    //      if (ancestor instanceof JFrame) {
    //         dialog = new JDialog((JFrame)ancestor);
    //      }//w  w w  .j a  va 2  s . c  om
    //      else if (ancestor instanceof JDialog) {
    //         dialog = new JDialog((JDialog)ancestor);
    //      }
    //      else if (ancestor == null) {
    //         dialog = new JDialog();
    //      }
    //      else {
    //         throw new RuntimeException();
    //      }

    JInternalFrame dialog = new JInternalFrame(title);

    //      dialog.setTitle(client.url() + dbPath);
    dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    //      dialog.setModal(false);
    dialog.getContentPane().add(ancestor);
    dialog.setSize(400, 300);
    //      dialog.setLocationRelativeTo(ancestor);
    dialog.setResizable(true);
    dialog.setClosable(true);
    dialog.setIconifiable(true);
    dialog.setMaximizable(true);
    getDesktopPane().add(dialog);
    try {
        dialog.setMaximum(true);
    } catch (PropertyVetoException e) {
        e.printStackTrace();
    }
    dialog.setVisible(true);
}

From source file:mondrian.gui.Workbench.java

private void updateMDXCatalogList() {
    Iterator<JInternalFrame> it = mdxWindows.iterator();
    while (it.hasNext()) {
        JInternalFrame elem = it.next();
        QueryPanel qp = (QueryPanel) elem.getContentPane().getComponent(0);
        qp.setSchemaWindowMap(schemaWindowMap);
    }/*from   w w w  .j ava2  s  .c  om*/
}

From source file:mondrian.gui.Workbench.java

/**
 * returns the currently selected schema explorer object
 *
 * @return current schema explorer object
 *//*  w  w  w .  jav  a 2 s.co  m*/
public SchemaExplorer getCurrentSchemaExplorer() {
    JInternalFrame jf = desktopPane.getSelectedFrame();
    if (jf != null && jf.getContentPane().getComponentCount() > 0
            && jf.getContentPane().getComponent(0) instanceof SchemaExplorer) {
        return (SchemaExplorer) jf.getContentPane().getComponent(0);
    }
    return null;
}

From source file:mondrian.gui.Workbench.java

private boolean checkFileOpen(File file) {
    Iterator<JInternalFrame> it = schemaWindowMap.keySet().iterator();
    // keys=schemaframes
    while (it.hasNext()) {
        JInternalFrame elem = it.next();
        File f = ((SchemaExplorer) elem.getContentPane().getComponent(0)).getSchemaFile();
        if (f.equals(file)) {
            try {
                // make the schema file active
                elem.setSelected(true);/*from  w w  w  . ja v  a 2  s .  c  o m*/
                return true;
            } catch (Exception ex) {
                // remove file from map as schema frame does not exist
                schemaWindowMap.remove(elem);
                break;
            }
        }
    }
    return false;
}

From source file:InternalFrameTest.java

/**
 * Creates an internal frame on the desktop.
 * @param c the component to display in the internal frame
 * @param t the title of the internal frame.
 *///from   w ww. j a va2 s .  c  om
public void createInternalFrame(Component c, String t) {
    final JInternalFrame iframe = new JInternalFrame(t, true, // resizable
            true, // closable
            true, // maximizable
            true); // iconifiable

    iframe.add(c, BorderLayout.CENTER);
    desktop.add(iframe);

    iframe.setFrameIcon(new ImageIcon("document.gif"));

    // add listener to confirm frame closing
    iframe.addVetoableChangeListener(new VetoableChangeListener() {
        public void vetoableChange(PropertyChangeEvent event) throws PropertyVetoException {
            String name = event.getPropertyName();
            Object value = event.getNewValue();

            // we only want to check attempts to close a frame
            if (name.equals("closed") && value.equals(true)) {
                // ask user if it is ok to close
                int result = JOptionPane.showInternalConfirmDialog(iframe, "OK to close?", "Select an Option",
                        JOptionPane.YES_NO_OPTION);

                // if the user doesn't agree, veto the close
                if (result != JOptionPane.YES_OPTION)
                    throw new PropertyVetoException("User canceled close", event);
            }
        }
    });

    // position frame
    int width = desktop.getWidth() / 2;
    int height = desktop.getHeight() / 2;
    iframe.reshape(nextFrameX, nextFrameY, width, height);

    iframe.show();

    // select the frame--might be vetoed
    try {
        iframe.setSelected(true);
    } catch (PropertyVetoException e) {
    }

    frameDistance = iframe.getHeight() - iframe.getContentPane().getHeight();

    // compute placement for next frame

    nextFrameX += frameDistance;
    nextFrameY += frameDistance;
    if (nextFrameX + width > desktop.getWidth())
        nextFrameX = 0;
    if (nextFrameY + height > desktop.getHeight())
        nextFrameY = 0;
}