Example usage for javax.swing JDesktopPane JDesktopPane

List of usage examples for javax.swing JDesktopPane JDesktopPane

Introduction

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

Prototype

public JDesktopPane() 

Source Link

Document

Creates a new JDesktopPane.

Usage

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

/**
 * Creates a new instance of the demo./*  w ww  . j  av  a  2 s  .  co m*/
 * 
 * @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:InternalFrameDemo.java

public InternalFrameDemo() {
    super("InternalFrameDemo");

    // Make the big window be indented 50 pixels from each edge
    // of the screen.
    int inset = 50;
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    setBounds(inset, inset, screenSize.width - inset * 2, screenSize.height - inset * 2);

    // Set up the GUI.
    desktop = new JDesktopPane(); // a specialized layered pane
    createFrame(); // create first "window"
    setContentPane(desktop);/*from  w ww.ja va2s . c  o  m*/
    setJMenuBar(createMenuBar());

    // Make dragging a little faster but perhaps uglier.
    desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
}

From source file:InternalFrameEventDemo.java

public InternalFrameEventDemo(String title) {
    super(title);

    // Set up the GUI.
    desktop = new JDesktopPane();
    desktop.putClientProperty("JDesktopPane.dragMode", "outline");
    // Because we use pack, it's not enough to call setSize.
    // We must set the desktop's preferred size.
    desktop.setPreferredSize(new Dimension(desktopWidth, desktopHeight));
    setContentPane(desktop);//from ww w  . ja v  a2  s . c o  m

    createDisplayWindow();
    desktop.add(displayWindow); // DON'T FORGET THIS!!!
    Dimension displaySize = displayWindow.getSize();
    displayWindow.setSize(desktopWidth, displaySize.height);
}

From source file:SiteFrame.java

public SiteManager() {
    super("Web Site Manager");
    setSize(450, 250);//  w  w w .j  a  va  2s . c  om
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    Container contentPane = getContentPane();

    JToolBar jtb = new JToolBar();
    jtb.add(new CutAction(this));
    jtb.add(new CopyAction(this));
    jtb.add(new PasteAction(this));
    contentPane.add(jtb, BorderLayout.NORTH);

    // Add our LayeredPane object for the internal frames.
    desktop = new JDesktopPane();
    contentPane.add(desktop, BorderLayout.CENTER);
    addSiteFrame("Sample");
}

From source file:be.fedict.eid.tsl.tool.TslTool.java

private TslTool() {
    super("eID TSL Tool");

    initMenuBar();//from  w w w  .  j  a v a  2  s  .c  o  m

    this.desktopPane = new JDesktopPane();
    setContentPane(this.desktopPane);

    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setSize(600, 400);
    setVisible(true);
}

From source file:DesktopManagerDemo.java

public DesktopManagerDemo() {
    setTitle("Animated DesktopManager");
    m_count = m_tencount = 0;//  www. j  ava  2s . c om

    JPanel innerListenerPanel = new JPanel(new GridLayout(15, 1));
    JPanel listenerPanel = new JPanel(new BorderLayout());
    m_dmEventCanvas = new DMEventCanvas();

    m_lActivates = new JLabel("activateFrame");
    m_lBegindrags = new JLabel("beginDraggingFrame");
    m_lBeginresizes = new JLabel("beginResizingFrame");
    m_lCloses = new JLabel("closeFrame");
    m_lDeactivates = new JLabel("deactivateFrame");
    m_lDeiconifies = new JLabel("deiconifyFrame");
    m_lDrags = new JLabel("dragFrame");
    m_lEnddrags = new JLabel("endDraggingFrame");
    m_lEndresizes = new JLabel("endResizingFrame");
    m_lIconifies = new JLabel("iconifyFrame");
    m_lMaximizes = new JLabel("maximizeFrame");
    m_lMinimizes = new JLabel("minimizeFrame");
    m_lOpens = new JLabel("openFrame");
    m_lResizes = new JLabel("resizeFrame");
    m_lSetbounds = new JLabel("setBoundsForFrame");

    innerListenerPanel.add(m_lActivates);
    innerListenerPanel.add(m_lBegindrags);
    innerListenerPanel.add(m_lBeginresizes);
    innerListenerPanel.add(m_lCloses);
    innerListenerPanel.add(m_lDeactivates);
    innerListenerPanel.add(m_lDeiconifies);
    innerListenerPanel.add(m_lDrags);
    innerListenerPanel.add(m_lEnddrags);
    innerListenerPanel.add(m_lEndresizes);
    innerListenerPanel.add(m_lIconifies);
    innerListenerPanel.add(m_lMaximizes);
    innerListenerPanel.add(m_lMinimizes);
    innerListenerPanel.add(m_lOpens);
    innerListenerPanel.add(m_lResizes);
    innerListenerPanel.add(m_lSetbounds);

    listenerPanel.add("Center", m_dmEventCanvas);
    listenerPanel.add("West", innerListenerPanel);
    listenerPanel.setOpaque(true);
    listenerPanel.setBackground(Color.white);

    m_myDesktopManager = new MyDesktopManager();
    m_desktop = new JDesktopPane();
    m_desktop.setDesktopManager(m_myDesktopManager);
    m_desktop.setBorder(new SoftBevelBorder(BevelBorder.LOWERED));
    m_newFrame = new JButton("New Frame");
    m_newFrame.addActionListener(this);
    m_infos = UIManager.getInstalledLookAndFeels();
    String[] LAFNames = new String[m_infos.length];
    for (int i = 0; i < m_infos.length; i++) {
        LAFNames[i] = m_infos[i].getName();
    }
    m_UIBox = new JComboBox(LAFNames);
    m_UIBox.addActionListener(this);
    JPanel topPanel = new JPanel(true);
    topPanel.setLayout(new FlowLayout());
    topPanel.setBorder(new CompoundBorder(new SoftBevelBorder(BevelBorder.LOWERED),
            new CompoundBorder(new EmptyBorder(2, 2, 2, 2), new SoftBevelBorder(BevelBorder.RAISED))));
    getContentPane().setLayout(new BorderLayout());
    getContentPane().add("North", topPanel);
    getContentPane().add("Center", m_desktop);
    getContentPane().add("South", listenerPanel);
    ((JPanel) getContentPane()).setBorder(new CompoundBorder(new SoftBevelBorder(BevelBorder.LOWERED),
            new CompoundBorder(new EmptyBorder(1, 1, 1, 1), new SoftBevelBorder(BevelBorder.RAISED))));
    topPanel.add(m_newFrame);
    topPanel.add(new JLabel("Look & Feel:", SwingConstants.RIGHT));
    topPanel.add(m_UIBox);
    setSize(645, 600);
    Dimension dim = getToolkit().getScreenSize();
    setLocation(dim.width / 2 - getWidth() / 2, dim.height / 2 - getHeight() / 2);
    setVisible(true);
    WindowListener l = new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    };
    addWindowListener(l);
    m_eventTimer = new Timer(1000, this);
    m_eventTimer.setRepeats(true);
    m_eventTimer.start();
}

From source file:InternalFrameEventDemo.java

public InternalFrameEventDemo(String title) {
    super(title);

    //Set up the GUI.
    desktop = new JDesktopPane();
    desktop.putClientProperty("JDesktopPane.dragMode", "outline");
    //Because we use pack, it's not enough to call setSize.
    //We must set the desktop's preferred size.
    desktop.setPreferredSize(new Dimension(desktopWidth, desktopHeight));
    setContentPane(desktop);//w w  w  .ja  va 2s.c  om

    createDisplayWindow();
    desktop.add(displayWindow); //DON'T FORGET THIS!!!
    Dimension displaySize = displayWindow.getSize();
    displayWindow.setSize(desktopWidth, displaySize.height);
}

From source file:MDIApp.java

/*************************************************************************
 * METHODS// w w  w  . j a v a 2 s  .  c o m
 *************************************************************************/

public MDIApp() {
    super("Java Media Player");

    // Add the desktop pane
    setLayout(new BorderLayout());
    desktop = new JDesktopPane();
    desktop.setDoubleBuffered(true);
    add("Center", desktop);
    setMenuBar(createMenuBar());
    setSize(640, 480);
    setVisible(true);

    try {
        UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
    } catch (Exception e) {
        System.err.println("Could not initialize java.awt Metal lnf");
    }
    addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent we) {
            System.exit(0);
        }
    });

    Manager.setHint(Manager.LIGHTWEIGHT_RENDERER, new Boolean(true));
}

From source file:eu.delving.sip.Application.java

private Application(final File storageDir) throws StorageException {
    GroovyCodeResource groovyCodeResource = new GroovyCodeResource(getClass().getClassLoader());
    final ImageIcon backgroundIcon = new ImageIcon(getClass().getResource("/delving-background.png"));
    desktop = new JDesktopPane() {
        public void paintComponent(Graphics g) {
            super.paintComponent(g);
            g.drawImage(backgroundIcon.getImage(), 0, 0, desktop);
        }//from  w w  w .jav  a  2  s.  c o m
    };
    desktop.setMinimumSize(new Dimension(MINIMUM_DESKTOP_SIZE));
    resizeTimer = new Timer(DEFAULT_RESIZE_INTERVAL, new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            resizeTimer.stop();
            for (JInternalFrame frame : desktop.getAllFrames()) {
                if (frame instanceof FrameBase) {
                    ((FrameBase) frame).ensureOnScreen();
                }
            }
        }
    });
    desktop.addComponentListener(new ComponentAdapter() {
        @Override
        public void componentResized(ComponentEvent componentEvent) {
            resizeTimer.restart();
        }
    });
    Preferences preferences = Preferences.userNodeForPackage(SipModel.class);
    feedback = new VisualFeedback(home, desktop, preferences);
    HttpClient httpClient = createHttpClient(storageDir);
    SchemaRepository schemaRepository;
    try {
        schemaRepository = new SchemaRepository(new SchemaFetcher(httpClient));
    } catch (IOException e) {
        throw new StorageException("Unable to create Schema Repository", e);
    }
    ResolverContext context = new ResolverContext();
    Storage storage = new StorageImpl(storageDir, schemaRepository, new CachedResourceResolver(context));
    context.setStorage(storage);
    context.setHttpClient(httpClient);
    sipModel = new SipModel(desktop, storage, groovyCodeResource, feedback, preferences);
    CultureHubClient cultureHubClient = isStandalone(storageDir) ? null
            : new CultureHubClient(sipModel, httpClient);
    if (cultureHubClient != null)
        uploadAction = new UploadAction(sipModel, cultureHubClient);
    expertMenu = new ExpertMenu(desktop, sipModel, cultureHubClient, allFrames);
    statusPanel = new StatusPanel(sipModel);
    home = new JFrame(titleString());
    home.addComponentListener(new ComponentAdapter() {
        @Override
        public void componentResized(ComponentEvent componentEvent) {
            allFrames.getViewSelector().refreshView();
        }
    });
    JPanel content = (JPanel) home.getContentPane();
    content.setFocusable(true);
    FrameBase dataSetFrame = cultureHubClient != null ? new DataSetHubFrame(sipModel, cultureHubClient)
            : new DataSetStandaloneFrame(sipModel, schemaRepository);
    LogFrame logFrame = new LogFrame(sipModel);
    feedback.setLog(logFrame.getLog());
    allFrames = new AllFrames(sipModel, content, dataSetFrame, logFrame);
    desktop.setBackground(new Color(190, 190, 200));
    content.add(desktop, BorderLayout.CENTER);
    sipModel.getMappingModel().addChangeListener(new MappingModel.ChangeListener() {
        @Override
        public void lockChanged(MappingModel mappingModel, final boolean locked) {
            sipModel.exec(new Swing() {
                @Override
                public void run() {
                    unlockMappingAction.setEnabled(locked);
                }
            });
        }

        @Override
        public void functionChanged(MappingModel mappingModel, MappingFunction function) {
        }

        @Override
        public void nodeMappingChanged(MappingModel mappingModel, RecDefNode node, NodeMapping nodeMapping,
                NodeMappingChange change) {
        }

        @Override
        public void nodeMappingAdded(MappingModel mappingModel, RecDefNode node, NodeMapping nodeMapping) {
        }

        @Override
        public void nodeMappingRemoved(MappingModel mappingModel, RecDefNode node, NodeMapping nodeMapping) {
        }

        @Override
        public void populationChanged(MappingModel mappingModel, RecDefNode node) {
        }
    });
    importAction = new ImportAction(desktop, sipModel);
    attachAccelerator(importAction, home);
    validateAction = new ValidateAction(sipModel, allFrames.prepareForInvestigation(desktop));
    unlockMappingAction = new UnlockMappingAction(sipModel);
    attachAccelerator(unlockMappingAction, home);
    selectAnotherMappingAction = new SelectAnotherMappingAction(sipModel);
    attachAccelerator(selectAnotherMappingAction, home);
    content.add(createStatePanel(), BorderLayout.SOUTH);
    content.add(allFrames.getSidePanel(), BorderLayout.WEST);
    Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
    screen.height -= 30;
    home.setSize(screen);
    home.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    ImageIcon logo = new ImageIcon(getClass().getResource("/sip-creator-logo.png"));
    home.setIconImage(logo.getImage());
    home.setJMenuBar(createMenuBar());
    home.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent windowEvent) {
            quit();
        }
    });
    home.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    sipModel.getDataSetModel().addListener(new DataSetModel.SwingListener() {
        @Override
        public void stateChanged(DataSetModel model, DataSetState state) {
            statusPanel.setState(state);
            switch (state) {
            case ABSENT:
                sipModel.exec(new Work() {
                    @Override
                    public void run() {
                        sipModel.getDataSetFacts().set(null);
                        sipModel.getStatsModel().setStatistics(null);
                    }

                    @Override
                    public Job getJob() {
                        return Job.CLEAR_FACTS_STATS;
                    }
                });
                home.setTitle(titleString());
                sipModel.seekReset();
                break;
            default:
                DataSetModel dataSetModel = sipModel.getDataSetModel();
                home.setTitle(String.format(titleString() + " - [%s -> %s]",
                        dataSetModel.getDataSet().getSpec(), dataSetModel.getPrefix().toUpperCase()));
                sipModel.getReportFileModel().refresh();
                break;
            }
        }
    });
    attachAccelerator(new QuitAction(), home);
    attachAccelerator(statusPanel.getButtonAction(), home);
}

From source file:com.freedomotic.jfrontend.MainWindow.java

private void setWindowedMode() {
    this.setVisible(false);
    this.dispose();
    this.setUndecorated(false);
    this.setResizable(true);

    try {//from ww w.  ja  va2s .  com
        this.getContentPane().removeAll();
    } catch (Exception e) {
        LOG.error("Set window mode exception {}", e.getMessage());
    }

    try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (ClassNotFoundException ex) {
        LOG.error("Cannot find system look&feel\n", ex.toString());
    } catch (InstantiationException ex) {
        LOG.error("Cannot instantiate system look&feel\n", ex.toString());
    } catch (IllegalAccessException ex) {
        LOG.error("Illegal access to system look&feel\n", ex.toString());
    } catch (UnsupportedLookAndFeelException ex) {
        LOG.error("Unsupported system look&feel\n", ex.toString());
    }

    setDefaultLookAndFeelDecorated(true);
    initComponents();
    this.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    setLayout(new BorderLayout());
    desktopPane = new JDesktopPane();
    lstClients = new PluginJList(this);
    frameClient = new JInternalFrame();
    frameClient.setLayout(new BorderLayout());

    JScrollPane clientScroll = new JScrollPane(lstClients);
    frameClient.add(clientScroll, BorderLayout.CENTER);
    frameClient.setTitle(i18n.msg("loaded_plugins"));
    frameClient.setResizable(true);
    frameClient.setMaximizable(true);
    frameMap = new JInternalFrame();
    setMapTitle("");
    frameMap.setMaximizable(true);
    frameMap.setResizable(true);
    desktopPane.add(frameMap);
    desktopPane.add(frameClient);
    frameClient.moveToFront();
    frameClient.setVisible(auth.isPermitted("plugins:read"));
    desktopPane.moveToFront(this);
    this.getContentPane().add(desktopPane);

    try {
        frameClient.setSelected(true);
    } catch (PropertyVetoException ex) {
        LOG.error(Freedomotic.getStackTraceInfo(ex));
    }

    EnvironmentLogic previousEnv = api.environments().findAll().get(0);

    if (drawer != null) {
        previousEnv = drawer.getCurrEnv();
    }

    initializeRenderer(previousEnv);
    drawer = master.createRenderer(previousEnv);

    if (drawer != null) {
        setDrawer(drawer);
        ResourcesManager.clear();
    } else {
        LOG.error("Unable to create a drawer to render the environment on the desktop frontend");
    }

    this.setTitle("Freedomotic " + Info.getLicense() + " - www.freedomotic.com");
    this.setSize(1100, 700);
    centerFrame(this);
    frameClient.moveToFront();
    frameMap.moveToFront();
    optimizeFramesDimension();
    drawer.repaint();
    lstClients.update();
    frameClient.setVisible(auth.isPermitted("plugins:read"));
    frameMap.setVisible(auth.isPermitted("environments:read"));
    setEditMode(false);
    this.setVisible(true);
    isFullscreen = false;

}