Search in sources :

Example 21 with BorderLayout

use of java.awt.BorderLayout in project java-design-patterns by iluwatar.

the class Target method setup.

private void setup() {
    setLayout(new BorderLayout());
    JPanel bot = new JPanel();
    add(jt.getTableHeader(), BorderLayout.NORTH);
    bot.setLayout(new BorderLayout());
    bot.add(del, BorderLayout.EAST);
    add(bot, BorderLayout.SOUTH);
    jsp = new JScrollPane(jt);
    jsp.setPreferredSize(new Dimension(500, 250));
    add(jsp, BorderLayout.CENTER);
    del.addActionListener(new DListener());
    JRootPane rootPane = SwingUtilities.getRootPane(del);
    rootPane.setDefaultButton(del);
    setVisible(true);
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) BorderLayout(java.awt.BorderLayout) JRootPane(javax.swing.JRootPane) Dimension(java.awt.Dimension)

Example 22 with BorderLayout

use of java.awt.BorderLayout in project jmonkeyengine by jMonkeyEngine.

the class TestAwtPanels method createWindowForPanel.

private static void createWindowForPanel(AwtPanel panel, int location) {
    JFrame frame = new JFrame("Render Display " + location);
    frame.getContentPane().setLayout(new BorderLayout());
    frame.getContentPane().add(panel, BorderLayout.CENTER);
    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    frame.addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosed(WindowEvent e) {
            if (++panelsClosed == 2) {
                app.stop();
            }
        }
    });
    frame.pack();
    frame.setLocation(location, Toolkit.getDefaultToolkit().getScreenSize().height - 400);
    frame.setVisible(true);
}
Also used : BorderLayout(java.awt.BorderLayout) JFrame(javax.swing.JFrame) WindowEvent(java.awt.event.WindowEvent) WindowAdapter(java.awt.event.WindowAdapter)

Example 23 with BorderLayout

use of java.awt.BorderLayout in project apjp by jvansteirteghem.

the class Main method main.

public static void main(final String[] args) {
    EventQueue.invokeLater(new Runnable() {

        public void run() {
            try {
                System.setProperty("sun.net.http.allowRestrictedHeaders", "true");
                Security.addProvider(new IAIK());
                Properties properties = new Properties();
                properties.load(new FileInputStream("APJP_LOCAL.properties"));
                APJP.APJP_KEY = properties.getProperty("APJP_KEY", "");
                APJP.APJP_LOGGER_ID = "APJP";
                APJP.APJP_LOGGER_LEVEL = 1;
                APJP.APJP_LOCAL_PROXY_SERVER_ADDRESS = properties.getProperty("APJP_LOCAL_PROXY_SERVER_ADDRESS", "");
                try {
                    APJP.APJP_LOCAL_PROXY_SERVER_PORT = new Integer(properties.getProperty("APJP_LOCAL_PROXY_SERVER_PORT", "0"));
                } catch (Exception e) {
                    APJP.APJP_LOCAL_PROXY_SERVER_PORT = 0;
                }
                APJP.APJP_LOCAL_PROXY_SERVER_LOGGER_ID = "APJP_LOCAL_PROXY_SERVER";
                APJP.APJP_LOCAL_PROXY_SERVER_LOGGER_LEVEL = 1;
                APJP.APJP_LOCAL_HTTP_PROXY_SERVER_ADDRESS = properties.getProperty("APJP_LOCAL_HTTP_PROXY_SERVER_ADDRESS", "");
                try {
                    APJP.APJP_LOCAL_HTTP_PROXY_SERVER_PORT = new Integer(properties.getProperty("APJP_LOCAL_HTTP_PROXY_SERVER_PORT", "0"));
                } catch (Exception e) {
                    APJP.APJP_LOCAL_HTTP_PROXY_SERVER_PORT = 0;
                }
                APJP.APJP_LOCAL_HTTP_PROXY_SERVER_LOGGER_ID = "APJP_LOCAL_HTTP_PROXY_SERVER";
                APJP.APJP_LOCAL_HTTP_PROXY_SERVER_LOGGER_LEVEL = 1;
                APJP.APJP_LOCAL_HTTP_SERVER_ADDRESS = properties.getProperty("APJP_LOCAL_HTTP_SERVER_ADDRESS", "");
                try {
                    APJP.APJP_LOCAL_HTTP_SERVER_PORT = new Integer(properties.getProperty("APJP_LOCAL_HTTP_SERVER_PORT", "0"));
                } catch (Exception e) {
                    APJP.APJP_LOCAL_HTTP_SERVER_PORT = 0;
                }
                APJP.APJP_LOCAL_HTTP_SERVER_LOGGER_ID = "APJP_LOCAL_HTTP_SERVER";
                APJP.APJP_LOCAL_HTTP_SERVER_LOGGER_LEVEL = 1;
                APJP.APJP_REMOTE_HTTP_SERVER_REQUEST_URL = new String[10];
                APJP.APJP_REMOTE_HTTP_SERVER_REQUEST_PROPERTY_KEY = new String[10][5];
                APJP.APJP_REMOTE_HTTP_SERVER_REQUEST_PROPERTY_VALUE = new String[10][5];
                for (int i = 0; i < APJP.APJP_REMOTE_HTTP_SERVER_REQUEST_PROPERTY_KEY.length; i = i + 1) {
                    APJP.APJP_REMOTE_HTTP_SERVER_REQUEST_URL[i] = properties.getProperty("APJP_REMOTE_HTTP_SERVER_" + (i + 1) + "_REQUEST_URL", "");
                    for (int j = 0; j < APJP.APJP_REMOTE_HTTP_SERVER_REQUEST_PROPERTY_KEY[i].length; j = j + 1) {
                        APJP.APJP_REMOTE_HTTP_SERVER_REQUEST_PROPERTY_KEY[i][j] = properties.getProperty("APJP_REMOTE_HTTP_SERVER_" + (i + 1) + "_REQUEST_PROPERTY_" + (j + 1) + "_KEY", "");
                        APJP.APJP_REMOTE_HTTP_SERVER_REQUEST_PROPERTY_VALUE[i][j] = properties.getProperty("APJP_REMOTE_HTTP_SERVER_" + (i + 1) + "_REQUEST_PROPERTY_" + (j + 1) + "_VALUE", "");
                    }
                }
                APJP.APJP_LOCAL_HTTPS_PROXY_SERVER_ADDRESS = properties.getProperty("APJP_LOCAL_HTTPS_PROXY_SERVER_ADDRESS", "");
                try {
                    APJP.APJP_LOCAL_HTTPS_PROXY_SERVER_PORT = new Integer(properties.getProperty("APJP_LOCAL_HTTPS_PROXY_SERVER_PORT", "0"));
                } catch (Exception e) {
                    APJP.APJP_LOCAL_HTTPS_PROXY_SERVER_PORT = 0;
                }
                APJP.APJP_LOCAL_HTTPS_PROXY_SERVER_LOGGER_ID = "APJP_LOCAL_HTTPS_PROXY_SERVER";
                APJP.APJP_LOCAL_HTTPS_PROXY_SERVER_LOGGER_LEVEL = 1;
                APJP.APJP_LOCAL_HTTPS_SERVER_ADDRESS = properties.getProperty("APJP_LOCAL_HTTPS_SERVER_ADDRESS", "");
                try {
                    APJP.APJP_LOCAL_HTTPS_SERVER_PORT = new Integer(properties.getProperty("APJP_LOCAL_HTTPS_SERVER_PORT", "0"));
                } catch (Exception e) {
                    APJP.APJP_LOCAL_HTTPS_SERVER_PORT = 0;
                }
                APJP.APJP_LOCAL_HTTPS_SERVER_LOGGER_ID = "APJP_LOCAL_HTTPS_SERVER";
                APJP.APJP_LOCAL_HTTPS_SERVER_LOGGER_LEVEL = 1;
                APJP.APJP_REMOTE_HTTPS_SERVER_REQUEST_URL = new String[10];
                APJP.APJP_REMOTE_HTTPS_SERVER_REQUEST_PROPERTY_KEY = new String[10][5];
                APJP.APJP_REMOTE_HTTPS_SERVER_REQUEST_PROPERTY_VALUE = new String[10][5];
                for (int i = 0; i < APJP.APJP_REMOTE_HTTPS_SERVER_REQUEST_PROPERTY_KEY.length; i = i + 1) {
                    APJP.APJP_REMOTE_HTTPS_SERVER_REQUEST_URL[i] = properties.getProperty("APJP_REMOTE_HTTPS_SERVER_" + (i + 1) + "_REQUEST_URL", "");
                    for (int j = 0; j < APJP.APJP_REMOTE_HTTPS_SERVER_REQUEST_PROPERTY_KEY[i].length; j = j + 1) {
                        APJP.APJP_REMOTE_HTTPS_SERVER_REQUEST_PROPERTY_KEY[i][j] = properties.getProperty("APJP_REMOTE_HTTPS_SERVER_" + (i + 1) + "_REQUEST_PROPERTY_" + (j + 1) + "_KEY", "");
                        APJP.APJP_REMOTE_HTTPS_SERVER_REQUEST_PROPERTY_VALUE[i][j] = properties.getProperty("APJP_REMOTE_HTTPS_SERVER_" + (i + 1) + "_REQUEST_PROPERTY_" + (j + 1) + "_VALUE", "");
                    }
                }
                APJP.APJP_HTTP_PROXY_SERVER_ADDRESS = properties.getProperty("APJP_HTTP_PROXY_SERVER_ADDRESS", "");
                try {
                    APJP.APJP_HTTP_PROXY_SERVER_PORT = new Integer(properties.getProperty("APJP_HTTP_PROXY_SERVER_PORT", "0"));
                } catch (Exception e) {
                    APJP.APJP_HTTP_PROXY_SERVER_PORT = 0;
                }
                APJP.APJP_HTTP_PROXY_SERVER_USERNAME = properties.getProperty("APJP_HTTP_PROXY_SERVER_USERNAME", "");
                APJP.APJP_HTTP_PROXY_SERVER_PASSWORD = properties.getProperty("APJP_HTTP_PROXY_SERVER_PASSWORD", "");
                APJP.APJP_HTTPS_PROXY_SERVER_ADDRESS = properties.getProperty("APJP_HTTPS_PROXY_SERVER_ADDRESS", "");
                try {
                    APJP.APJP_HTTPS_PROXY_SERVER_PORT = new Integer(properties.getProperty("APJP_HTTPS_PROXY_SERVER_PORT", "0"));
                } catch (Exception e) {
                    APJP.APJP_HTTPS_PROXY_SERVER_PORT = 0;
                }
                APJP.APJP_HTTPS_PROXY_SERVER_USERNAME = properties.getProperty("APJP_HTTPS_PROXY_SERVER_USERNAME", "");
                APJP.APJP_HTTPS_PROXY_SERVER_PASSWORD = properties.getProperty("APJP_HTTPS_PROXY_SERVER_PASSWORD", "");
                Authenticator.setDefault(new Authenticator() {

                    protected PasswordAuthentication getPasswordAuthentication() {
                        PasswordAuthentication passwordAuthentication = null;
                        if (this.getRequestorType() == Authenticator.RequestorType.PROXY) {
                            if (this.getRequestingURL().getProtocol().equalsIgnoreCase("HTTP") == true) {
                                passwordAuthentication = new PasswordAuthentication(APJP.APJP_HTTP_PROXY_SERVER_USERNAME, APJP.APJP_HTTP_PROXY_SERVER_PASSWORD.toCharArray());
                            } else {
                                if (this.getRequestingURL().getProtocol().equalsIgnoreCase("HTTPS") == true) {
                                    passwordAuthentication = new PasswordAuthentication(APJP.APJP_HTTPS_PROXY_SERVER_USERNAME, APJP.APJP_HTTPS_PROXY_SERVER_PASSWORD.toCharArray());
                                }
                            }
                        }
                        return passwordAuthentication;
                    }
                });
                logger = Logger.getLogger(APJP.APJP_LOGGER_ID);
                final ProxyServer proxyServer = new ProxyServer();
                final JTextArea outputTextArea = new JTextArea();
                outputTextArea.setEditable(false);
                outputTextArea.setLineWrap(true);
                outputTextArea.setBackground(new Color(0, 0, 0));
                outputTextArea.setForeground(new Color(255, 255, 255));
                outputTextArea.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 12));
                final JScrollPane outputScrollPane = new JScrollPane(outputTextArea);
                final OutputStream outputStream = new OutputStream() {

                    public void write(final int b) throws IOException {
                        outputTextArea.append(new String(new char[] { (char) b }));
                    }

                    public void write(final byte[] b, final int off, final int len) throws IOException {
                        outputTextArea.append(new String(b, off, len));
                    }
                };
                final PrintStream printStream = new PrintStream(outputStream, true);
                System.setOut(printStream);
                final JButton startButton = new JButton();
                startButton.setText("Start");
                startButton.setPreferredSize(new Dimension(100, 30));
                startButton.addActionListener(new ActionListener() {

                    public void actionPerformed(final ActionEvent actionEvent) {
                        outputTextArea.setText("");
                        logger.log(1, "START_PROXY_SERVER");
                        try {
                            proxyServer.start();
                            logger.log(1, "START_PROXY_SERVER: OK");
                        } catch (Exception e) {
                            logger.log(1, "START_PROXY_SERVER: EXCEPTION", e);
                            logger.log(1, "START_PROXY_SERVER: NOT OK");
                        }
                        HTTPRequests httpRequests = HTTPRequests.getHTTPRequests();
                        logger.log(1, "TEST_HTTP_REQUESTS");
                        try {
                            httpRequests.test();
                            logger.log(1, "TEST_HTTP_REQUESTS: OK");
                        } catch (Exception e) {
                            logger.log(1, "TEST_HTTP_REQUESTS: EXCEPTION", e);
                            logger.log(1, "TEST_HTTP_REQUESTS: NOT OK");
                        }
                        HTTPSRequests httpsRequests = HTTPSRequests.getHTTPSRequests();
                        logger.log(1, "TEST_HTTPS_REQUESTS");
                        try {
                            httpsRequests.test();
                            logger.log(1, "TEST_HTTPS_REQUESTS: OK");
                        } catch (Exception e) {
                            logger.log(1, "TEST_HTTPS_REQUESTS: EXCEPTION", e);
                            logger.log(1, "TEST_HTTPS_REQUESTS: NOT OK");
                        }
                    }
                });
                final JButton stopButton = new JButton();
                stopButton.setText("Stop");
                stopButton.setPreferredSize(new Dimension(100, 30));
                stopButton.addActionListener(new ActionListener() {

                    public void actionPerformed(final ActionEvent actionEvent) {
                        outputTextArea.setText("");
                        logger.log(1, "STOP_PROXY_SERVER");
                        try {
                            proxyServer.stop();
                            logger.log(1, "STOP_PROXY_SERVER: OK");
                        } catch (Exception e) {
                            logger.log(1, "STOP_PROXY_SERVER: EXCEPTION", e);
                            logger.log(1, "STOP_PROXY_SERVER: NOT OK");
                        }
                    }
                });
                final Panel buttonPanel = new Panel();
                buttonPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
                buttonPanel.add(startButton);
                buttonPanel.add(stopButton);
                final ImageIcon imageIcon = new ImageIcon("APJP_LOCAL.png");
                final JFrame frame = new JFrame();
                frame.setIconImage(imageIcon.getImage());
                frame.setSize(675, 375);
                frame.setResizable(false);
                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                frame.setLayout(new BorderLayout());
                frame.add(buttonPanel, BorderLayout.NORTH);
                frame.add(outputScrollPane, BorderLayout.CENTER);
                if (SystemTray.isSupported()) {
                    final TrayIcon trayIcon = new TrayIcon(imageIcon.getImage());
                    trayIcon.setImageAutoSize(true);
                    trayIcon.addActionListener(new ActionListener() {

                        public void actionPerformed(final ActionEvent actionEvent) {
                            frame.setVisible(!frame.isVisible());
                        }
                    });
                    SystemTray.getSystemTray().add(trayIcon);
                }
                frame.setVisible(true);
            } catch (Exception e) {
                logger.log(1, "EXCEPTION", e);
            }
        }
    });
}
Also used : ImageIcon(javax.swing.ImageIcon) JTextArea(javax.swing.JTextArea) FlowLayout(java.awt.FlowLayout) ActionEvent(java.awt.event.ActionEvent) OutputStream(java.io.OutputStream) JButton(javax.swing.JButton) HTTPRequests(APJP.HTTP11.HTTPRequests) Properties(java.util.Properties) Font(java.awt.Font) HTTPSRequests(APJP.HTTP11.HTTPSRequests) BorderLayout(java.awt.BorderLayout) JFrame(javax.swing.JFrame) TrayIcon(java.awt.TrayIcon) IAIK(iaik.security.provider.IAIK) Authenticator(java.net.Authenticator) PasswordAuthentication(java.net.PasswordAuthentication) JScrollPane(javax.swing.JScrollPane) PrintStream(java.io.PrintStream) Color(java.awt.Color) IOException(java.io.IOException) Dimension(java.awt.Dimension) FileInputStream(java.io.FileInputStream) IOException(java.io.IOException) ProxyServer(APJP.ProxyServer) Panel(java.awt.Panel) ActionListener(java.awt.event.ActionListener)

Example 24 with BorderLayout

use of java.awt.BorderLayout in project openblocks by mikaelhg.

the class WorkspaceController method initWorkspacePanel.

/**
     * This method creates and lays out the entire workspace panel with its
     * different components.  Workspace and language data not loaded in
     * this function.
     * Should be call only once at application startup.
     */
private void initWorkspacePanel() {
    workspacePanel = new JPanel();
    workspacePanel.setLayout(new BorderLayout());
    workspacePanel.add(workspace, BorderLayout.CENTER);
    isWorkspacePanelInitialized = true;
}
Also used : JPanel(javax.swing.JPanel) BorderLayout(java.awt.BorderLayout)

Example 25 with BorderLayout

use of java.awt.BorderLayout in project jodd by oblac.

the class SwingSpy method initSpyDialog.

/**
	 * Initializes Spy dialog.
	 */
protected void initSpyDialog(Component rootComponent, Component component) {
    if (rootComponent instanceof Dialog) {
        spyDialog = new CaddyDialog((Dialog) rootComponent) {

            @Override
            protected JRootPane createRootPane() {
                return createSpyRootPane();
            }
        };
    } else if (rootComponent instanceof Frame) {
        spyDialog = new CaddyDialog((Frame) rootComponent) {

            @Override
            protected JRootPane createRootPane() {
                return createSpyRootPane();
            }
        };
    } else {
        spyDialog = new JDialog() {

            @Override
            protected JRootPane createRootPane() {
                return createSpyRootPane();
            }
        };
    }
    spyDialog.setName("SwingSpy");
    spyDialog.setTitle("SwingSpy");
    spyDialog.setModal(false);
    spyDialog.setAlwaysOnTop(true);
    Container contentPane = spyDialog.getContentPane();
    contentPane.setLayout(new BorderLayout());
    spyPanel = new SwingSpyPanel();
    spyPanel.reload(rootComponent, component);
    contentPane.add(spyPanel);
    spyDialog.pack();
    spyDialog.addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent e) {
            super.windowClosed(e);
            spyGlass.setVisible(false);
            spyDialog = null;
        }
    });
    spyDialog.setLocationRelativeTo(null);
    spyDialog.setVisible(true);
}
Also used : Frame(java.awt.Frame) RootPaneContainer(javax.swing.RootPaneContainer) Container(java.awt.Container) BorderLayout(java.awt.BorderLayout) JDialog(javax.swing.JDialog) Dialog(java.awt.Dialog) WindowEvent(java.awt.event.WindowEvent) WindowAdapter(java.awt.event.WindowAdapter) JRootPane(javax.swing.JRootPane) JDialog(javax.swing.JDialog)

Aggregations

BorderLayout (java.awt.BorderLayout)761 JPanel (javax.swing.JPanel)514 JLabel (javax.swing.JLabel)238 JScrollPane (javax.swing.JScrollPane)191 Dimension (java.awt.Dimension)155 JButton (javax.swing.JButton)134 FlowLayout (java.awt.FlowLayout)90 ActionEvent (java.awt.event.ActionEvent)88 JTextField (javax.swing.JTextField)85 EmptyBorder (javax.swing.border.EmptyBorder)73 ActionListener (java.awt.event.ActionListener)70 JCheckBox (javax.swing.JCheckBox)69 Insets (java.awt.Insets)64 BoxLayout (javax.swing.BoxLayout)62 GridBagConstraints (java.awt.GridBagConstraints)57 GridBagLayout (java.awt.GridBagLayout)57 JTable (javax.swing.JTable)57 JTextArea (javax.swing.JTextArea)52 GridLayout (java.awt.GridLayout)49 Box (javax.swing.Box)45