Example usage for javax.swing JScrollPane setHorizontalScrollBarPolicy

List of usage examples for javax.swing JScrollPane setHorizontalScrollBarPolicy

Introduction

In this page you can find the example usage for javax.swing JScrollPane setHorizontalScrollBarPolicy.

Prototype

@BeanProperty(preferred = true, enumerationValues = { "ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED",
        "ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER",
        "ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS" }, description = "The scrollpane scrollbar policy")
public void setHorizontalScrollBarPolicy(int policy) 

Source Link

Document

Determines when the horizontal scrollbar appears in the scrollpane.

Usage

From source file:com.sshtools.sshterm.SshTermCommandTab.java

/**
 * Creates a new SshToolsConnectionCommandTab object.
 *///from  w  w  w  .jav a  2s.  c om
public SshTermCommandTab() {
    super();

    JPanel main = new JPanel(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.anchor = GridBagConstraints.NORTH;
    gbc.insets = new Insets(0, 2, 2, 2);

    Insets ins2 = new Insets(2, 24, 2, 2);
    gbc.weightx = 1.0;
    requestPseudoTerminal.getModel().setSelected(false);
    disconnectOnSessionClose.getModel().setSelected(true);
    UIUtil.jGridBagAdd(main, requestPseudoTerminal, gbc, GridBagConstraints.REMAINDER);
    UIUtil.jGridBagAdd(main, disconnectOnSessionClose, gbc, GridBagConstraints.REMAINDER);
    UIUtil.jGridBagAdd(main, new JSeparator(JSeparator.HORIZONTAL), gbc, GridBagConstraints.REMAINDER);
    UIUtil.jGridBagAdd(main, onceAuthenticated, gbc, GridBagConstraints.REMAINDER);
    group.add(doNothing);
    group.add(startShell);
    group.add(executeCommands);
    startShell.setSelected(true);
    UIUtil.jGridBagAdd(main, doNothing, gbc, GridBagConstraints.REMAINDER);
    UIUtil.jGridBagAdd(main, startShell, gbc, GridBagConstraints.REMAINDER);
    UIUtil.jGridBagAdd(main, executeCommands, gbc, GridBagConstraints.REMAINDER);
    gbc.fill = GridBagConstraints.BOTH;
    gbc.insets = ins2;
    gbc.weighty = 1.0;

    //commands.setLineWrap(true);
    commands.setBorder(BorderFactory.createEtchedBorder());

    JScrollPane scroll = new JScrollPane(commands);
    scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
    scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    UIUtil.jGridBagAdd(main, scroll, gbc, GridBagConstraints.REMAINDER);

    IconWrapperPanel iconProxyDetailsPanel = new IconWrapperPanel(new ResourceIcon(COMMANDS_ICON), main);
    commands.setRows(8);

    //  This panel
    setLayout(new BorderLayout());
    setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
    gbc = new GridBagConstraints();
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.anchor = GridBagConstraints.NORTH;
    gbc.insets = new Insets(2, 2, 2, 2);
    gbc.weightx = 1.0;
    add(iconProxyDetailsPanel, BorderLayout.NORTH);
}

From source file:com.atlassian.theplugin.idea.jira.PerformIssueActionForm.java

/**
 * Method generated by IntelliJ IDEA GUI Designer
 * >>> IMPORTANT!! <<<
 * DO NOT edit this method OR call it in your code!
 *
 * @noinspection ALL//from   w ww. j a  v a 2 s .  c o m
 */
private void $$$setupUI$$$() {
    root = new JPanel();
    root.setLayout(new BorderLayout(0, 0));
    final JScrollPane scrollPane1 = new JScrollPane();
    scrollPane1.setHorizontalScrollBarPolicy(31);
    root.add(scrollPane1, BorderLayout.CENTER);
    contentPanel = new JPanel();
    contentPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
    scrollPane1.setViewportView(contentPanel);
}

From source file:com.emental.mindraider.ui.outline.OutlineSorterJPanel.java

public OutlineSorterJPanel() {
    setLayout(new BorderLayout());

    // table with archived concepts (title)
    // let table model to load discarded concepts itself
    tableModel = new SorterTableModel();
    table = new JTable(tableModel);
    table.getSelectionModel().addListSelectionListener(new SorterListSelectionListener(table, tableModel));
    table.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    table.setFillsViewportHeight(true);//w  ww.j av  a 2 s  .c o m
    table.setShowHorizontalLines(false);
    table.setShowVerticalLines(false);
    table.getColumnModel().getColumn(COLUMN_NAME).setPreferredWidth(150);
    table.getColumnModel().getColumn(COLUMN_ANNOTATION).setPreferredWidth(220);
    table.getColumnModel().getColumn(COLUMN_CREATED).setPreferredWidth(60);
    table.getColumnModel().getColumn(COLUMN_MODIFIED).setPreferredWidth(60);
    table.getColumnModel().getColumn(COLUMN_REVISION).setPreferredWidth(35);

    TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(table.getModel());
    table.setRowSorter(sorter);
    sorter.setComparator(COLUMN_REVISION, new Comparator<Long>() {
        @Override
        public int compare(Long o1, Long o2) {
            return o2.intValue() - o1.intValue();
        }
    });
    final Comparator<String> timestampComparator = new Comparator<String>() {
        @Override
        public int compare(String o1, String o2) {
            if (OutlineTreeInstance.getCreatedTimestampFromHtml(o2) > OutlineTreeInstance
                    .getCreatedTimestampFromHtml(o1)) {
                return 1;
            } else {
                if (OutlineTreeInstance.getCreatedTimestampFromHtml(o2) == OutlineTreeInstance
                        .getCreatedTimestampFromHtml(o1)) {
                    return 0;
                } else {
                    return -1;
                }
            }
        }
    };
    sorter.setComparator(COLUMN_MODIFIED, timestampComparator);
    sorter.setComparator(COLUMN_CREATED, timestampComparator);

    JScrollPane scroll = new JScrollPane(table);
    scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
    scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);

    add(scroll, BorderLayout.CENTER);
}

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

/**
 * {@inheritDoc}//www.  j ava 2s. co  m
 */
@Override
protected void buildGUI() {
    setLayout(new GridBagLayout());
    setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

    // Create the transaction and status labels
    Insets insets5 = new Insets(5, 5, 5, 5);
    add(bold(new JLabel("Transaction ID:")),
            new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, WEST, NONE, insets5, 0, 0));
    add(transactionTxt, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, WEST, HORIZONTAL, insets5, 0, 0));

    add(bold(new JLabel("Latest status:")),
            new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, WEST, NONE, insets5, 0, 0));
    add(statusTxt, new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0, WEST, HORIZONTAL, insets5, 0, 0));

    // Create the info panel
    JPanel infoPanel = createInfoPanel();
    add(infoPanel, new GridBagConstraints(0, 2, 2, 1, 1.0, 0.0, WEST, HORIZONTAL, insets5, 0, 0));

    // Create the messages panel
    JScrollPane scrollPane = new JScrollPane(messagesPanel);
    scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
    scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPane.setBorder(new MatteBorder(1, 1, 1, 1, UIManager.getColor("Separator.shadow")));
    messagesPanel.setBackground(UIManager.getColor("List.background"));
    add(scrollPane, new GridBagConstraints(0, 3, 2, 1, 1.0, 1.0, WEST, BOTH, insets5, 0, 0));
}

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:org.kepler.plotting.Plot.java

public void setScrolling(boolean scrolling) {

    GridBagConstraints constraints = new GridBagConstraints();
    constraints.gridx = 1;//  w  ww . jav a 2s.c  o m
    constraints.gridy = 1;

    if (panel == null) {
        // initialize panel
        panel = new JPanel(new GridBagLayout());
    } else {
        panel.removeAll();
    }
    // Now we have an empty panel

    Component graphComponent;
    chartPanel = new ChartPanel(chart);
    // System.out.println("Chart panel has been set: " + System.identityHashCode(chartPanel));
    if (scrolling) {
        JScrollPane scrollPane = new JScrollPane(chartPanel);
        scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
        scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
        graphComponent = scrollPane;
    } else {
        graphComponent = chartPanel;
    }

    panel.add(graphComponent, constraints);
}

From source file:com.clank.launcher.swing.MessageLog.java

private void initComponents() {
    if (colorEnabled) {
        JTextPane text = new JTextPane() {
            @Override/*  w  w w.j  a  va2s. c  o  m*/
            public boolean getScrollableTracksViewportWidth() {
                return true;
            }
        };
        this.textComponent = text;
    } else {
        JTextArea text = new JTextArea();
        this.textComponent = text;
        text.setLineWrap(true);
        text.setWrapStyleWord(true);
    }

    textComponent.setFont(new JLabel().getFont());
    textComponent.setEditable(false);
    textComponent.setComponentPopupMenu(TextFieldPopupMenu.INSTANCE);
    DefaultCaret caret = (DefaultCaret) textComponent.getCaret();
    caret.setUpdatePolicy(DefaultCaret.NEVER_UPDATE);
    document = textComponent.getDocument();
    document.addDocumentListener(new LimitLinesDocumentListener(numLines, true));

    JScrollPane scrollText = new JScrollPane(textComponent);
    scrollText.setBorder(null);
    scrollText.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    scrollText.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);

    add(scrollText, BorderLayout.CENTER);
}

From source file:corina.cross.AllScoresView.java

/**
   Create a new view of all of a crossdate's scores.
        //  w  w  w  . j  a v  a 2 s. c o  m
   @param the crossdate to view initially
*/
public AllScoresView(Cross crossdate) {
    this.crossdate = crossdate;

    initTable();

    JScrollPane scroll = new JScrollPane(table);
    scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);

    setLayout(new BorderLayout());
    add(scroll);
}

From source file:jmap2gml.ScriptGui.java

/**
 * Formats the window, initializes the JMap2Script object, and sets up all
 * the necessary events./*ww w.j  av  a2  s .  co  m*/
 */
public ScriptGui() {
    setTitle("jmap to gml script converter");
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    getContentPane().setLayout(new GridBagLayout());

    this.addWindowListener(new WindowListener() {
        @Override
        public void windowOpened(WindowEvent we) {
        }

        @Override
        public void windowClosing(WindowEvent we) {
            saveConfig();
        }

        @Override
        public void windowClosed(WindowEvent we) {
        }

        @Override
        public void windowIconified(WindowEvent we) {
        }

        @Override
        public void windowDeiconified(WindowEvent we) {
        }

        @Override
        public void windowActivated(WindowEvent we) {
        }

        @Override
        public void windowDeactivated(WindowEvent we) {
        }
    });

    GridBagConstraints c = new GridBagConstraints();

    setResizable(true);
    setIconImage((new ImageIcon("spikeup.png")).getImage());

    jta = new JTextArea(38, 30);

    loadConfig();

    JScrollPane jsp = new JScrollPane(jta);
    jsp.setRowHeaderView(new TextLineNumber(jta));
    jsp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    jsp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
    jsp.setSize(jsp.getWidth(), 608);

    // menu bar
    JMenuBar menubar = new JMenuBar();

    // file menu
    JMenu file = new JMenu("File");

    // load button
    JMenuItem load = new JMenuItem("Load jmap");
    load.addActionListener(ae -> {
        JFileChooser fileChooser = new JFileChooser(prevDirectory);
        fileChooser.setFileFilter(new FileNameExtensionFilter("jmap file", "jmap", "jmap"));

        int returnValue = fileChooser.showOpenDialog(null);

        if (returnValue == JFileChooser.APPROVE_OPTION) {
            File selectedFile = fileChooser.getSelectedFile();

            prevDirectory = selectedFile.getAbsolutePath();

            jm2s = new ScriptFromJmap(selectedFile.getPath(), false);

            jta.setText("");
            jta.append(jm2s.toString());
            jta.setCaretPosition(0);

            writeFile.setEnabled(true);

            drawPanel.setItems(jta.getText().split("\n"));
        }
    });

    // add load to file menu
    file.add(load);

    // button to save script to file
    writeFile = new JMenuItem("Write file");
    writeFile.addActionListener(ae -> {
        if (jm2s != null) {
            PrintWriter out;
            try {
                File f = new File(
                        jm2s.getFileName().substring(0, jm2s.getFileName().lastIndexOf(".jmap")) + ".gml");
                out = new PrintWriter(f);
                out.append(jm2s.toString());
                out.close();
            } catch (FileNotFoundException ex) {
                Logger.getLogger(ScriptGui.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    });
    writeFile.setEnabled(false);

    JMenuItem gmx = new JMenuItem("Export as gmx");
    gmx.addActionListener(ae -> {
        String fn = String.format("%s.room.gmx", prevDirectory);

        JFileChooser fc = new JFileChooser(prevDirectory);
        fc.setSelectedFile(new File(fn));
        fc.setFileFilter(new FileNameExtensionFilter("Game Maker XML", "gmx", "gmx"));
        fc.showDialog(null, "Save");
        File f = fc.getSelectedFile();

        if (f != null) {
            try {
                GMX.itemsToGMX(drawPanel.items, new FileOutputStream(f));
            } catch (FileNotFoundException ex) {
                Logger.getLogger(ScriptGui.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    });

    // add to file menu
    file.add(writeFile);
    file.add(gmx);

    // add file menu to the menubar
    menubar.add(file);

    // Edit menu

    // display menu
    JMenu display = new JMenu("Display");

    JMenuItem update = new JMenuItem("Update");

    update.addActionListener(ae -> {
        drawPanel.setItems(jta.getText().split("\n"));
    });

    display.add(update);

    JMenuItem gridToggle = new JMenuItem("Toggle Grid");
    gridToggle.addActionListener(ae -> {
        drawPanel.toggleGrid();
    });
    display.add(gridToggle);

    JMenuItem gridOptions = new JMenuItem("Modify Grid");
    gridOptions.addActionListener(ae -> {
        drawPanel.modifyGrid();
    });
    display.add(gridOptions);

    menubar.add(display);

    // sets the menubar
    setJMenuBar(menubar);

    // add the text area to the window
    c.gridx = 0;
    c.gridy = 0;
    add(jsp, c);

    // initialize the preview panel
    drawPanel = new Preview(this);
    JScrollPane scrollPane = new JScrollPane(drawPanel);

    // add preview panel to the window
    c.gridx = 1;
    c.gridwidth = 2;
    add(scrollPane, c);

    pack();
    setMinimumSize(this.getSize());
    setLocationRelativeTo(null);
    setVisible(true);
    drawPanel.setItems(jta.getText().split("\n"));
}

From source file:com.k42b3.sacmis.Sacmis.java

public Sacmis(String path, String file, int exitCode, boolean writerStdIn) throws Exception {
    this.path = path;
    this.file = file;
    this.exitCode = exitCode;
    this.writerStdIn = writerStdIn;

    this.setTitle("sacmis (version: " + ver + ")");

    this.setLocation(100, 100);

    this.setSize(600, 500);

    this.setMinimumSize(this.getSize());

    // arguments// ww  w . j  a v a2s .com
    JPanel panelArgs = new JPanel();

    panelArgs.setLayout(new BorderLayout());

    panelArgs.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));

    this.args = new Args();

    this.args.setText(file);

    panelArgs.add(this.args, BorderLayout.CENTER);

    this.add(panelArgs, BorderLayout.NORTH);

    // main panel
    JSplitPane sp = new JSplitPane(JSplitPane.VERTICAL_SPLIT);

    this.in = new In();

    JScrollPane scrIn = new JScrollPane(this.in);

    scrIn.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));

    scrIn.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);

    scrIn.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);

    sp.add(scrIn);

    this.out = new Out();

    JScrollPane scrOut = new JScrollPane(this.out);

    scrOut.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));

    scrOut.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);

    scrOut.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);

    sp.add(scrOut);

    this.add(sp, BorderLayout.CENTER);

    // toolbar
    this.toolbar = new Toolbar();

    this.toolbar.getRun().addActionListener(new runHandler());
    this.toolbar.getReset().addActionListener(new resetHandler());
    this.toolbar.getAbout().addActionListener(new aboutHandler());
    this.toolbar.getExit().addActionListener(new exitHandler());

    this.getContentPane().add(this.toolbar, BorderLayout.SOUTH);

    this.setVisible(true);

    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    this.loadFile();
}