Search in sources :

Example 1 with SimpleScrollbarUI

use of net.technicpack.ui.controls.list.SimpleScrollbarUI in project LauncherV3 by TechnicPack.

the class ModpackDataDisplay method initComponents.

private void initComponents() {
    BorderLayout packFeatureLayout = new BorderLayout();
    packFeatureLayout.setHgap(10);
    this.setLayout(packFeatureLayout);
    this.setOpaque(false);
    JPanel imagePanel = new JPanel();
    imagePanel.setOpaque(false);
    imagePanel.setAlignmentX(RIGHT_ALIGNMENT);
    imagePanel.setAlignmentY(TOP_ALIGNMENT);
    imagePanel.setBorder(BorderFactory.createEmptyBorder());
    imagePanel.setPreferredSize(new Dimension(370, 220));
    this.add(imagePanel, BorderLayout.LINE_START);
    packImage = new JButton(resources.getIcon("modpack/ModImageFiller.png"));
    packImage.setIcon(resources.getIcon("modpack/ModImageFiller.png"));
    packImage.setAlignmentX(RIGHT_ALIGNMENT);
    packImage.setPreferredSize(new Dimension(370, 220));
    packImage.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    packImage.setBorder(BorderFactory.createEmptyBorder());
    packImage.setContentAreaFilled(false);
    packImage.setFocusPainted(false);
    packImage.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            DesktopUtils.browseUrl(packSiteUrl);
        }
    });
    imagePanel.add(packImage);
    JPanel packInfoPanel = new JPanel();
    packInfoPanel.setLayout(new GridBagLayout());
    packInfoPanel.setOpaque(false);
    packInfoPanel.setAlignmentY(TOP_ALIGNMENT);
    packInfoPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    this.add(packInfoPanel, BorderLayout.CENTER);
    statBoxes = new JPanel();
    statBoxes.setLayout(new GridLayout(1, 3, 5, 0));
    statBoxes.setOpaque(false);
    statBoxes.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0));
    ActionListener listener = new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            DesktopUtils.browseUrl(packSiteUrl);
        }
    };
    ratings = new StatBox(resources, resources.getString("launcher.packstats.ratings"), null);
    ratings.setBackground(LauncherFrame.COLOR_LIKES_BACK);
    ratings.setForeground(LauncherFrame.COLOR_WHITE_TEXT);
    ratings.addActionListener(listener);
    statBoxes.add(ratings);
    downloads = new StatBox(resources, resources.getString("launcher.packstats.downloads"), null);
    downloads.setBackground(LauncherFrame.COLOR_FEEDITEM_BACK);
    downloads.setForeground(LauncherFrame.COLOR_WHITE_TEXT);
    downloads.addActionListener(listener);
    statBoxes.add(downloads);
    runs = new StatBox(resources, resources.getString("launcher.packstats.runs"), null);
    runs.setBackground(LauncherFrame.COLOR_FEEDITEM_BACK);
    runs.setForeground(LauncherFrame.COLOR_WHITE_TEXT);
    runs.addActionListener(listener);
    statBoxes.add(runs);
    packInfoPanel.add(statBoxes, new GridBagConstraints(0, 2, 2, 1, 0.0, 0.0, GridBagConstraints.SOUTH, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
    packInfoPanel.add(Box.createHorizontalGlue(), new GridBagConstraints(2, 2, 1, 1, 1.0, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
    discordPanel = new JPanel();
    discordPanel.setOpaque(false);
    discordPanel.setLayout(new GridBagLayout());
    JButton discordImage = new JButton(resources.getIcon("discord.png"));
    discordImage.setContentAreaFilled(false);
    discordImage.setFocusPainted(false);
    discordImage.setBorder(BorderFactory.createEmptyBorder());
    discordImage.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    discordPanel.add(discordImage, new GridBagConstraints(0, 0, 1, 2, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2, 0, 0, 3), 0, 0));
    discordButtons.add(discordImage);
    discordLabel = new JButton(resources.getString("launcher.discord.join"));
    discordLabel.setForeground(LauncherFrame.COLOR_WHITE_TEXT);
    discordLabel.setFont(resources.getFont(ResourceLoader.FONT_OPENSANS, 20));
    discordLabel.setContentAreaFilled(false);
    discordLabel.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
    discordLabel.setFocusPainted(false);
    discordLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    discordPanel.add(discordLabel, new GridBagConstraints(1, 0, 1, 1, 1, 0.5, GridBagConstraints.SOUTHWEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    discordButtons.add(discordLabel);
    countLabel = new JButton(resources.getString("launcher.discord.count", Integer.toString(0)));
    countLabel.setForeground(LauncherFrame.COLOR_WHITE_TEXT);
    countLabel.setFont(resources.getFont(ResourceLoader.FONT_OPENSANS, 14));
    countLabel.setContentAreaFilled(false);
    countLabel.setBorder(BorderFactory.createEmptyBorder());
    countLabel.setFocusPainted(false);
    countLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    discordPanel.add(countLabel, new GridBagConstraints(1, 1, 1, 1, 1, 0.5, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    discordButtons.add(countLabel);
    packInfoPanel.add(discordPanel, new GridBagConstraints(3, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 4), 0, 0));
    discordPanel.setVisible(false);
    titleLabel = new JLabel(resources.getString("launcher.packstats.title", "Modpack"));
    titleLabel.setFont(resources.getFont(ResourceLoader.FONT_RALEWAY, 24, Font.BOLD));
    titleLabel.setForeground(LauncherFrame.COLOR_WHITE_TEXT);
    titleLabel.setHorizontalAlignment(SwingConstants.LEFT);
    titleLabel.setHorizontalTextPosition(SwingConstants.LEFT);
    titleLabel.setAlignmentX(LEFT_ALIGNMENT);
    titleLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    titleLabel.addMouseListener(new MouseListener() {

        @Override
        public void mouseClicked(MouseEvent e) {
            DesktopUtils.browseUrl(packSiteUrl + "/about");
        }

        @Override
        public void mousePressed(MouseEvent e) {
        }

        @Override
        public void mouseReleased(MouseEvent e) {
        }

        @Override
        public void mouseEntered(MouseEvent e) {
        }

        @Override
        public void mouseExited(MouseEvent e) {
        }
    });
    packInfoPanel.add(titleLabel, new GridBagConstraints(0, 0, 4, 1, 1.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
    description = new JTextPane();
    description.setFont(resources.getFont(ResourceLoader.FONT_OPENSANS, 14));
    description.setOpaque(false);
    description.setEditable(false);
    description.setHighlighter(null);
    description.setAlignmentX(LEFT_ALIGNMENT);
    description.setForeground(LauncherFrame.COLOR_WHITE_TEXT);
    description.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    MutableAttributeSet attributes = new SimpleAttributeSet(description.getParagraphAttributes());
    StyleConstants.setLineSpacing(attributes, StyleConstants.getLineSpacing(attributes) * 1.3f);
    description.setParagraphAttributes(attributes, true);
    description.addMouseListener(new MouseListener() {

        @Override
        public void mouseClicked(MouseEvent e) {
            DesktopUtils.browseUrl(packSiteUrl + "/about");
        }

        @Override
        public void mousePressed(MouseEvent e) {
        }

        @Override
        public void mouseReleased(MouseEvent e) {
        }

        @Override
        public void mouseEntered(MouseEvent e) {
        }

        @Override
        public void mouseExited(MouseEvent e) {
        }
    });
    description.setBorder(BorderFactory.createEmptyBorder(8, 8, 8, 8));
    JScrollPane scrollPane = new JScrollPane(description, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPane.setBorder(BorderFactory.createEmptyBorder());
    scrollPane.setOpaque(false);
    scrollPane.getViewport().setOpaque(false);
    scrollPane.getVerticalScrollBar().setUI(new SimpleScrollbarUI(LauncherFrame.COLOR_SCROLL_TRACK, LauncherFrame.COLOR_SCROLL_THUMB));
    scrollPane.getVerticalScrollBar().setPreferredSize(new Dimension(10, 10));
    JPanel scrollHostPanel = new JPanel();
    scrollHostPanel.setBackground(LauncherFrame.COLOR_FEED_BACK);
    scrollHostPanel.setLayout(new BorderLayout());
    scrollHostPanel.add(scrollPane, BorderLayout.CENTER);
    scrollPane.getVerticalScrollBar().addAdjustmentListener(new AdjustmentListener() {

        @Override
        public void adjustmentValueChanged(final AdjustmentEvent e) {
            ModpackDataDisplay.this.repaint();
        }
    });
    packInfoPanel.add(scrollHostPanel, new GridBagConstraints(0, 1, 4, 1, 1.0, 1.0, GridBagConstraints.NORTH, GridBagConstraints.BOTH, new Insets(5, 0, 0, 0), 0, 0));
}
Also used : SimpleScrollbarUI(net.technicpack.ui.controls.list.SimpleScrollbarUI) SimpleAttributeSet(javax.swing.text.SimpleAttributeSet) MutableAttributeSet(javax.swing.text.MutableAttributeSet) StatBox(net.technicpack.ui.controls.feeds.StatBox)

Example 2 with SimpleScrollbarUI

use of net.technicpack.ui.controls.list.SimpleScrollbarUI in project LauncherV3 by TechnicPack.

the class NewsSelector method initComponents.

private void initComponents() {
    setLayout(new BorderLayout());
    setBackground(LauncherFrame.COLOR_SELECTOR_BACK);
    widgetHost = new JPanel();
    widgetHost.setOpaque(false);
    widgetHost.setLayout(new GridBagLayout());
    JScrollPane scrollPane = new JScrollPane(widgetHost, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPane.setBorder(BorderFactory.createEmptyBorder());
    scrollPane.setOpaque(false);
    scrollPane.getViewport().setOpaque(false);
    scrollPane.getVerticalScrollBar().setUI(new SimpleScrollbarUI(LauncherFrame.COLOR_SCROLL_TRACK, LauncherFrame.COLOR_SCROLL_THUMB));
    scrollPane.getVerticalScrollBar().setPreferredSize(new Dimension(10, 10));
    scrollPane.getVerticalScrollBar().setUnitIncrement(12);
    add(scrollPane, BorderLayout.CENTER);
    GridBagConstraints constraints = new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0);
    constraints.weighty = 1.0;
    widgetHost.add(Box.createGlue(), constraints);
}
Also used : SimpleScrollbarUI(net.technicpack.ui.controls.list.SimpleScrollbarUI)

Example 3 with SimpleScrollbarUI

use of net.technicpack.ui.controls.list.SimpleScrollbarUI in project LauncherV3 by TechnicPack.

the class NewsInfoPanel method initComponents.

private void initComponents() {
    setLayout(new GridBagLayout());
    setBorder(BorderFactory.createEmptyBorder(20, 20, 18, 16));
    setBackground(LauncherFrame.COLOR_CENTRAL_BACK_OPAQUE);
    title = new JLabel("");
    title.setForeground(LauncherFrame.COLOR_WHITE_TEXT);
    title.setFont(resources.getFont(ResourceLoader.FONT_RALEWAY, 26));
    title.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    title.addMouseListener(new MouseListener() {

        @Override
        public void mouseClicked(MouseEvent e) {
            visitCurrentItem();
        }

        @Override
        public void mousePressed(MouseEvent e) {
        }

        @Override
        public void mouseReleased(MouseEvent e) {
        }

        @Override
        public void mouseEntered(MouseEvent e) {
        }

        @Override
        public void mouseExited(MouseEvent e) {
        }
    });
    add(title, new GridBagConstraints(0, 0, 2, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
    authorshipInfo = new AuthorshipWidget(resources);
    add(authorshipInfo, new GridBagConstraints(0, 1, 2, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 0, 8, 0), 0, 0));
    newsText = new JTextPane();
    newsText.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    newsText.setOpaque(false);
    newsText.setForeground(LauncherFrame.COLOR_WHITE_TEXT);
    newsText.setFont(resources.getFont(ResourceLoader.FONT_OPENSANS, 16));
    newsText.setEditable(false);
    newsText.setHighlighter(null);
    newsText.setAlignmentX(LEFT_ALIGNMENT);
    newsText.setContentType("text/html");
    newsText.addHyperlinkListener(new HyperlinkListener() {

        @Override
        public void hyperlinkUpdate(HyperlinkEvent e) {
            if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
                if (e.getURL() != null)
                    DesktopUtils.browseUrl(e.getURL().toString());
            }
        }
    });
    newsText.addComponentListener(new ComponentListener() {

        @Override
        public void componentResized(ComponentEvent e) {
            NewsInfoPanel.this.revalidate();
        }

        @Override
        public void componentMoved(ComponentEvent e) {
        }

        @Override
        public void componentShown(ComponentEvent e) {
        }

        @Override
        public void componentHidden(ComponentEvent e) {
        }
    });
    newsScroller = new JScrollPane(newsText, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    newsScroller.getVerticalScrollBar().setUI(new SimpleScrollbarUI(LauncherFrame.COLOR_SCROLL_TRACK, LauncherFrame.COLOR_SCROLL_THUMB));
    newsScroller.getVerticalScrollBar().setPreferredSize(new Dimension(10, 10));
    newsScroller.setBorder(BorderFactory.createEmptyBorder());
    newsScroller.setMaximumSize(new Dimension(32000, 900));
    newsScroller.setOpaque(false);
    newsScroller.getViewport().setOpaque(false);
    JPanel newsTextPanel = new JPanel();
    newsTextPanel.setLayout(new BoxLayout(newsTextPanel, BoxLayout.PAGE_AXIS));
    newsTextPanel.setOpaque(false);
    newsTextPanel.add(newsScroller);
    newsTextPanel.add(Box.createVerticalGlue());
    add(newsTextPanel, new GridBagConstraints(0, 2, 2, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, new Insets(0, 0, 10, 0), 0, 0));
    add(Box.createGlue(), new GridBagConstraints(0, 3, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    RoundedButton discussButton = new RoundedButton(resources.getString("launcher.news.discuss"));
    discussButton.setFont(resources.getFont(ResourceLoader.FONT_OPENSANS, 16));
    discussButton.setBorder(BorderFactory.createEmptyBorder(5, 17, 10, 17));
    discussButton.setForeground(LauncherFrame.COLOR_BUTTON_BLUE);
    discussButton.setHoverForeground(LauncherFrame.COLOR_BLUE);
    discussButton.setAlignmentX(RIGHT_ALIGNMENT);
    discussButton.setContentAreaFilled(false);
    discussButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            visitCurrentItem();
        }
    });
    add(discussButton, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.SOUTHEAST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
}
Also used : HyperlinkEvent(javax.swing.event.HyperlinkEvent) RoundedButton(net.technicpack.ui.controls.RoundedButton) SimpleScrollbarUI(net.technicpack.ui.controls.list.SimpleScrollbarUI) HyperlinkListener(javax.swing.event.HyperlinkListener)

Example 4 with SimpleScrollbarUI

use of net.technicpack.ui.controls.list.SimpleScrollbarUI in project LauncherV3 by TechnicPack.

the class ModpackSelector method initComponents.

private void initComponents() {
    setLayout(new BorderLayout());
    setBackground(LauncherFrame.COLOR_SELECTOR_BACK);
    setMaximumSize(new Dimension(287, getMaximumSize().height));
    JPanel header = new JPanel();
    header.setLayout(new GridBagLayout());
    header.setBorder(BorderFactory.createEmptyBorder(4, 8, 4, 4));
    header.setBackground(LauncherFrame.COLOR_SELECTOR_OPTION);
    add(header, BorderLayout.PAGE_START);
    filterContents = new WatermarkTextField(resources.getString("launcher.packselector.filter.hotfix"), LauncherFrame.COLOR_BLUE_DARKER);
    filterContents.setFont(resources.getFont(ResourceLoader.FONT_OPENSANS, 14));
    filterContents.setBorder(new RoundBorder(LauncherFrame.COLOR_BUTTON_BLUE, 1, 8));
    filterContents.setForeground(LauncherFrame.COLOR_BLUE);
    filterContents.setBackground(LauncherFrame.COLOR_FORMELEMENT_INTERNAL);
    filterContents.setSelectedTextColor(Color.black);
    filterContents.setSelectionColor(LauncherFrame.COLOR_BUTTON_BLUE);
    filterContents.setCaretColor(LauncherFrame.COLOR_BUTTON_BLUE);
    filterContents.setColumns(20);
    ((AbstractDocument) filterContents.getDocument()).setDocumentFilter(new DocumentFilter() {

        @Override
        public void insertString(DocumentFilter.FilterBypass fb, int offset, String string, AttributeSet attr) throws BadLocationException {
            if (fb.getDocument().getLength() + string.length() <= MAX_SEARCH_STRING) {
                fb.insertString(offset, string, attr);
            }
        }

        @Override
        public void remove(DocumentFilter.FilterBypass fb, int offset, int length) throws BadLocationException {
            fb.remove(offset, length);
        }

        @Override
        public void replace(DocumentFilter.FilterBypass fb, int offset, int length, String text, AttributeSet attrs) throws BadLocationException {
            int finalTextLength = (fb.getDocument().getLength() - length) + text.length();
            if (finalTextLength > MAX_SEARCH_STRING)
                text = text.substring(0, text.length() - (finalTextLength - MAX_SEARCH_STRING));
            fb.replace(offset, length, text, attrs);
        }
    });
    filterContents.getDocument().addDocumentListener(new DocumentListener() {

        @Override
        public void insertUpdate(DocumentEvent e) {
            detectFilterChanges();
        }

        @Override
        public void removeUpdate(DocumentEvent e) {
            detectFilterChanges();
        }

        @Override
        public void changedUpdate(DocumentEvent e) {
            detectFilterChanges();
        }
    });
    header.add(filterContents, new GridBagConstraints(1, 0, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(3, 0, 3, 0), 0, 12));
    widgetList = new JPanel();
    widgetList.setOpaque(false);
    widgetList.setLayout(new GridBagLayout());
    scrollPane = new JScrollPane(widgetList, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPane.setOpaque(false);
    scrollPane.setBorder(BorderFactory.createEmptyBorder());
    scrollPane.getViewport().setOpaque(false);
    scrollPane.getVerticalScrollBar().setUI(new SimpleScrollbarUI(LauncherFrame.COLOR_SCROLL_TRACK, LauncherFrame.COLOR_SCROLL_THUMB));
    scrollPane.getVerticalScrollBar().setPreferredSize(new Dimension(10, 10));
    scrollPane.getVerticalScrollBar().setUnitIncrement(12);
    add(scrollPane, BorderLayout.CENTER);
    widgetList.add(Box.createHorizontalStrut(294), new GridBagConstraints(0, 0, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    widgetList.add(Box.createGlue(), new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
}
Also used : DocumentListener(javax.swing.event.DocumentListener) SimpleScrollbarUI(net.technicpack.ui.controls.list.SimpleScrollbarUI) DocumentFilter(javax.swing.text.DocumentFilter) DocumentEvent(javax.swing.event.DocumentEvent) AbstractDocument(javax.swing.text.AbstractDocument) AttributeSet(javax.swing.text.AttributeSet) RoundBorder(net.technicpack.ui.controls.borders.RoundBorder) BadLocationException(javax.swing.text.BadLocationException) WatermarkTextField(net.technicpack.ui.controls.WatermarkTextField)

Aggregations

SimpleScrollbarUI (net.technicpack.ui.controls.list.SimpleScrollbarUI)4 DocumentEvent (javax.swing.event.DocumentEvent)1 DocumentListener (javax.swing.event.DocumentListener)1 HyperlinkEvent (javax.swing.event.HyperlinkEvent)1 HyperlinkListener (javax.swing.event.HyperlinkListener)1 AbstractDocument (javax.swing.text.AbstractDocument)1 AttributeSet (javax.swing.text.AttributeSet)1 BadLocationException (javax.swing.text.BadLocationException)1 DocumentFilter (javax.swing.text.DocumentFilter)1 MutableAttributeSet (javax.swing.text.MutableAttributeSet)1 SimpleAttributeSet (javax.swing.text.SimpleAttributeSet)1 RoundedButton (net.technicpack.ui.controls.RoundedButton)1 WatermarkTextField (net.technicpack.ui.controls.WatermarkTextField)1 RoundBorder (net.technicpack.ui.controls.borders.RoundBorder)1 StatBox (net.technicpack.ui.controls.feeds.StatBox)1