Example usage for java.awt BorderLayout PAGE_START

List of usage examples for java.awt BorderLayout PAGE_START

Introduction

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

Prototype

String PAGE_START

To view the source code for java.awt BorderLayout PAGE_START.

Click Source Link

Document

The component comes before the first line of the layout's content.

Usage

From source file:Main.java

public Main() {
    setLayout(new BorderLayout());
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setSize(500, 200);//  ww  w  .jav  a2 s  .  c o m
    add(createToolBar(), BorderLayout.PAGE_START);

    setVisible(true);
}

From source file:Main.java

private void addComponentsToPane() {

    JButton button = new JButton("Clear");
    button.addActionListener(this);

    typingArea = new JTextField(20);
    typingArea.addKeyListener(this);

    getContentPane().add(typingArea, BorderLayout.PAGE_START);
    getContentPane().add(button, BorderLayout.PAGE_END);
}

From source file:Main.java

private void addComponentsToPane() {

    JButton button = new JButton("Clear");
    button.addActionListener(this);

    typingArea = new JTextField(20);
    typingArea.addKeyListener(this);

    displayArea = new JTextArea();
    displayArea.setEditable(false);//from w  ww  .  ja  va 2s.  c o  m
    JScrollPane scrollPane = new JScrollPane(displayArea);
    scrollPane.setPreferredSize(new Dimension(375, 125));

    getContentPane().add(typingArea, BorderLayout.PAGE_START);
    getContentPane().add(scrollPane, BorderLayout.CENTER);
    getContentPane().add(button, BorderLayout.PAGE_END);
}

From source file:layout.BorderLayoutDemo.java

public static void addComponentsToPane(Container pane) {

    if (!(pane.getLayout() instanceof BorderLayout)) {
        pane.add(new JLabel("Container doesn't use BorderLayout!"));
        return;/*from  w w w .  ja  va 2s.c o  m*/
    }

    if (RIGHT_TO_LEFT) {
        pane.setComponentOrientation(java.awt.ComponentOrientation.RIGHT_TO_LEFT);
    }

    JButton button = new JButton("Button 1 (PAGE_START)");
    pane.add(button, BorderLayout.PAGE_START);

    //Make the center component big, since that's the
    //typical usage of BorderLayout.
    button = new JButton("Button 2 (CENTER)");
    button.setPreferredSize(new Dimension(200, 100));
    pane.add(button, BorderLayout.CENTER);

    button = new JButton("Button 3 (LINE_START)");
    pane.add(button, BorderLayout.LINE_START);

    button = new JButton("Long-Named Button 4 (PAGE_END)");
    pane.add(button, BorderLayout.PAGE_END);

    button = new JButton("5 (LINE_END)");
    pane.add(button, BorderLayout.LINE_END);
}

From source file:Main.java

public void build() {
    setSize(600, 600);//from   www.  j  a v a 2s  .com
    JTextPane textPane = new JTextPane();

    JScrollPane scrollPane = new JScrollPane(textPane);
    scrollPane.setPreferredSize(new Dimension(300, 300));

    JTextArea changeLog = new JTextArea(5, 30);
    changeLog.setEditable(false);
    JScrollPane scrollPaneForLog = new JScrollPane(changeLog);

    JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, scrollPane, scrollPaneForLog);
    splitPane.setOneTouchExpandable(true);

    JPanel statusPane = new JPanel(new GridLayout(1, 1));
    JLabel caretListenerLabel = new JLabel("Caret Status");
    statusPane.add(caretListenerLabel);

    JToolBar toolBar = new JToolBar();
    toolBar.add(new JButton("Btn1"));
    toolBar.add(new JButton("Btn2"));
    toolBar.add(new JButton("Btn3"));
    toolBar.add(new JButton("Btn4"));

    getContentPane().add(toolBar, BorderLayout.PAGE_START);
    getContentPane().add(splitPane, BorderLayout.CENTER);
    getContentPane().add(statusPane, BorderLayout.PAGE_END);

    JMenu editMenu = new JMenu("test");
    JMenu styleMenu = new JMenu("test");
    JMenuBar mb = new JMenuBar();
    mb.add(editMenu);
    mb.add(styleMenu);
    setJMenuBar(mb);

}

From source file:Main.java

Main() {
    gui.setBorder(new EmptyBorder(2, 3, 2, 3));

    String userDirLocation = System.getProperty("user.dir");
    File userDir = new File(userDirLocation);
    // default to user directory
    fileChooser = new JFileChooser(userDir);

    Action open = new AbstractAction("Open") {
        @Override/*from   ww w .  j a v  a 2  s.  c  om*/
        public void actionPerformed(ActionEvent e) {
            int result = fileChooser.showOpenDialog(gui);
            if (result == JFileChooser.APPROVE_OPTION) {
                try {
                    File f = fileChooser.getSelectedFile();
                    FileReader fr = new FileReader(f);
                    output.read(fr, f);
                    fr.close();
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            }
        }
    };

    Action save = new AbstractAction("Save") {
        @Override
        public void actionPerformed(ActionEvent e) {
            int result = fileChooser.showSaveDialog(gui);
            System.out.println("Not supported yet.");
        }
    };

    JToolBar tb = new JToolBar();
    gui.add(tb, BorderLayout.PAGE_START);
    tb.add(open);
    tb.add(save);

    gui.add(new JScrollPane(output));
}

From source file:Main.java

public Main() {
    super(new BorderLayout());
    JProgressBar progressBar = new JProgressBar(0, 100);
    progressBar.setValue(0);/* w w  w.  ja  va  2 s.c  o  m*/
    progressBar.setStringPainted(true);

    taskOutput = new JTextArea(5, 20);
    taskOutput.setEditable(false);

    startButton = new JButton("Start");
    startButton.setActionCommand("start");
    startButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            startButton.setEnabled(false);
            setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));

            final Task task = new Task();
            task.addPropertyChangeListener(new PropertyChangeListener() {
                @Override
                public void propertyChange(PropertyChangeEvent pce) {
                    if ("progress".equals(pce.getPropertyName())) {
                        int progress = (Integer) pce.getNewValue();
                        progressBar.setValue(progress);
                        taskOutput.append(String.format("Completed %d%% of task.\n", task.getProgress()));
                    }
                }
            });
            task.execute();
        }
    });

    JPanel panel = new JPanel();
    panel.add(startButton);
    panel.add(progressBar);

    add(panel, BorderLayout.PAGE_START);
    add(new JScrollPane(taskOutput), BorderLayout.CENTER);

}

From source file:FileChooserDemo2.java

public FileChooserDemo2() {
    super(new BorderLayout());

    // Create the log first, because the action listener
    // needs to refer to it.
    log = new JTextArea(5, 20);
    log.setMargin(new Insets(5, 5, 5, 5));
    log.setEditable(false);/* ww w .  j ava 2  s .  c  o  m*/
    JScrollPane logScrollPane = new JScrollPane(log);

    JButton sendButton = new JButton("Attach...");
    sendButton.addActionListener(this);

    add(sendButton, BorderLayout.PAGE_START);
    add(logScrollPane, BorderLayout.CENTER);
}

From source file:s3ml.DFABuilder.java

public DFABuilder() {
    super.setName("DFA Builder");
    super.setLayout(new BorderLayout());

    textArea.setFont(new Font("monospaced", Font.PLAIN, 15));

    add(new JButton(new AbstractAction("Build DFA") {
        {/*from w w w  .  j a v  a  2s . c  o m*/
            setPreferredSize(new Dimension(200, 100));
        }

        @Override
        public void actionPerformed(ActionEvent ae) {
            new Thread() {
                @Override
                public void run() {
                    BuildDFA();
                }
            }.start();
        }
    }), BorderLayout.PAGE_START);

    Layout<State, Transition> layout = new SpringLayout<>(graph);
    layout.setSize(new Dimension(1400, 1300));

    final VisualizationViewer<State, Transition> vv = new VisualizationViewer<>(layout);

    vv.getRenderContext().setVertexLabelTransformer(new Transformer<State, String>() {

        @Override
        public String transform(State i) {
            return i.name + "-" + i.outputSymbol;
        }

    });
    vv.getRenderContext().setEdgeLabelTransformer(new Transformer<Transition, String>() {

        @Override
        public String transform(Transition i) {
            return "" + i.symbol;
        }

    });
    final Stroke stroke = new Stroke() {
        private Stroke stroke1, stroke2;

        {
            this.stroke1 = new BasicStroke(5f);
            this.stroke2 = new BasicStroke(1f);
        }

        @Override
        public Shape createStrokedShape(Shape shape) {
            return stroke2.createStrokedShape(stroke1.createStrokedShape(shape));
        }
    };
    vv.getRenderContext().setVertexStrokeTransformer(new Transformer<State, Stroke>() {
        @Override
        public Stroke transform(State i) {
            if (i.startState) {
                return new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f,
                        new float[] { 2.0f }, 0.0f);
            } else if (i.finalState) {
                return stroke;
            } else {
                return vv.getRenderContext().getGraphicsContext().getStroke();
            }
        }
    });

    vv.getRenderContext().setVertexFillPaintTransformer(new Transformer<State, Paint>() {
        @Override
        public Paint transform(State i) {
            if (i.finalState) {
                return Color.RED;
            } else if (i.startState) {
                return Color.CYAN;
            } else {
                return Color.LIGHT_GRAY;
            }
        }
    });

    add(new JScrollPane(textArea), BorderLayout.CENTER);
}

From source file:QandE.Beeper2.java

public Beeper2() {
    super(new BorderLayout());

    //Create and set up the spinner.
    String numBeepsString = "Number of Beeps: ";
    beepsModel = new SpinnerNumberModel(1, 1, 10, 1);
    JLabel numBeepsLabel = new JLabel(numBeepsString);
    add(numBeepsLabel, BorderLayout.PAGE_START);
    JSpinner spinner = new JSpinner(beepsModel);
    numBeepsLabel.setLabelFor(spinner);// w w  w .j a  va  2  s  .  com
    add(spinner, BorderLayout.CENTER);

    button = new JButton("Click Me");
    button.setPreferredSize(new Dimension(200, 80));
    add(button, BorderLayout.PAGE_END);
    button.setActionCommand(BUTTON_CMD);
    button.addActionListener(this);
}