Example usage for javax.swing JWindow setLayout

List of usage examples for javax.swing JWindow setLayout

Introduction

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

Prototype

public void setLayout(LayoutManager manager) 

Source Link

Document

Sets the LayoutManager.

Usage

From source file:org.nebulaframework.ui.swing.cluster.ClusterMainUI.java

/**
 * Displays Splash Screen/*from ww  w .  j av a  2s.c o  m*/
 * 
 * @return Splash Screen Reference
 */
public static JWindow showSplash() {

    JWindow splash = new JWindow();
    splash.setSize(400, 250);
    splash.setLayout(null);

    JLabel status = new JLabel("Developed by Yohan Liyanage, 2008");
    JLabelAppender.setLabel(status);
    status.setFont(new Font("sansserif", Font.PLAIN, 10));
    status.setSize(350, 30);
    status.setLocation(10, 220);
    splash.add(status);

    JLabel lbl = new JLabel(
            new ImageIcon(ClassLoader.getSystemResource("META-INF/resources/nebula-startup.png")));
    lbl.setSize(400, 250);
    lbl.setLocation(0, 0);
    splash.add(lbl);

    splash.setVisible(true);
    splash.setLocationRelativeTo(null);

    return splash;
}

From source file:org.pmedv.blackboard.commands.OpenBoardCommand.java

@Override
public void execute(ActionEvent e) {

    final ApplicationWindow win = ctx.getBean(ApplicationWindow.class);

    // No file selected before, popup a dialog and query the user which file to open.
    if (file == null) {
        String path = System.getProperty("user.home");
        if (AppContext.getLastSelectedFolder() != null) {
            path = AppContext.getLastSelectedFolder();
        }//  w w w . j  a v  a  2 s .  c om
        JFileChooser fc = new JFileChooser(path);
        fc.setDialogTitle(resources.getResourceByKey("OpenBoardCommand.name"));
        fc.setFileFilter(new FefaultFileFilter());
        int result = fc.showOpenDialog(win);
        if (result == JFileChooser.APPROVE_OPTION) {
            if (fc.getSelectedFile() == null)
                return;
            file = fc.getSelectedFile();
            AppContext.setLastSelectedFolder(file.getParentFile().getAbsolutePath());
        } else {
            return;
        }
    }

    final JWindow topWindow = new JWindow();
    topWindow.setSize(390, 50);
    topWindow.setLayout(new BorderLayout());
    topWindow.setBackground(Color.WHITE);

    final JPanel content = new JPanel(new BorderLayout());
    content.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.BLACK),
            BorderFactory.createEmptyBorder(10, 10, 10, 10)));
    content.setBackground(Color.WHITE);
    final JLabel infoLabel = new JLabel(
            resources.getResourceByKey("OpenBoardCommand.waitMsg") + " " + file.getName());
    infoLabel.setVerticalAlignment(SwingConstants.CENTER);
    content.add(infoLabel, BorderLayout.SOUTH);

    final JBusyComponent<JPanel> busyPanel = new JBusyComponent<JPanel>(content);
    busyPanel.setBusy(true);

    topWindow.getContentPane().add(busyPanel, BorderLayout.CENTER);
    topWindow.setLocationRelativeTo(null);
    topWindow.add(busyPanel, BorderLayout.CENTER);

    final SwingWorker<Boolean, Void> worker = new SwingWorker<Boolean, Void>() {

        @Override
        protected Boolean doInBackground() {
            topWindow.setVisible(true);
            doOpen();
            return Boolean.valueOf(true);
        }

        @Override
        protected void done() {
            topWindow.setVisible(false);
            topWindow.dispose();
            for (Runnable r : postConfigurators) {
                SwingUtilities.invokeLater(r);
            }
        }
    };

    worker.execute();

}