Example usage for java.awt BorderLayout BorderLayout

List of usage examples for java.awt BorderLayout BorderLayout

Introduction

In this page you can find the example usage for java.awt BorderLayout BorderLayout.

Prototype

public BorderLayout() 

Source Link

Document

Constructs a new border layout with no gaps between components.

Usage

From source file:MouseDragClip.java

public static void main(String[] av) {
    JFrame f = new JFrame("Mouse Dragger");
    Container cp = f.getContentPane();

    if (av.length < 1) {
        System.err.println("Usage: MouseDragClip imagefile");
        System.exit(1);//  www .ja  v  a 2  s.  c o m
    }
    Image im = Toolkit.getDefaultToolkit().getImage(av[0]);

    // create a MouseDragClip object
    MouseDragClip j = new MouseDragClip(im);

    cp.setLayout(new BorderLayout());
    cp.add(BorderLayout.NORTH, new Label("Hello, and welcome to the world of Java"));
    cp.add(BorderLayout.CENTER, j);
    cp.add(BorderLayout.SOUTH, status = new Label());
    status.setSize(f.getSize().width, status.getSize().height);
    f.pack();
    f.setVisible(true);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}

From source file:BufferedDraw.java

public static void main(String s[]) {

    JFrame f = new JFrame("BufferedShapeMover");
    f.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);//from w w  w.j  av  a 2s . c o m
        }
    });
    f.getContentPane().setLayout(new BorderLayout());
    f.getContentPane().add(new BufferedDraw(), "Center");

    f.pack();
    f.setSize(new Dimension(550, 250));
    f.show();
}

From source file:SimpleClient.java

public static void main(String argv[]) {
    boolean usage = false;

    for (int optind = 0; optind < argv.length; optind++) {
        if (argv[optind].equals("-L")) {
            url.addElement(argv[++optind]);
        } else if (argv[optind].startsWith("-")) {
            usage = true;//from  w ww. j  av a  2 s.  co m
            break;
        } else {
            usage = true;
            break;
        }
    }

    if (usage || url.size() == 0) {
        System.out.println("Usage: SimpleClient -L url");
        System.out.println("   where url is protocol://username:password@hostname/");
        System.exit(1);
    }

    try {
        // Set up our Mailcap entries.  This will allow the JAF
        // to locate our viewers.
        File capfile = new File("simple.mailcap");
        if (!capfile.isFile()) {
            System.out.println("Cannot locate the \"simple.mailcap\" file.");
            System.exit(1);
        }

        CommandMap.setDefaultCommandMap(new MailcapCommandMap(new FileInputStream(capfile)));

        JFrame frame = new JFrame("Simple JavaMail Client");
        frame.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
                System.exit(0);
            }
        });
        //frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

        // Get a Store object
        SimpleAuthenticator auth = new SimpleAuthenticator(frame);
        Session session = Session.getDefaultInstance(System.getProperties(), auth);
        //session.setDebug(true);

        DefaultMutableTreeNode root = new DefaultMutableTreeNode("Root");

        // create a node for each store we have
        for (Enumeration e = url.elements(); e.hasMoreElements();) {
            String urlstring = (String) e.nextElement();
            URLName urln = new URLName(urlstring);
            Store store = session.getStore(urln);

            StoreTreeNode storenode = new StoreTreeNode(store);
            root.add(storenode);
        }

        DefaultTreeModel treeModel = new DefaultTreeModel(root);
        JTree tree = new JTree(treeModel);
        tree.addTreeSelectionListener(new TreePress());

        /* Put the Tree in a scroller. */
        JScrollPane sp = new JScrollPane();
        sp.setPreferredSize(new Dimension(250, 300));
        sp.getViewport().add(tree);

        /* Create a double buffered JPanel */
        JPanel sv = new JPanel(new BorderLayout());
        sv.add("Center", sp);

        fv = new FolderViewer(null);

        JSplitPane jsp = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, sv, fv);
        jsp.setOneTouchExpandable(true);
        mv = new MessageViewer();
        JSplitPane jsp2 = new JSplitPane(JSplitPane.VERTICAL_SPLIT, jsp, mv);
        jsp2.setOneTouchExpandable(true);

        frame.getContentPane().add(jsp2);
        frame.pack();
        frame.show();

    } catch (Exception ex) {
        System.out.println("SimpletClient caught exception");
        ex.printStackTrace();
        System.exit(1);
    }
}

From source file:moviedatas.MovieDatas.java

public static void main(String[] args) {
    FilterController fpc = new FilterController();

    SortController spc = new SortController();

    //1. Create the frame.
    JFrame frame = new JFrame("Movies Open Datas by Harp-e");
    frame.setPreferredSize(new Dimension(1280, 800));

    //2. Optional: What happens when the frame closes?
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    MovieListView movieListView = new MovieListView();
    JPanel movieListPanel = movieListView.createViewPanel();
    TitledBorder moviesTitle;//from  w  w  w. j a v  a  2  s.c o m
    moviesTitle = BorderFactory.createTitledBorder("Movies");
    movieListPanel.setBorder(moviesTitle);

    //3. Create components and put them in the frame.
    //----------------------------------------------------------------------
    // Sort & Filter panel (right)
    //----------------------------------------------------------------------
    SortPanelView sortFilterView = new SortPanelView();
    FilterPanelView filterPanelView = new FilterPanelView();

    JPanel sortPanel = sortFilterView.createSortPanel();
    JPanel filterPanel = filterPanelView.createFilterPanel();
    JPanel sortFilterPanel = new JPanel();

    sortFilterPanel.setLayout(new BoxLayout(sortFilterPanel, BoxLayout.PAGE_AXIS));

    sortFilterPanel.add(sortPanel);
    sortFilterPanel.add(filterPanel);

    frame.getContentPane().add(sortFilterPanel, BorderLayout.WEST);
    //----------------------------------------------------------------------
    // Movie Info Panel (left)
    //----------------------------------------------------------------------
    MovieInfoController movieInfoController = new MovieInfoController();
    JPanel movieInfoView = movieInfoController.initView();
    TitledBorder infoTitle;
    infoTitle = BorderFactory.createTitledBorder("Informations");
    movieInfoView.setBorder(infoTitle);
    //----------------------------------------------------------------------
    // Movie List Panel (middle)
    //----------------------------------------------------------------------   
    JPanel listPanel = new JPanel();
    listPanel.setLayout(new BorderLayout());
    listPanel.setPreferredSize(new Dimension(1280, 400));
    listPanel.add(sortFilterPanel, BorderLayout.WEST);
    listPanel.add(movieInfoView, BorderLayout.EAST);
    listPanel.add(movieListPanel, BorderLayout.CENTER);
    frame.getContentPane().add(listPanel, BorderLayout.NORTH);
    //----------------------------------------------------------------------
    // Charts Panel (bottom)
    //----------------------------------------------------------------------
    JPanel chartPanel = new JPanel();

    // Spider chart Panel
    //______________________________________________________________________
    // Create the panel
    JPanel spiderPanel = new JPanel();
    // Create the view
    SpiderChartView spiderChartView = new SpiderChartView();
    // Create a tilte
    TitledBorder spiderTitle;
    // Put a border around the title
    spiderTitle = BorderFactory.createTitledBorder("Spider chart");
    // Put the border on the panel
    spiderPanel.setBorder(spiderTitle);
    // Put the view on the panel
    spiderPanel.add(spiderChartView.initView());
    // Put the spider panel on the global panel
    chartPanel.add(spiderPanel);
    //______________________________________________________________________

    // Bar chart Panel
    //______________________________________________________________________
    JPanel barPanel = new JPanel();
    BarChartView barChartView = new BarChartView();
    TitledBorder barTitle;
    barTitle = BorderFactory.createTitledBorder("Bar chart");
    barPanel.setBorder(barTitle);
    barPanel.add(barChartView.initView());
    chartPanel.add(barPanel);
    //______________________________________________________________________

    // Global chart Panel
    //______________________________________________________________________
    JPanel globalChartPanel = new JPanel();
    GlobalChart globalChartView = new GlobalChart();
    TitledBorder globalTitle;
    globalTitle = BorderFactory.createTitledBorder("Global chart");
    globalChartPanel.setBorder(globalTitle);
    globalChartPanel.add(globalChartView.initView());
    chartPanel.add(globalChartPanel);
    //______________________________________________________________________

    frame.getContentPane().add(chartPanel, BorderLayout.CENTER);
    //----------------------------------------------------------------------

    //4. Size the frame.
    frame.pack();

    //5. Show it.
    frame.setVisible(true);
    //ArrayList<Movie> movies = new ArrayList<>();
    //FilterController.filter(10,SortController.byTitle(movies));

}

From source file:flow.visibility.FlowMain.java

public static void main(String[] args) throws Exception {

    /************************************************************** 
     * Creating the Main GUI /*from   ww  w. j  a  v  a  2 s.  c  om*/
     **************************************************************/

    final JDesktopPane desktop = new JDesktopPane();

    final JMenuBar mb = new JMenuBar();
    JMenu menu;

    /** Add File Menu to Open File and Save Result */

    menu = new JMenu("File");
    JMenuItem Open = new JMenuItem("Open");
    JMenuItem Save = new JMenuItem("Save");
    menu.add(Open);
    menu.add(Save);

    menu.addSeparator();
    JMenuItem Exit = new JMenuItem("Exit");
    menu.add(Exit);
    Exit.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            System.exit(0);
        }
    });

    mb.add(menu);

    /** Add Control Menu to Start and Stop Capture */

    menu = new JMenu("Control");
    JMenuItem Start = new JMenuItem("Start Capture");
    JMenuItem Stop = new JMenuItem("Stop Capture");
    menu.add(Start);
    Start.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            FlowDumper.main(false);
        }
    });

    menu.add(Stop);
    Stop.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            FlowDumper.main(true);
        }
    });

    mb.add(menu);

    /** Add Configuration Menu for Tapping and Display */

    menu = new JMenu("Configuration");
    JMenuItem Tapping = new JMenuItem("Tapping Configuration");
    JMenuItem Display = new JMenuItem("Display Configuration");
    menu.add(Tapping);
    Tapping.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            FlowTapping.main(null);
        }
    });
    menu.add(Display);

    mb.add(menu);

    /** Add Detail Menu for NetGrok Visualization and JEthereal Inspection */

    menu = new JMenu("Flow Detail");
    JMenuItem FlowVisual = new JMenuItem("Flow Visualization");
    JMenuItem FlowInspect = new JMenuItem("Flow Inspections");
    menu.add(FlowVisual);
    FlowVisual.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            NetworkView.main(null);
        }
    });
    menu.add(FlowInspect);
    FlowInspect.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            Ethereal.main(null);
        }
    });
    mb.add(menu);

    /** Add Help Menu for Software Information */
    menu = new JMenu("Help");
    JMenuItem About = new JMenuItem("About");
    menu.add(About);
    About.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            JOptionPane.showMessageDialog(null, "OF@TEIN Flow Visibility Tools @ 2015 by GIST",
                    "About the Software", JOptionPane.PLAIN_MESSAGE);
        }
    });
    mb.add(menu);

    /** Creating the main frame */
    JFrame frame = new JFrame("OF@TEIN Flow Visibility Tools");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setLayout(new BorderLayout());
    frame.add(desktop);
    frame.setJMenuBar(mb);
    frame.setSize(1215, 720);
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);

    /**Add Blank three (3) Internal Jframe*/

    /**Internal Frame from Flow Summary Chart*/
    JInternalFrame FlowStatistic = new JInternalFrame("Flow Statistic", true, true, true, true);
    FlowStatistic.setBounds(0, 0, 600, 330);
    ChartPanel chartPanel = new ChartPanel(createChart(null));
    chartPanel.setMouseZoomable(true, false);
    FlowStatistic.add(chartPanel);
    FlowStatistic.setVisible(true);
    desktop.add(FlowStatistic);

    /**Internal Frame from Flow Summary Text*/
    JInternalFrame FlowSummary = new JInternalFrame("Flow Summary", true, true, true, true);
    FlowSummary.setBounds(0, 331, 600, 329);
    JTextArea textArea = new JTextArea(50, 10);
    JScrollPane scrollPane = new JScrollPane(textArea);
    FlowSummary.add(scrollPane);
    FlowSummary.setVisible(true);
    desktop.add(FlowSummary);

    //JInternalFrame FlowInspection = new JInternalFrame("Flow Inspection", true, true, true, true);
    //FlowInspection.setBounds(601, 0, 600, 660);
    //JTextArea textArea2 = new JTextArea(50, 10);
    //JScrollPane scrollPane2 = new JScrollPane(textArea2);
    //FlowInspection.add(scrollPane2);
    //FlowInspection.setVisible(true);
    //desktop.add(FlowInspection);

    /**Internal Frame from Printing the Packet Sequence*/
    JInternalFrame FlowSequence = new JInternalFrame("Flow Sequence", true, true, true, true);
    FlowSequence.setBounds(601, 0, 600, 660);
    JTextArea textArea3 = new JTextArea(50, 10);
    JScrollPane scrollPane3 = new JScrollPane(textArea3);
    FlowSequence.add(scrollPane3);
    FlowSequence.setVisible(true);
    desktop.add(FlowSequence);

    /************************************************************** 
     * Update the Frame Regularly
     **************************************************************/

    /** Regularly update the Frame Content every 3 seconds */

    for (;;) {

        desktop.removeAll();
        desktop.add(FlowProcess.FlowStatistic());
        desktop.add(FlowProcess.FlowSummary());
        //desktop.add(FlowProcess.FlowInspection());
        desktop.add(FlowProcess.FlowSequence());
        desktop.revalidate();
        Thread.sleep(10000);

    }

}

From source file:ColorSink.java

/** This is a simple test program for ColorSource and ColorSink */
public static void main(String[] args) {
    // Create a window
    JFrame f = new JFrame("ColorSourceTest");
    f.getContentPane().setLayout(new BorderLayout());

    // Add some ColorSources
    JPanel panel = new JPanel();
    f.getContentPane().add(panel, BorderLayout.NORTH);
    panel.add(new ColorSource(Color.yellow));
    panel.add(new ColorSource(Color.pink));
    panel.add(new ColorSource(Color.white));
    panel.add(new ColorSource(Color.gray));

    // Add a ColorSink
    ColorSink sink = new ColorSink();
    f.getContentPane().add(sink, BorderLayout.CENTER);

    // Pop it all up
    f.setSize(400, 300);// www . j  a  v  a  2 s.c om
    f.show();
}

From source file:gda.gui.BatonPanel.java

/**
 * Auto-generated main method to display this JPanel inside a new JFrame.
 * // ww w  .j a v  a  2s  . c o m
 * @param args
 */
public static void main(String[] args) {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    frame.pack();
    frame.setSize(792, 419);
    frame.setPreferredSize(new java.awt.Dimension(792, 419));
    frame.setVisible(true);
    {
        batonPanel_IL = new BatonPanel();
        frame.getContentPane().add(batonPanel_IL, BorderLayout.CENTER);
        BorderLayout batonPanel_ILLayout = new BorderLayout();
        batonPanel_IL.setLayout(batonPanel_ILLayout);
    }
}

From source file:projects.tgas.exec.HrDiagram.java

/**
 * Main application entry point.//  ww w  .  ja  v a  2  s.  c  o m
 * @param args
 *    The args - ignored.
 */
public static void main(String[] args) {

    final JFrame frame = new JFrame("TGAS HR diagram");

    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.setLayout(new BorderLayout());
            frame.add(new HrDiagram(), BorderLayout.CENTER);
            frame.setSize(1500, 750);
            frame.pack();
            frame.setVisible(true);
        }
    });
}

From source file:lu.lippmann.cdb.weka.SilhouetteUtil.java

public static void main(String[] args) throws Exception {
    final Instances ds = WekaDataAccessUtil.loadInstancesFromARFFOrCSVFile(
            //new File("./samples/csv/uci/zoo.csv"));
            //new File("./samples/arff/UCI/cmc.arff"));
            //new File("./samples/csv/direct-marketing-bank-reduced.csv"));
            //new File("./samples/csv/bank.csv"));
            //new File("./samples/csv/preswissroll.csv"));
            new File("./samples/csv/iris.csv"));
    //new File("./samples/csv/lines.csv"));
    //new File("./samples/csv/pima.csv"));
    //new File("./samples/csv/isolet.csv"));
    //new File("./samples/csv/iris.csv"));

    final SimpleKMeans kmeans = WekaMachineLearningUtil.buildSimpleKMeansClustererWithK(3);

    final WekaClusteringResult cr = WekaMachineLearningUtil.computeClusters(kmeans, ds);

    final JFrame mainFrame = new JFrame();
    mainFrame.setTitle("Silhouette plot");
    mainFrame.setBackground(Color.WHITE);
    LogoHelper.setLogo(mainFrame);/*from   w w  w  .jav  a 2s. c om*/

    mainFrame.getContentPane().setLayout(new BorderLayout());
    mainFrame.getContentPane().add(buildSilhouettePanel(ds, cr), BorderLayout.CENTER);

    mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    mainFrame.setSize(1200, 900);
    mainFrame.setVisible(true);

}

From source file:com.qawaa.gui.PointAnalysisGUI.java

/**
* Auto-generated main method to display this JFrame
*//* w  w  w.j a va  2  s  .c o m*/
public static void main(String[] args) {
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            PointAnalysisGUI inst = new PointAnalysisGUI();
            inst.setLocationRelativeTo(null);
            inst.setVisible(true);
            inst.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            JFrame.setDefaultLookAndFeelDecorated(true);
            FlowLayout flowLayout = new FlowLayout();
            flowLayout.setAlignment(FlowLayout.LEFT);
            flowLayout.setAlignOnBaseline(true);
            inst.setTitle(PROGRAM_NAME + " [" + PROGRAM_VERSION + "] " + " - " + DefaultMessage.SOFT_NAME
                    + " - " + DefaultMessage.COMPANY_NAME);
            {
                consoleScrollPane = new JScrollPane();
                inst.getContentPane().add(consoleScrollPane, BorderLayout.CENTER);
                {
                    consolePane = new JEditorPane();
                    consoleScrollPane.setViewportView(consolePane);
                    consolePane.setText("");
                    setConsoleRight();
                    jConsole = new JConsole(System.out, consolePane);
                    System.setOut(jConsole);
                    System.setErr(jConsole);
                    consolePane.setEditable(false);
                    consolePane.addMouseListener(new MouseAdapter() {
                        /* (non-Javadoc)
                         * @see java.awt.event.MouseAdapter#mouseReleased(java.awt.event.MouseEvent)
                         */
                        public void mouseReleased(MouseEvent e) {
                            if (e.getButton() == MouseEvent.BUTTON3) {
                                consolePane.add(consoleRight);
                                consoleRight.show(e.getComponent(), e.getX(), e.getY());
                            }
                        }
                    });
                }
            }
            {
                infoPanel = new JPanel();
                inst.getContentPane().add(infoPanel, BorderLayout.SOUTH);
                infoPanel.setBorder(new LineBorder(new Color(0, 0, 0), 1, false));
                infoPanel.setPreferredSize(new Dimension(784, 30));
                infoPanel.setLayout(flowLayout);
                {
                    {
                        statusbar_count = new JTextPane();
                        infoPanel.add(statusbar_count);
                        statusbar_count
                                .setText(CONTEXT.getMessage("point.statusbar.count", null, Locale.CHINA));
                        statusbar_count.setBackground(null);
                        statusbar_count.setEditable(false);
                    }
                    {
                        statusbar_count_value = new JTextPane();
                        infoPanel.add(statusbar_count_value);
                        statusbar_count_value.setText(String.valueOf(SCAN_COUNT));
                        statusbar_count_value.setBackground(null);
                        statusbar_count_value.setEditable(false);
                        statusbar_count_value.setEnabled(false);
                    }
                    {
                        programPID = new JTextPane();
                        infoPanel.add(programPID);
                        programPID.setText("PID:");
                        programPID.setBackground(null);
                        programPID.setEditable(false);
                    }
                    {
                        programPID_value = new JTextPane();
                        infoPanel.add(programPID_value);
                        programPID_value.setText(JvmPid.getPID());
                        programPID_value.setBackground(null);
                        programPID_value.setEditable(false);
                        programPID_value.setEnabled(false);
                    }
                    {
                        memory = new JTextPane();
                        infoPanel.add(memory);
                        memory.setText(CONTEXT.getMessage("gobal.gui.memory", null, Locale.CHINA));
                        memory.setBackground(null);
                        memory.setEditable(false);
                    }
                    {
                        memory_value = new JTextPane();
                        infoPanel.add(memory_value);
                        memory_value.setText("0KB");
                        memory_value.setBackground(null);
                        memory_value.setEditable(false);
                        memory_value.setEnabled(false);
                        MemoryListener memory = new MemoryListener(memory_value);
                        memory.start();
                    }
                    {
                        runtime = new JTextPane();
                        infoPanel.add(runtime);
                        runtime.setText(CONTEXT.getMessage("gobal.gui.runtime", null, Locale.CHINA));
                        runtime.setBackground(null);
                        runtime.setEditable(false);
                    }
                    {
                        runtime_value = new JTextPane();
                        infoPanel.add(runtime_value);
                        runtime_value.setText("NULL");
                        runtime_value.setBackground(null);
                        runtime_value.setEditable(false);
                        runtime_value.setEnabled(false);
                    }
                }
            }
            {
                shortcut = new JPanel();
                inst.getContentPane().add(shortcut, BorderLayout.NORTH);
                shortcut.setSize(784, 35);
                shortcut.setPreferredSize(new Dimension(784, 35));
                shortcut.setBorder(new LineBorder(new Color(0, 0, 0), 1, false));
                shortcut.setLayout(new BorderLayout());
                {
                    eventText = new JTextPane();
                    shortcut.add(eventText, BorderLayout.WEST);
                    eventText.setText(CONTEXT.getMessage("point.event.name", null, Locale.CHINA) + ": ");
                    eventText.setEditable(false);
                    eventText.setEnabled(true);
                    eventText.setBackground(null);
                    eventText.setCaretColor(new Color(0, 0, 0));
                }
                {
                    eventTextField = new JTextField();
                    shortcut.add(eventTextField, BorderLayout.CENTER);
                    eventTextField.setSize(500, 25);
                    eventTextField.setText("");
                    eventTextField.setPreferredSize(new Dimension(500, 25));
                    eventTextField.setEditable(false);
                }
                {
                    submit = new JButton();
                    shortcut.add(submit, BorderLayout.EAST);
                    submit.setText(CONTEXT.getMessage("gobal.gui.button.run", null, Locale.CHINA));
                    submit.setSize(new Dimension(75, 25));
                    submit.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            try {
                                submitActionPerformed(evt);
                            } catch (InterruptedException e) {
                                e.printStackTrace();
                            }
                        }
                    });
                }
            }
        }
    });

}