Example usage for javax.swing ScrollPaneConstants VERTICAL_SCROLLBAR_ALWAYS

List of usage examples for javax.swing ScrollPaneConstants VERTICAL_SCROLLBAR_ALWAYS

Introduction

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

Prototype

int VERTICAL_SCROLLBAR_ALWAYS

To view the source code for javax.swing ScrollPaneConstants VERTICAL_SCROLLBAR_ALWAYS.

Click Source Link

Document

Used to set the vertical scroll bar policy so that vertical scrollbars are always displayed.

Usage

From source file:events.TableListSelectionDemo.java

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

    String[] columnNames = { "French", "Spanish", "Italian" };
    String[][] tableData = { { "un", "uno", "uno" }, { "deux", "dos", "due" }, { "trois", "tres", "tre" },
            { "quatre", "cuatro", "quattro" }, { "cinq", "cinco", "cinque" }, { "six", "seis", "sei" },
            { "sept", "siete", "sette" } };

    table = new JTable(tableData, columnNames);
    listSelectionModel = table.getSelectionModel();
    listSelectionModel.addListSelectionListener(new SharedListSelectionHandler());
    table.setSelectionModel(listSelectionModel);
    JScrollPane tablePane = new JScrollPane(table);

    //Build control area (use default FlowLayout).
    JPanel controlPane = new JPanel();
    String[] modes = { "SINGLE_SELECTION", "SINGLE_INTERVAL_SELECTION", "MULTIPLE_INTERVAL_SELECTION" };

    final JComboBox comboBox = new JComboBox(modes);
    comboBox.setSelectedIndex(2);/*from ww  w  . ja  v  a 2  s .  c  o  m*/
    comboBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            String newMode = (String) comboBox.getSelectedItem();
            if (newMode.equals("SINGLE_SELECTION")) {
                listSelectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
            } else if (newMode.equals("SINGLE_INTERVAL_SELECTION")) {
                listSelectionModel.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
            } else {
                listSelectionModel.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
            }
            output.append("----------" + "Mode: " + newMode + "----------" + newline);
        }
    });
    controlPane.add(new JLabel("Selection mode:"));
    controlPane.add(comboBox);

    //Build output area.
    output = new JTextArea(1, 10);
    output.setEditable(false);
    JScrollPane outputPane = new JScrollPane(output, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);

    //Do the layout.
    JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    add(splitPane, BorderLayout.CENTER);

    JPanel topHalf = new JPanel();
    topHalf.setLayout(new BoxLayout(topHalf, BoxLayout.LINE_AXIS));
    JPanel listContainer = new JPanel(new GridLayout(1, 1));
    JPanel tableContainer = new JPanel(new GridLayout(1, 1));
    tableContainer.setBorder(BorderFactory.createTitledBorder("Table"));
    tableContainer.add(tablePane);
    tablePane.setPreferredSize(new Dimension(420, 130));
    topHalf.setBorder(BorderFactory.createEmptyBorder(5, 5, 0, 5));
    topHalf.add(listContainer);
    topHalf.add(tableContainer);

    topHalf.setMinimumSize(new Dimension(250, 50));
    topHalf.setPreferredSize(new Dimension(200, 110));
    splitPane.add(topHalf);

    JPanel bottomHalf = new JPanel(new BorderLayout());
    bottomHalf.add(controlPane, BorderLayout.PAGE_START);
    bottomHalf.add(outputPane, BorderLayout.CENTER);
    //XXX: next line needed if bottomHalf is a scroll pane:
    //bottomHalf.setMinimumSize(new Dimension(400, 50));
    bottomHalf.setPreferredSize(new Dimension(450, 110));
    splitPane.add(bottomHalf);
}

From source file:utilities.GraphViewer.java

public GraphViewer() {

    super("Graph Viewer");
    setRootPaneCheckingEnabled(false);//w w w .ja  va  2  s . c  o m

    this.setLocation(0, 0);
    this.setVisible(false);
    dataset = new XYSeriesCollection();
    this.db = new Db();
    this.sensors = new LinkedList<JCheckBox>();
    this.sensors1 = new LinkedList<JCheckBox>();

    getContentPane().setLayout(new BorderLayout(0, 0));

    this.setName("Graph Viewer");
    setIconifiable(true);
    setClosable(true);
    setBounds(6, 95, 1000, 600);

    option = new JPanel();
    option.setBackground(new Color(240, 240, 255));
    option.setPreferredSize(new Dimension(200, 500));
    option.setLayout(new BorderLayout(10, 10));
    getContentPane().add(option, BorderLayout.WEST);

    parcourir = new JButton("Add Sensor");
    parcourir.setAlignmentX(Component.CENTER_ALIGNMENT);
    parcourir.addActionListener(this);
    option.add(parcourir, BorderLayout.NORTH);

    this.sensorsList = new JPanel();
    sensorsList.setLayout(new VerticalLayout());
    sensorsList.setBackground(Color.WHITE);

    scpane = new JScrollPane(sensorsList);
    scpane.setBorder(BorderFactory.createLineBorder(Color.black));
    scpane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    option.add(scpane, BorderLayout.CENTER);

    paneGraphe = new JPanel();
    paneGraphe.setLayout(new BorderLayout(0, 0));
    graphe = graphe();
    paneGraphe.add(graphe, BorderLayout.CENTER);
    getContentPane().add(paneGraphe);

}

From source file:ListSelectionDemo.java

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

    String[] listData = { "one", "two", "three", "four", "five", "six", "seven" };
    String[] columnNames = { "French", "Spanish", "Italian" };
    list = new JList(listData);

    listSelectionModel = list.getSelectionModel();
    listSelectionModel.addListSelectionListener(new SharedListSelectionHandler());
    JScrollPane listPane = new JScrollPane(list);

    JPanel controlPane = new JPanel();
    String[] modes = { "SINGLE_SELECTION", "SINGLE_INTERVAL_SELECTION", "MULTIPLE_INTERVAL_SELECTION" };

    final JComboBox comboBox = new JComboBox(modes);
    comboBox.setSelectedIndex(2);/*from www.j  a  v  a2  s.c o m*/
    comboBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            String newMode = (String) comboBox.getSelectedItem();
            if (newMode.equals("SINGLE_SELECTION")) {
                listSelectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
            } else if (newMode.equals("SINGLE_INTERVAL_SELECTION")) {
                listSelectionModel.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
            } else {
                listSelectionModel.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
            }
            output.append("----------" + "Mode: " + newMode + "----------" + newline);
        }
    });
    controlPane.add(new JLabel("Selection mode:"));
    controlPane.add(comboBox);

    // Build output area.
    output = new JTextArea(1, 10);
    output.setEditable(false);
    JScrollPane outputPane = new JScrollPane(output, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);

    // Do the layout.
    JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    add(splitPane, BorderLayout.CENTER);

    JPanel topHalf = new JPanel();
    topHalf.setLayout(new BoxLayout(topHalf, BoxLayout.LINE_AXIS));
    JPanel listContainer = new JPanel(new GridLayout(1, 1));
    listContainer.setBorder(BorderFactory.createTitledBorder("List"));
    listContainer.add(listPane);

    topHalf.setBorder(BorderFactory.createEmptyBorder(5, 5, 0, 5));
    topHalf.add(listContainer);
    // topHalf.add(tableContainer);

    topHalf.setMinimumSize(new Dimension(100, 50));
    topHalf.setPreferredSize(new Dimension(100, 110));
    splitPane.add(topHalf);

    JPanel bottomHalf = new JPanel(new BorderLayout());
    bottomHalf.add(controlPane, BorderLayout.PAGE_START);
    bottomHalf.add(outputPane, BorderLayout.CENTER);
    // XXX: next line needed if bottomHalf is a scroll pane:
    // bottomHalf.setMinimumSize(new Dimension(400, 50));
    bottomHalf.setPreferredSize(new Dimension(450, 135));
    splitPane.add(bottomHalf);
}

From source file:TableSelectionDemo.java

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

    String[] columnNames = { "French", "Spanish", "Italian" };
    String[][] tableData = { { "un", "uno", "uno" }, { "deux", "dos", "due" }, { "trois", "tres", "tre" },
            { "quatre", "cuatro", "quattro" }, { "cinq", "cinco", "cinque" }, { "six", "seis", "sei" },
            { "sept", "siete", "sette" } };

    table = new JTable(tableData, columnNames);
    listSelectionModel = table.getSelectionModel();
    listSelectionModel.addListSelectionListener(new SharedListSelectionHandler());
    table.setSelectionModel(listSelectionModel);
    JScrollPane tablePane = new JScrollPane(table);

    // Build control area (use default FlowLayout).
    JPanel controlPane = new JPanel();
    String[] modes = { "SINGLE_SELECTION", "SINGLE_INTERVAL_SELECTION", "MULTIPLE_INTERVAL_SELECTION" };

    final JComboBox comboBox = new JComboBox(modes);
    comboBox.setSelectedIndex(2);/*from  w w w.j  a v a2 s  .  c om*/
    comboBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            String newMode = (String) comboBox.getSelectedItem();
            if (newMode.equals("SINGLE_SELECTION")) {
                listSelectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
            } else if (newMode.equals("SINGLE_INTERVAL_SELECTION")) {
                listSelectionModel.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
            } else {
                listSelectionModel.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
            }
            output.append("----------" + "Mode: " + newMode + "----------" + newline);
        }
    });
    controlPane.add(new JLabel("Selection mode:"));
    controlPane.add(comboBox);

    // Build output area.
    output = new JTextArea(1, 10);
    output.setEditable(false);
    JScrollPane outputPane = new JScrollPane(output, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);

    // Do the layout.
    JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    add(splitPane, BorderLayout.CENTER);

    JPanel topHalf = new JPanel();
    topHalf.setLayout(new BoxLayout(topHalf, BoxLayout.LINE_AXIS));
    JPanel listContainer = new JPanel(new GridLayout(1, 1));
    JPanel tableContainer = new JPanel(new GridLayout(1, 1));
    tableContainer.setBorder(BorderFactory.createTitledBorder("Table"));
    tableContainer.add(tablePane);
    tablePane.setPreferredSize(new Dimension(420, 130));
    topHalf.setBorder(BorderFactory.createEmptyBorder(5, 5, 0, 5));
    topHalf.add(listContainer);
    topHalf.add(tableContainer);

    topHalf.setMinimumSize(new Dimension(250, 50));
    topHalf.setPreferredSize(new Dimension(200, 110));
    splitPane.add(topHalf);

    JPanel bottomHalf = new JPanel(new BorderLayout());
    bottomHalf.add(controlPane, BorderLayout.PAGE_START);
    bottomHalf.add(outputPane, BorderLayout.CENTER);
    // XXX: next line needed if bottomHalf is a scroll pane:
    // bottomHalf.setMinimumSize(new Dimension(400, 50));
    bottomHalf.setPreferredSize(new Dimension(450, 110));
    splitPane.add(bottomHalf);
}

From source file:edu.ku.brc.specify.config.SpecifyExceptionTracker.java

@Override
protected FeedBackSenderItem getFeedBackSenderItem(final Class<?> cls, final Exception exception) {
    CellConstraints cc = new CellConstraints();
    PanelBuilder pb = new PanelBuilder(new FormLayout("p,2px,p,f:p:g", "p,8px,p,2px, p,4px,p,2px,f:p:g"));

    Vector<Taskable> taskItems = new Vector<Taskable>(TaskMgr.getInstance().getAllTasks());
    Collections.sort(taskItems, new Comparator<Taskable>() {
        @Override/* w ww. j av a 2  s  .  com*/
        public int compare(Taskable o1, Taskable o2) {
            return o1.getName().compareTo(o2.getName());
        }
    });

    final JTextArea commentsTA = createTextArea(3, 60);
    final JTextArea stackTraceTA = createTextArea(15, 60);
    final JCheckBox moreBtn;

    commentsTA.setWrapStyleWord(true);
    commentsTA.setLineWrap(true);

    //JLabel desc = createI18NLabel("UNHDL_EXCP", SwingConstants.LEFT);
    JEditorPane desc = new JEditorPane("text/html", getResourceString("UNHDL_EXCP"));
    desc.setEditable(false);
    desc.setOpaque(false);
    //desc.setFont(new Font(Font.SANS_SERIF, Font.BOLD, (new JLabel("X")).getFont().getSize()));

    JScrollPane sp = new JScrollPane(stackTraceTA, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);

    int y = 1;
    pb.add(desc, cc.xyw(1, y, 4));
    y += 2;
    pb.add(createI18NFormLabel("UNHDL_EXCP_CMM"), cc.xy(1, y));
    y += 2;
    pb.add(createScrollPane(commentsTA, true), cc.xyw(1, y, 4));
    y += 2;

    forwardImgIcon = IconManager.getIcon("Forward"); //$NON-NLS-1$
    downImgIcon = IconManager.getIcon("Down"); //$NON-NLS-1$
    moreBtn = new JCheckBox(getResourceString("LOGIN_DLG_MORE"), forwardImgIcon); //$NON-NLS-1$
    setControlSize(moreBtn);
    JButton copyBtn = createI18NButton("UNHDL_EXCP_COPY");

    PanelBuilder innerPB = new PanelBuilder(new FormLayout("p,2px,f:p:g", "p,2px,p:g,2px,p"));
    innerPB.add(createI18NLabel("UNHDL_EXCP_STK"), cc.xy(1, 1));
    innerPB.add(sp, cc.xyw(1, 3, 3));
    innerPB.add(copyBtn, cc.xy(1, 5));
    stackTracePanel = innerPB.getPanel();
    stackTracePanel.setVisible(false);

    pb.add(moreBtn, cc.xyw(1, y, 4));
    y += 2;
    pb.add(stackTracePanel, cc.xyw(1, y, 4));
    y += 2;

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    exception.printStackTrace(new PrintStream(baos));

    stackTraceTA.setText(baos.toString());

    moreBtn.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (stackTracePanel.isVisible()) {
                stackTracePanel.setVisible(false);
                moreBtn.setIcon(forwardImgIcon);
            } else {
                stackTracePanel.setVisible(true);
                moreBtn.setIcon(downImgIcon);
            }
            if (dlg != null) {
                dlg.pack();
            }
        }
    });

    copyBtn.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            String taskName = getTaskName();
            FeedBackSenderItem item = new FeedBackSenderItem(taskName, "", "", commentsTA.getText(),
                    stackTraceTA.getText(), cls.getName());
            NameValuePair[] pairs = createPostParameters(item);

            StringBuilder sb = new StringBuilder();
            for (NameValuePair pair : pairs) {
                if (!pair.getName().equals("bug")) {
                    sb.append(pair.getName());
                    sb.append(": ");
                    if (pair.getName().equals("comments") || pair.getName().equals("stack_trace")) {
                        sb.append("\n");
                    }
                    sb.append(pair.getValue());
                    sb.append("\n");
                }
            }

            // Copy to Clipboard
            UIHelper.setTextToClipboard(sb.toString());
        }
    });

    pb.setDefaultDialogBorder();
    dlg = new CustomDialog((Frame) null, getResourceString("UnhandledExceptionTitle"), true,
            CustomDialog.OK_BTN, pb.getPanel());
    dlg.setOkLabel(getResourceString("UNHDL_EXCP_SEND"));

    dlg.createUI();
    stackTracePanel.setVisible(false);

    centerAndShow(dlg);

    String taskName = getTaskName();
    FeedBackSenderItem item = new FeedBackSenderItem(taskName, "", "", commentsTA.getText(),
            stackTraceTA.getText(), cls.getName());
    return item;
}

From source file:com.mindcognition.mindraider.ui.swing.concept.annotation.renderer.AbstractTextAnnotationRenderer.java

private JScrollPane encapsulateToScroll(Component what, String title) {
    JScrollPane editorScroll = new JScrollPane(what);
    editorScroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    editorScroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    // TODO bundle
    editorScroll.setBorder(new TitledBorder(title));
    return editorScroll;
}

From source file:PagingTester.java

public static JScrollPane createPagingScrollPaneForTable(JTable jt) {
    JScrollPane jsp = new JScrollPane(jt);
    TableModel tmodel = jt.getModel();

    // Don't choke if this is called on a regular table . . .
    if (!(tmodel instanceof PagingModel)) {
        return jsp;
    }//  ww  w . j a v a 2 s.  c  o m

    // Okay, go ahead and build the real scrollpane
    final PagingModel model = (PagingModel) tmodel;
    final JButton upButton = new JButton(new ArrowIcon(ArrowIcon.UP));
    upButton.setEnabled(false); // starts off at 0, so can't go up
    final JButton downButton = new JButton(new ArrowIcon(ArrowIcon.DOWN));
    if (model.getPageCount() <= 1) {
        downButton.setEnabled(false); // One page...can't scroll down
    }

    upButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            model.pageUp();

            // If we hit the top of the data, disable the up button.
            if (model.getPageOffset() == 0) {
                upButton.setEnabled(false);
            }
            downButton.setEnabled(true);
        }
    });

    downButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            model.pageDown();

            // If we hit the bottom of the data, disable the down button.
            if (model.getPageOffset() == (model.getPageCount() - 1)) {
                downButton.setEnabled(false);
            }
            upButton.setEnabled(true);
        }
    });

    // Turn on the scrollbars; otherwise we won't get our corners.
    jsp.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    jsp.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);

    // Add in the corners (page up/down).
    jsp.setCorner(ScrollPaneConstants.UPPER_RIGHT_CORNER, upButton);
    jsp.setCorner(ScrollPaneConstants.LOWER_RIGHT_CORNER, downButton);

    return jsp;
}

From source file:components.SharedModelDemo.java

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

    Vector data = new Vector(7);
    String[] columnNames = { "French", "Spanish", "Italian" };
    String[] oneData = { "un", "uno", "uno" };
    String[] twoData = { "deux", "dos", "due" };
    String[] threeData = { "trois", "tres", "tre" };
    String[] fourData = { "quatre", "cuatro", "quattro" };
    String[] fiveData = { "cinq", "cinco", "cinque" };
    String[] sixData = { "six", "seis", "sei" };
    String[] sevenData = { "sept", "siete", "sette" };

    //Build the model.
    SharedDataModel dataModel = new SharedDataModel(columnNames);
    dataModel.addElement(oneData);/*  w w  w .  j  a v  a  2  s. c  o  m*/
    dataModel.addElement(twoData);
    dataModel.addElement(threeData);
    dataModel.addElement(fourData);
    dataModel.addElement(fiveData);
    dataModel.addElement(sixData);
    dataModel.addElement(sevenData);

    list = new JList(dataModel);
    list.setCellRenderer(new DefaultListCellRenderer() {
        public Component getListCellRendererComponent(JList l, Object value, int i, boolean s, boolean f) {
            String[] array = (String[]) value;
            return super.getListCellRendererComponent(l, array[0], i, s, f);
        }
    });

    listSelectionModel = list.getSelectionModel();
    listSelectionModel.addListSelectionListener(new SharedListSelectionHandler());
    JScrollPane listPane = new JScrollPane(list);

    table = new JTable(dataModel);
    table.setSelectionModel(listSelectionModel);
    JScrollPane tablePane = new JScrollPane(table);

    //Build control area (use default FlowLayout).
    JPanel controlPane = new JPanel();
    String[] modes = { "SINGLE_SELECTION", "SINGLE_INTERVAL_SELECTION", "MULTIPLE_INTERVAL_SELECTION" };

    final JComboBox comboBox = new JComboBox(modes);
    comboBox.setSelectedIndex(2);
    comboBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            String newMode = (String) comboBox.getSelectedItem();
            if (newMode.equals("SINGLE_SELECTION")) {
                listSelectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
            } else if (newMode.equals("SINGLE_INTERVAL_SELECTION")) {
                listSelectionModel.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
            } else {
                listSelectionModel.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
            }
            output.append("----------" + "Mode: " + newMode + "----------" + newline);
        }
    });
    controlPane.add(new JLabel("Selection mode:"));
    controlPane.add(comboBox);

    //Build output area.
    output = new JTextArea(10, 40);
    output.setEditable(false);
    JScrollPane outputPane = new JScrollPane(output, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);

    //Do the layout.
    JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    add(splitPane, BorderLayout.CENTER);

    JPanel topHalf = new JPanel();
    topHalf.setLayout(new BoxLayout(topHalf, BoxLayout.X_AXIS));
    JPanel listContainer = new JPanel(new GridLayout(1, 1));
    listContainer.setBorder(BorderFactory.createTitledBorder("List"));
    listContainer.add(listPane);
    JPanel tableContainer = new JPanel(new GridLayout(1, 1));
    tableContainer.setBorder(BorderFactory.createTitledBorder("Table"));
    tableContainer.add(tablePane);
    tablePane.setPreferredSize(new Dimension(300, 100));
    topHalf.setBorder(BorderFactory.createEmptyBorder(5, 5, 0, 5));
    topHalf.add(listContainer);
    topHalf.add(tableContainer);

    topHalf.setMinimumSize(new Dimension(400, 50));
    topHalf.setPreferredSize(new Dimension(400, 110));
    splitPane.add(topHalf);

    JPanel bottomHalf = new JPanel(new BorderLayout());
    bottomHalf.add(controlPane, BorderLayout.NORTH);
    bottomHalf.add(outputPane, BorderLayout.CENTER);
    //XXX: next line needed if bottomHalf is a scroll pane:
    //bottomHalf.setMinimumSize(new Dimension(400, 50));
    bottomHalf.setPreferredSize(new Dimension(450, 135));
    splitPane.add(bottomHalf);
}

From source file:is.iclt.jcorpald.CorpaldView.java

public void createAndShowGUI() {
    CorpaldSettings settings = CorpaldSettings.getInstance();

    //Create and set up the window.
    JFrame frame = new JFrame(settings.getProperty("corpus.acronym") + " "
            + settings.getProperty("corpus.version") + " - " + settings.getProperty("corpus.longname"));
    frame.setIconImage((new ImageIcon("icons/corpald.png")).getImage());

    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    // frame.setBounds(50, 50, 700, 450);
    frame.setPreferredSize(new Dimension(750, 720));

    // Create the panel that has the query and the result        
    JPanel panMainArea = new JPanel(new BorderLayout());
    JPanel panQuery = new JPanel(new BorderLayout());

    txtQuery = new JHighlightPane();
    txtQuery.addKeyListener(this);

    txtQuery.setFont(new Font("Monospaced", Font.BOLD, 16));
    this.updateHighlighting();
    txtQuery.setPreferredSize(new Dimension(700, 150));

    panQuery.add(labQuery, BorderLayout.NORTH);
    panQuery.add(new JScrollPane(txtQuery, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS), BorderLayout.CENTER);
    panQuery.setBorder(new EmptyBorder(0, 10, 10, 10));

    String welcomeMessage = "";
    try {//from   ww w  .j  av  a2s  .  c om
        welcomeMessage = FileUtils.readFileToString(new File(settings.getProperty("corpus.welcome")), "utf-8");
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    JPanel panResult = new JPanel(new BorderLayout());
    txtResult = new JTextArea(welcomeMessage);

    txtResult.setEditable(false);
    txtResult.setFont(new Font("Monospaced", Font.BOLD, 14));

    JScrollPane scrResult = new JScrollPane(txtResult, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
    scrResult.setPreferredSize(new Dimension(700, 400));
    panResult.add(new JLabel("Result:"), BorderLayout.NORTH);
    panResult.add(scrResult, BorderLayout.CENTER);
    panResult.setBorder(new EmptyBorder(0, 10, 0, 10));

    panMainArea.add(panQuery, BorderLayout.NORTH);
    panMainArea.add(panResult, BorderLayout.CENTER);

    // Create panel at top with buttons
    JPanel panToolbar = new JPanel(new FlowLayout(FlowLayout.CENTER));

    // New, Open, Save
    // New
    ImageIcon icoNewQuery = new ImageIcon("icons/page_white.png");
    butNewQuery = new JButton(icoNewQuery);
    butNewQuery.addActionListener(this);
    butNewQuery.setPreferredSize(new Dimension(26, 26));
    butNewQuery.setToolTipText("Create a new empty query");
    panToolbar.add(butNewQuery);
    // Open
    ImageIcon icoOpenQuery = new ImageIcon("icons/folder.png");
    butOpenQuery = new JButton(icoOpenQuery);
    butOpenQuery.addActionListener(this);
    butOpenQuery.setPreferredSize(new Dimension(26, 26));
    butOpenQuery.setToolTipText("Open a query file");
    panToolbar.add(butOpenQuery);
    // Save
    ImageIcon icoSaveQuery = new ImageIcon("icons/page_save.png");
    butSaveQuery = new JButton(icoSaveQuery);
    butSaveQuery.addActionListener(this);
    butSaveQuery.setPreferredSize(new Dimension(26, 26));
    butSaveQuery.setToolTipText("Save current query");
    panToolbar.add(butSaveQuery);
    // Save as
    ImageIcon icoSaveQueryAs = new ImageIcon("icons/page_save_as.png");
    butSaveQueryAs = new JButton(icoSaveQueryAs);
    butSaveQueryAs.addActionListener(this);
    butSaveQueryAs.setPreferredSize(new Dimension(26, 26));
    butSaveQueryAs.setToolTipText("Save current query under a new file name");
    panToolbar.add(butSaveQueryAs);

    // Open definitions file
    ImageIcon icoOpenDef = new ImageIcon("icons/folder_table.png");
    butOpenDef = new JButton(icoOpenDef);
    butOpenDef.addActionListener(this);
    butOpenDef.setPreferredSize(new Dimension(26, 26));
    butOpenDef.setToolTipText("Select a new definitions file");
    panToolbar.add(butOpenDef);

    // Run Query button
    ImageIcon icoRunQuery = new ImageIcon("icons/control_play_blue.png");
    butRunQuery = new JButton("Run Query", icoRunQuery);
    butRunQuery.setPreferredSize(new Dimension(130, 26));
    butRunQuery.addActionListener(this);
    butRunQuery.setToolTipText("Run the current query using CorpusSearch");
    panToolbar.add(butRunQuery);

    // TextField for root node label
    JLabel labRootNode = new JLabel("Root:");
    panToolbar.add(labRootNode);
    txtRootNode = new JTextField("", 12);
    txtRootNode.setPreferredSize(new Dimension(50, 26));
    txtRootNode.addKeyListener(this);
    txtRootNode.setMargin(new Insets(3, 3, 3, 3));
    txtRootNode.setToolTipText("<html>Search within instances of a particular type of node,<br/>"
            + "such as IP-*, IP-SUB, NP-*, etc. $ROOT matches<br/>"
            + "the root node of every tree in the corpus.</html>");
    panToolbar.add(txtRootNode);

    chkNodesOnly = new JCheckBox("Nodes only");
    chkNodesOnly.addItemListener(this);
    chkNodesOnly.setToolTipText("<html>If checked, CorpusSearch prints out only the nodes that<br/>"
            + "contain the structure described in \"Query\". If not checked,<br/>"
            + "CorpusSearch prints out the entire sentence that contains the<br/>"
            + "structure described in \"Query\".</html>");
    panToolbar.add(chkNodesOnly);

    chkRemoveNodes = new JCheckBox("Remove nodes");
    chkRemoveNodes.addItemListener(this);
    chkRemoveNodes.setToolTipText("<html>Remove subtrees whose root is of the same syntactic category<br/>"
            + "as the node boundary embedded within a instance of that node<br/>"
            + "boundary. \"Remove nodes\" thus removes recursive structure.</html>");
    panToolbar.add(chkRemoveNodes);

    // Create panel at top with buttons
    JPanel panBottombar = new JPanel(new FlowLayout(FlowLayout.CENTER));
    // panBottombar.setBorder(new EmptyBorder(0, 0, 10, 5));
    ImageIcon icoOpenFolder = new ImageIcon("icons/folder.png");
    butOpenFolder = new JButton("Show result in folder", icoOpenFolder);
    butOpenFolder.setEnabled(false);
    butOpenFolder.addActionListener(this);
    panBottombar.add(butOpenFolder);

    ImageIcon icoTextEditor = new ImageIcon("icons/page_white_go.png");
    butTextEditor = new JButton("Open result in text editor", icoTextEditor);
    butTextEditor.setEnabled(false);
    butTextEditor.addActionListener(this);
    panBottombar.add(butTextEditor);

    ImageIcon icoCopyResults = new ImageIcon("icons/page_copy.png");
    butCopyResults = new JButton("Copy result to clipboard", icoCopyResults);
    butCopyResults.setEnabled(false);
    butCopyResults.addActionListener(this);
    panBottombar.add(butCopyResults);

    // Add stuff to top level content pane                
    frame.getContentPane().setLayout(new BorderLayout());
    frame.getContentPane().add(panToolbar, BorderLayout.NORTH);
    frame.getContentPane().add(panMainArea, BorderLayout.CENTER);
    frame.getContentPane().add(panBottombar, BorderLayout.SOUTH);

    this.configureFileFilters();

    //Display the window.
    frame.pack();
    frame.setVisible(true);
}

From source file:dk.dma.epd.common.prototype.gui.notification.ChatServicePanel.java

/**
 * Constructor/*from  ww w. ja  v a  2s  . com*/
 * 
 * @param compactLayout
 *            if false, there will be message type selectors in the panel
 */
public ChatServicePanel(boolean compactLayout) {
    super(new BorderLayout());

    // Prepare the title header
    titleHeader.setBackground(getBackground().darker());
    titleHeader.setOpaque(true);
    titleHeader.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
    titleHeader.setHorizontalAlignment(SwingConstants.CENTER);
    add(titleHeader, BorderLayout.NORTH);

    // Add messages panel
    scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    messagesPanel.setBackground(UIManager.getColor("List.background"));
    messagesPanel.setOpaque(false);
    messagesPanel.setLayout(new GridBagLayout());
    messagesPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    add(scrollPane, BorderLayout.CENTER);

    JPanel sendPanel = new JPanel(new GridBagLayout());
    add(sendPanel, BorderLayout.SOUTH);
    Insets insets = new Insets(2, 2, 2, 2);

    // Add text area
    if (compactLayout) {
        messageText = new JTextField();
        ((JTextField) messageText).addActionListener(this);
        sendPanel.add(messageText, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, NORTH, BOTH, insets, 0, 0));

    } else {
        messageText = new JTextArea();
        JScrollPane scrollPane2 = new JScrollPane(messageText);
        scrollPane2.setPreferredSize(new Dimension(100, 50));
        scrollPane2.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
        scrollPane2.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
        sendPanel.add(scrollPane2, new GridBagConstraints(0, 0, 1, 2, 1.0, 1.0, NORTH, BOTH, insets, 0, 0));
    }

    // Add buttons
    ButtonGroup group = new ButtonGroup();
    messageTypeBtn = createMessageTypeButton("Send messages", ICON_MESSAGE, true, group);
    warningTypeBtn = createMessageTypeButton("Send warnings", ICON_WARNING, false, group);
    alertTypeBtn = createMessageTypeButton("Send alerts", ICON_ALERT, false, group);

    if (!compactLayout) {
        JToolBar msgTypePanel = new JToolBar();
        msgTypePanel.setBorderPainted(false);
        msgTypePanel.setOpaque(true);
        msgTypePanel.setFloatable(false);
        sendPanel.add(msgTypePanel, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, NORTH, NONE, insets, 0, 0));
        msgTypePanel.add(messageTypeBtn);
        msgTypePanel.add(warningTypeBtn);
        msgTypePanel.add(alertTypeBtn);
    }

    if (compactLayout) {
        sendBtn = new JButton("Send");
        sendPanel.add(sendBtn, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, NORTH, NONE, insets, 0, 0));
    } else {
        sendBtn = new JButton("Send", ICON_MESSAGE);
        sendBtn.setPreferredSize(new Dimension(100, sendBtn.getPreferredSize().height));
        sendPanel.add(sendBtn, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, NORTH, NONE, insets, 0, 0));
    }
    sendBtn.setEnabled(false);
    messageText.setEditable(false);
    sendBtn.addActionListener(this);
}