Java Code Examples for javax.swing.JScrollPane#VERTICAL_SCROLLBAR_NEVER

The following examples show how to use javax.swing.JScrollPane#VERTICAL_SCROLLBAR_NEVER . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StartupConfigurator.java    From visualvm with GNU General Public License v2.0 6 votes vote down vote up
private static TextAreaComponent createTextArea(int rows) {
    final JTextArea rootsArea = new JTextArea();
    rootsArea.setEditable(false);
    rootsArea.setFont(new Font("Monospaced", Font.PLAIN, UIManager.getFont("Label.font").getSize())); // NOI18N
    TextAreaComponent rootsAreaScrollPane = new TextAreaComponent(rootsArea,
            JScrollPane.VERTICAL_SCROLLBAR_NEVER,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER) {
        public Dimension getMinimumSize() {
            return getPreferredSize();
        }
        public void setEnabled(boolean enabled) {
            super.setEnabled(enabled);
            rootsArea.setEnabled(enabled);
        }
    };
    rootsAreaScrollPane.setBorder(BorderFactory.createLineBorder(Color.GRAY));
    JTextArea referenceArea = new JTextArea("X"); // NOI18N
    referenceArea.setFont(rootsArea.getFont());
    referenceArea.setRows(rows);
    Insets insets = rootsAreaScrollPane.getInsets();
    rootsAreaScrollPane.setPreferredSize(new Dimension(1, referenceArea.getPreferredSize().height + 
            (insets != null ? insets.top + insets.bottom : 0)));
    return rootsAreaScrollPane;
}
 
Example 2
Source File: MapGeneratorOptionsDialog.java    From freecol with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a dialog to set the map generator options.
 *
 * @param freeColClient The {@code FreeColClient} for the game.
 * @param frame The owner frame.
 * @param editable Whether the options may be edited.
 */
public MapGeneratorOptionsDialog(FreeColClient freeColClient, JFrame frame,
                                 boolean editable) {
    super(freeColClient, frame, editable,
          freeColClient.getGame().getMapGeneratorOptions(),
          MapGeneratorOptions.TAG,
          FreeColDirectories.MAP_GENERATOR_OPTIONS_FILE_NAME,
          MapGeneratorOptions.TAG);

    if (isEditable()) {
        loadDefaultOptions();
        // FIXME: The update should be solved by PropertyEvent.

        final List<File> mapFiles = FreeColDirectories.getMapFileList();
        JPanel mapPanel = new JPanel();
        for (File f : mapFiles) {
            JButton mapButton = makeMapButton(f);
            if (mapButton == null) continue;
            mapButton.addActionListener((ActionEvent ae) -> {
                    updateFile(f);
                });
            mapPanel.add(mapButton);
        }

        JScrollPane scrollPane = new JScrollPane(mapPanel,
            JScrollPane.VERTICAL_SCROLLBAR_NEVER,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
        scrollPane.getVerticalScrollBar().setUnitIncrement(16);
        scrollPane.getViewport().setOpaque(false);
        panel.add(scrollPane, "height 80%, width 100%");
    }
    initialize(frame, choices());
}
 
Example 3
Source File: JCarouselMenu.java    From radiance with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * Creates a new instance of JCarouselMenu
 * @param border The border to use to draw items in the menu
 */
public JCarouselMenu(ImageBorder border) {
    carousel = new JCarosel();
    carousel.setLayout(new OffsetCaroselLayout(carousel));
    carousel.setBackground(null);
    carousel.setOpaque(false);
    carousel.setContentWidth(256);
    
    super.setLayout(new GridLayout(1,2));
    super.add(carousel);
    
    upButton.setForeground(Color.WHITE);
    downButton.setForeground(Color.WHITE);
    
    JPanel menuPanel = new JPanel();
    menuPanel.setBackground(null);
    menuPanel.setOpaque(false);
    menuPanel.setLayout(new GridBagLayout());
    GridBagConstraints gbc  = new GridBagConstraints();
    
    menu = new JList();
    menuScroll = new JScrollPane(menu, JScrollPane.VERTICAL_SCROLLBAR_NEVER, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    menuScroll.getViewport().setOpaque(false);
    menuScroll.setBorder(null);
    menuScroll.getViewport().addChangeListener(this);
    menu.setModel(menuModel);
    menu.setCellRenderer(new CarouselListCellRenderer(border));
    menu.setBackground(null);       
    menu.setOpaque(false);
    menu.addListSelectionListener(this);
    menuScroll.setOpaque(true);
    menuScroll.setBackground(Color.BLACK);
    menuScroll.setBorder(BorderFactory.createEmptyBorder());
    
    gbc.weightx=0.0;
    gbc.weighty=0.0;
    gbc.gridy=0;
    gbc.fill=GridBagConstraints.HORIZONTAL;
    menuPanel.add(upButton,gbc);
    gbc.weighty=1.0;
    gbc.weightx=1.0;
    gbc.gridy++;
    gbc.fill=GridBagConstraints.BOTH;
    menuPanel.add(menuScroll,gbc);
    gbc.weighty=0.0;
    gbc.weightx=0.0;
    gbc.gridy++;
    gbc.fill=GridBagConstraints.HORIZONTAL;
    menuPanel.add(downButton,gbc);
    menu.addMouseListener(this);
    menu.addKeyListener(this);
            
    //Don't want it to listen to itself...
    carousel.removeMouseWheelListener(carousel);
    carousel.addMouseWheelListener(this);
    menu.addMouseWheelListener(this);
    menuScroll.addMouseWheelListener(this);
    menuPanel.addMouseWheelListener(this);
    
    super.add(menuPanel);
}
 
Example 4
Source File: HeaderPanel.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private void initComponents() {
    JTable impl = new JTable(new DefaultTableModel(new Object[] { "" }, 0)); // NOI18N
    TableColumnModel colMod = impl.getColumnModel();
    final TableColumn col = colMod.getColumn(0);
    impl.setFocusable(false);
    header = new Header(colMod);
    impl.setTableHeader(header);
    header.setResizingAllowed(false);
    header.setReorderingAllowed(false);

    final TableCellRenderer renderer = header.getDefaultRenderer();
    header.setDefaultRenderer(new TableCellRenderer() {
        public Component getTableCellRendererComponent(
                JTable table, Object value, boolean isSelected, boolean hasFocus,
                int row, int column) {

            Component component = renderer.getTableCellRendererComponent(
                    table, getRendererValue(), isSelected(),
                    isSelected(), row, processMouseEvents() ? 0 : 1);

            setupRenderer(component);

            col.setWidth(header.getWidth());
            return component;
        }
    });

    JScrollPane scroll = new JScrollPane(impl, JScrollPane.VERTICAL_SCROLLBAR_NEVER,
                                               JScrollPane.HORIZONTAL_SCROLLBAR_NEVER) {
        public Dimension getPreferredSize() { return header.getPreferredSize(); }
        public void reshape(int x, int y, int width, int height) {
            header.setPreferredSize(new Dimension(width, height));
            super.reshape(x, y, width, height);
        }
    };
    scroll.setBorder(BorderFactory.createEmptyBorder());
    scroll.setViewportBorder(BorderFactory.createEmptyBorder());

    setLayout(new OverlayLayout(this));
    add(scroll);
}
 
Example 5
Source File: HeaderPanel.java    From visualvm with GNU General Public License v2.0 4 votes vote down vote up
private void initComponents() {
    JTable impl = new JTable(new DefaultTableModel(new Object[] { "" }, 0)); // NOI18N
    TableColumnModel colMod = impl.getColumnModel();
    final TableColumn col = colMod.getColumn(0);
    impl.setFocusable(false);
    header = new Header(colMod);
    impl.setTableHeader(header);
    header.setResizingAllowed(false);
    header.setReorderingAllowed(false);

    final TableCellRenderer renderer = header.getDefaultRenderer();
    header.setDefaultRenderer(new TableCellRenderer() {
        public Component getTableCellRendererComponent(
                JTable table, Object value, boolean isSelected, boolean hasFocus,
                int row, int column) {

            Component component = renderer.getTableCellRendererComponent(
                    table, getRendererValue(), isSelected(),
                    isSelected(), row, processMouseEvents() ? 0 : 1);

            setupRenderer(component);

            col.setWidth(header.getWidth());
            return component;
        }
    });

    JScrollPane scroll = new JScrollPane(impl, JScrollPane.VERTICAL_SCROLLBAR_NEVER,
                                               JScrollPane.HORIZONTAL_SCROLLBAR_NEVER) {
        public Dimension getPreferredSize() { return header.getPreferredSize(); }
        public void reshape(int x, int y, int width, int height) {
            header.setPreferredSize(new Dimension(width, height));
            super.reshape(x, y, width, height);
        }
    };
    scroll.setBorder(BorderFactory.createEmptyBorder());
    scroll.setViewportBorder(BorderFactory.createEmptyBorder());

    setLayout(new OverlayLayout(this));
    add(scroll);
}
 
Example 6
Source File: HeaderPanel.java    From visualvm with GNU General Public License v2.0 4 votes vote down vote up
private void initComponents() {
    JTable impl = new JTable(new DefaultTableModel(new Object[] { "" }, 0)); // NOI18N
    TableColumnModel colMod = impl.getColumnModel();
    final TableColumn col = colMod.getColumn(0);
    impl.setFocusable(false);
    header = new Header(colMod);
    impl.setTableHeader(header);
    header.setResizingAllowed(false);
    header.setReorderingAllowed(false);

    final TableCellRenderer renderer = header.getDefaultRenderer();
    header.setDefaultRenderer(new TableCellRenderer() {
        public Component getTableCellRendererComponent(
                JTable table, Object value, boolean isSelected, boolean hasFocus,
                int row, int column) {

            Component component = renderer.getTableCellRendererComponent(
                    table, getRendererValue(), isSelected(),
                    isSelected(), row, processMouseEvents() ? 0 : 1);

            setupRenderer(component);

            col.setWidth(header.getWidth());
            return component;
        }
    });

    JScrollPane scroll = new JScrollPane(impl, JScrollPane.VERTICAL_SCROLLBAR_NEVER,
                                               JScrollPane.HORIZONTAL_SCROLLBAR_NEVER) {
        public Dimension getPreferredSize() { return header.getPreferredSize(); }
        public void reshape(int x, int y, int width, int height) {
            header.setPreferredSize(new Dimension(width, height));
            super.reshape(x, y, width, height);
        }
    };
    scroll.setBorder(BorderFactory.createEmptyBorder());
    scroll.setViewportBorder(BorderFactory.createEmptyBorder());

    setLayout(new OverlayLayout(this));
    add(scroll);
}
 
Example 7
Source File: Palette.java    From ChatGameFontificator with The Unlicense 4 votes vote down vote up
public Palette(final String label, Color bgColor, ControlPanelBase controlPanel)
{
    super(new GridBagLayout());

    this.control = controlPanel;

    GridBagConstraints gbc = new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0);

    this.buttonAdd = new JButton("+");
    this.buttonRem = new JButton("-");
    if (label != null)
    {
        this.label = new JLabel(label);
    }
    this.swatchPanel = new SwatchPanel(bgColor);

    gbc.weightx = 0.0;

    if (label != null)
    {
        gbc.gridheight = 2;
        add(this.label, gbc);
        gbc.gridx++;
    }
    gbc.gridheight = 1;
    add(this.buttonAdd, gbc);
    gbc.gridy++;
    add(this.buttonRem, gbc);
    gbc.gridy = 0;
    gbc.gridx++;
    gbc.gridheight = 2;

    paletteScrollPane = new JScrollPane(this.swatchPanel, JScrollPane.VERTICAL_SCROLLBAR_NEVER, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    paletteScrollPane.setPreferredSize(new Dimension(512, getHeight()));

    gbc.weightx = 0.0;
    gbc.fill = GridBagConstraints.VERTICAL;
    gbc.anchor = GridBagConstraints.EAST;
    add(paletteScrollPane, gbc);
    gbc.gridx++;

    ActionListener al = new ActionListener()
    {
        public void actionPerformed(ActionEvent e)
        {
            JButton source = (JButton) e.getSource();

            if (source == buttonAdd)
            {
                Color c = JColorChooser.showDialog(ControlWindow.me, "Add Color to Palette" + (label == null ? "" : " for " + label), swatchPanel.isEmpty() ? null : swatchPanel.getColors().get(swatchPanel.getCount() - 1));
                if (c != null)
                {
                    addColor(c);
                    control.update();
                    validate();
                    repaint();
                }
            }
            else if (source == buttonRem)
            {
                swatchPanel.removeSelectedColors();
                control.update();
                validate();
                repaint();
            }

        }
    };

    this.buttonAdd.addActionListener(al);
    this.buttonRem.addActionListener(al);

}
 
Example 8
Source File: HelpTranslationDialog.java    From dualsub with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void initComponents() {
	// Features
	final int marginLeft = 30;
	this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
	this.setResizable(false);
	getContentPane().setLayout(new BorderLayout());
	JPanel panel = new JPanel();
	panel.setLayout(null);
	panel.setPreferredSize(new Dimension(getWidth(), getHeight()));
	panel.setBackground(parent.getBackground());
	JScrollPane scroll = new JScrollPane(panel,
			JScrollPane.VERTICAL_SCROLLBAR_NEVER,
			JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
	getContentPane().add(scroll);

	// Title
	final String title = I18N.getHtmlText("PanelTranslation.border.text");
	setTitle(I18N.getText("Window.name.text"));
	JLabel lblTitle = new JLabel(title);
	lblTitle.setFont(new Font("Lucida", Font.BOLD, 20));
	lblTitle.setBounds(marginLeft, 21, 435, 25);
	panel.add(lblTitle);

	// Content
	JLabel lblContent01 = new JLabel(
			I18N.getHtmlText("HelpTranslationDialog.help.01"));
	lblContent01.setBounds(marginLeft, 50, 435, 80);
	panel.add(lblContent01);

	JLabel lblContent02 = new JLabel(
			I18N.getHtmlText("HelpTranslationDialog.help.02"));
	lblContent02.setBounds(marginLeft, 130, 435, 140);
	panel.add(lblContent02);

	// Borders (for debug purposes)
	if (log.isTraceEnabled()) {
		Border border = BorderFactory.createLineBorder(Color.black);
		lblTitle.setBorder(border);
		lblContent01.setBorder(border);
		lblContent02.setBorder(border);
		panel.setBorder(border);
	}
}