use of net.technicpack.ui.controls.feeds.StatBox 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));
}
Aggregations