Example usage for javax.swing ScrollPaneConstants HORIZONTAL_SCROLLBAR_NEVER

List of usage examples for javax.swing ScrollPaneConstants HORIZONTAL_SCROLLBAR_NEVER

Introduction

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

Prototype

int HORIZONTAL_SCROLLBAR_NEVER

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

Click Source Link

Document

Used to set the horizontal scroll bar policy so that horizontal scrollbars are never displayed.

Usage

From source file:com.haulmont.cuba.desktop.gui.components.DesktopScrollBoxLayout.java

public DesktopScrollBoxLayout() {
    impl = new JScrollPane();
    // by default it is turned off
    impl.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    impl.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
    impl.setBorder(null);/*from w  w w. j  ava  2s  .c o m*/

    content = new DesktopVBox();

    DesktopVBox contentPane = new DesktopVBox();
    contentPane.setContainer(this);
    contentPane.add(content);

    impl.setViewportView(DesktopComponentsHelper.getComposition(contentPane));

    applyScrollBarPolicy(scrollBarPolicy);

    // support tables with 100% width like in web
    impl.addComponentListener(new ComponentAdapter() {
        @Override
        public void componentResized(ComponentEvent e) {
            adjustViewPreferredSize();
        }
    });

    setWidth("100%");
}

From source file:com.willwinder.universalgcodesender.uielements.macros.MacroActionPanel.java

public MacroActionPanel(BackendAPI backend) {
    if (backend == null) {
        throw new RuntimeException("BackendAPI must be provided.");
    }//from   w  ww.  j  a  va2  s.c om
    setMinimumSize(new Dimension(50, 0));
    this.backend = backend;
    backend.addUGSEventListener(this);

    // Insert a scrollpane in case the buttons wont fit.
    JScrollPane scrollPane = new JScrollPane(macroPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPane.setBorder(BorderFactory.createEmptyBorder());
    setLayout(new BorderLayout());
    add(scrollPane, BorderLayout.CENTER);
}

From source file:net.sf.firemox.ui.wizard.AboutMdb.java

/**
 * Creates a new instance of AboutMdb <br>
 * /*w w  w.ja v  a  2  s  . c o  m*/
 * @param parent
 */
public AboutMdb(JFrame parent) {
    super(LanguageManager.getString("about.tbs"),
            "<html><b>" + LanguageManager.getString("tbsname") + ": </b>" + MdbLoader.getTbsFullName()
                    + "<br><b>" + LanguageManager.getString("author") + ": </b>" + MdbLoader.getAuthor()
                    + "<br><b>" + LanguageManager.getString("info") + ": </b>" + MdbLoader.getMoreInfo()
                    + "<br><b>" + LanguageManager.getString("version") + ": </b>" + MdbLoader.getVersion(),
            "mp64.gif", LanguageManager.getString("close"), 420, 320);
    JTextArea disclaimer = new JTextArea();
    disclaimer.setEditable(false);
    disclaimer.setLineWrap(true);
    disclaimer.setWrapStyleWord(true);
    disclaimer.setAutoscrolls(true);
    // Then try and read it locally
    final InputStream inGPL = MToolKit.getResourceAsStream(MToolKit.mdbFile);
    if (inGPL != null) {
        disclaimer.setText(MdbLoader.getDisclaimer().replaceAll("\t", "").replaceAll("\n", ""));
        IOUtils.closeQuietly(inGPL);
    }
    JScrollPane disclaimerSPanel = new JScrollPane();
    disclaimerSPanel.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    MToolKit.addOverlay(disclaimerSPanel);
    disclaimerSPanel.setViewportView(disclaimer);
    gameParamPanel.add(disclaimerSPanel);
    setLocation((getToolkit().getScreenSize().width - 420) / 2,
            (getToolkit().getScreenSize().height - 320) / 2);
}

From source file:gdt.jgui.tool.JIconSelector.java

/**
 * The default constructor.//from   w ww .j a va2  s  .  com
 */
public JIconSelector() {
    FlowLayout flowLayout = new FlowLayout(FlowLayout.LEFT, 5, 5);
    flowLayout.setAlignOnBaseline(true);
    WrapLayout wrapLayout = new WrapLayout(FlowLayout.LEFT, 5, 5);
    wrapLayout.setAlignOnBaseline(true);
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    panel = new JPanel();
    panel.setLayout(wrapLayout);
    scrollPane = new JScrollPane(panel);
    add(scrollPane);
    scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
}

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

private void initComponents() {
    if (colorEnabled) {
        JTextPane text = new JTextPane() {
            @Override//w w w.  ja v  a 2s  . c om
            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:com.stefanbrenner.droplet.ui.DevicePanel.java

/**
 * Create the panel.//from w w w  . j  av a  2s  .c  om
 */
public DevicePanel(final JComponent parent, final IDroplet droplet, final T device) {

    this.parent = parent;

    setDevice(device);

    setLayout(new BorderLayout(0, 5));
    setBorder(BorderFactory.createLineBorder(Color.BLACK));
    setBackground(DropletColors.getBackgroundColor(device));

    BeanAdapter<T> adapter = new BeanAdapter<T>(device, true);

    // device name textfield
    txtName = BasicComponentFactory.createTextField(adapter.getValueModel(IDevice.PROPERTY_NAME));
    txtName.setHorizontalAlignment(SwingConstants.CENTER);
    txtName.setColumns(1);
    txtName.setToolTipText(device.getName());
    adapter.addBeanPropertyChangeListener(IDevice.PROPERTY_NAME, new PropertyChangeListener() {

        @Override
        public void propertyChange(final PropertyChangeEvent event) {
            txtName.setToolTipText(device.getName());
        }
    });
    add(txtName, BorderLayout.NORTH);

    // actions panel with scroll pane
    actionsPanel = new JPanel();
    actionsPanel.setLayout(new BoxLayout(actionsPanel, BoxLayout.Y_AXIS));
    actionsPanel.setBackground(getBackground());

    JScrollPane scrollPane = new JScrollPane(actionsPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    // resize vertical scrollbar
    scrollPane.getVerticalScrollBar().putClientProperty("JComponent.sizeVariant", "mini"); //$NON-NLS-1$ //$NON-NLS-2$
    SwingUtilities.updateComponentTreeUI(scrollPane);
    // we need no border
    scrollPane.setBorder(BorderFactory.createEmptyBorder());
    add(scrollPane, BorderLayout.CENTER);

    {
        JPanel panel = new JPanel();
        panel.setLayout(new GridLayout(0, 1));

        createAddButton(panel);

        // remove button
        JButton btnRemove = new JButton(Messages.getString("ActionDevicePanel.removeDevice")); //$NON-NLS-1$
        btnRemove.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(final ActionEvent action) {
                int retVal = JOptionPane.showConfirmDialog(DevicePanel.this,
                        Messages.getString("ActionDevicePanel.removeDevice") + " '" + device.getName() + "'?", //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
                        StringUtils.EMPTY, JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
                if (retVal == JOptionPane.YES_OPTION) {
                    droplet.removeDevice(device);
                }
            }
        });
        btnRemove.setFocusable(false);
        panel.add(btnRemove);

        add(panel, BorderLayout.SOUTH);
    }

}

From source file:net.sf.firemox.ui.component.SplashScreen.java

/**
 * Create a new instance of this class./*  w w  w  .j  a  v a  2 s  . co  m*/
 * 
 * @param filename
 *          the picture filename.
 * @param parent
 *          the splash screen's parent.
 * @param waitTime
 *          the maximum time before the screen is hidden.
 */
public SplashScreen(String filename, Frame parent, int waitTime) {
    super(parent);
    getContentPane().setLayout(null);
    toFront();
    final JLabel l = new JLabel(new ImageIcon(filename));
    final Dimension labelSize = l.getPreferredSize();
    l.setLocation(0, 0);
    l.setSize(labelSize);
    setSize(labelSize);

    final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    setLocation(screenSize.width / 2 - labelSize.width / 2, screenSize.height / 2 - labelSize.height / 2);

    final JLabel mp = new JLabel(IdConst.PROJECT_DISPLAY_NAME);
    mp.setLocation(30, 305);
    mp.setSize(new Dimension(300, 30));

    final JLabel version = new JLabel(IdConst.VERSION);
    version.setLocation(235, 418);
    version.setSize(new Dimension(300, 30));

    final JTextArea disclaimer = new JTextArea();
    disclaimer.setEditable(false);
    disclaimer.setLineWrap(true);
    disclaimer.setWrapStyleWord(true);
    disclaimer.setAutoscrolls(true);
    disclaimer.setFont(MToolKit.defaultFont);
    disclaimer.setTabSize(2);

    // Then try and read it locally
    Reader inGPL = null;
    try {
        inGPL = new BufferedReader(new InputStreamReader(MToolKit.getResourceAsStream(IdConst.FILE_LICENSE)));
        disclaimer.read(inGPL, "");
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        IOUtils.closeQuietly(inGPL);
    }

    final JScrollPane disclaimerSPanel = new JScrollPane();
    disclaimerSPanel.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    disclaimerSPanel.setViewportView(disclaimer);
    disclaimerSPanel.setLocation(27, 340);
    disclaimerSPanel.setPreferredSize(new Dimension(283, 80));
    disclaimerSPanel.setSize(disclaimerSPanel.getPreferredSize());

    getContentPane().add(disclaimerSPanel);
    getContentPane().add(version);
    getContentPane().add(mp);
    getContentPane().add(l);

    final int pause = waitTime;
    final Runnable waitRunner = new Runnable() {
        public void run() {
            try {
                Thread.sleep(pause);
                while (!bKilled) {
                    Thread.sleep(200);
                }
            } catch (InterruptedException e) {
                // Ignore this error
            }
            setVisible(false);
            dispose();
            MagicUIComponents.magicForm.toFront();
        }
    };

    // setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    addMouseListener(new MouseAdapter() {
        @Override
        public void mousePressed(MouseEvent e) {
            setVisible(false);
            dispose();
            if (MagicUIComponents.magicForm != null)
                MagicUIComponents.magicForm.toFront();
        }
    });
    addKeyListener(new KeyAdapter() {
        @Override
        public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_SPACE) {
                setVisible(false);
                dispose();
                MagicUIComponents.magicForm.toFront();
            }
        }
    });
    setVisible(true);
    start(waitRunner);
}

From source file:dk.dma.epd.common.prototype.gui.voct.VOCTAdditionalInfoPanel.java

/**
 * Constructor/*from w ww . j  av  a2  s  .com*/
 * 
 * @param compactLayout
 *            if false, there will be message type selectors in the panel
 */
public VOCTAdditionalInfoPanel(boolean compactLayout) {
    super(new BorderLayout());

    EPD.getInstance().getVoctHandler().addVoctSarInfoListener(this);

    // 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 (false) {
    // 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();

    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));

    }

    if (compactLayout) {
        addBtn = new JButton("Add to Log");
        sendPanel.add(addBtn, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, NORTH, NONE, insets, 0, 0));
    }
    // addBtn.setEnabled(false);
    // messageText.setEditable(false);
    addBtn.addActionListener(this);
}

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

/**
 * {@inheritDoc}/*from w  ww  .  j  a  v a2  s.c  o 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.offbynull.peernetic.debug.visualizer.JGraphXVisualizer.java

/**
 * Creates a {@link JGraphXVisualizer} object.
 *///ww  w  . ja  v a  2 s .  co  m
public JGraphXVisualizer() {

    graph = new mxGraph();
    graph.setCellsEditable(false);
    graph.setAllowDanglingEdges(false);
    graph.setAllowLoops(false);
    graph.setCellsDeletable(false);
    graph.setCellsCloneable(false);
    graph.setCellsDisconnectable(false);
    graph.setDropEnabled(false);
    graph.setSplitEnabled(false);
    graph.setCellsBendable(false);
    graph.setConnectableEdges(false);
    graph.setCellsMovable(false);
    graph.setCellsResizable(false);
    graph.setAutoSizeCells(true);

    component = new mxGraphComponent(graph);
    component.setConnectable(false);

    component.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    component.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);

    nodeLookupMap = new DualHashBidiMap<>();
    connToEdgeLookupMap = new MultiValueMap<>();
    edgeToConnLookupMap = new HashMap<>();
    vertexLingerTriggerMap = new HashMap<>();

    textOutputArea = new JTextArea();
    textOutputArea.setLineWrap(false);
    textOutputArea.setEditable(false);
    JScrollPane textOutputScrollPane = new JScrollPane(textOutputArea);
    textOutputScrollPane.setPreferredSize(new Dimension(0, 100));

    frame = new JFrame("Visualizer");
    frame.setSize(400, 400);
    frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);

    JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, component, textOutputScrollPane);
    splitPane.setResizeWeight(1.0);

    frame.setContentPane(splitPane);

    component.addComponentListener(new ComponentAdapter() {

        @Override
        public void componentResized(ComponentEvent e) {
            zoomFit();
        }
    });

    frame.addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosed(WindowEvent e) {
            Recorder<A> rec = recorder.get();
            if (rec != null) {
                IOUtils.closeQuietly(rec);
            }

            VisualizerEventListener veListener = listener.get();
            if (veListener != null) {
                veListener.closed();
            }
        }
    });

    frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);

    splitPane.setDividerLocation(0.2);
}