java – reddit-like GUI – Code Review Stack Exchange

I am not very familiar with Swing but am attempting to make a Reddit GUI. I’ve finally got everything to work as expected but I must admit, it’s quite mundane and not very nice to look at. I want to add some visually appealing things to it but as I said I am very new to Swing. I got help making the components and such for my idea, so I’m feeling a little over-whelmed.

Screenshot of program

P.S. This is definitely advanced for me, so just want to side note I didn’t somehow create this from scratch without help. Also have since fixed the crooked Reddit icon.

package com.Will.me;
 
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.select.Elements;
 
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
 
public class Reddit extends JFrame {
 
 
    static JPanel mainPanel = new JPanel();
    static JTextField textField = new JTextField(20);
    static JButton search = new JButton("Search");
    static JButton() numbers = new JButton(28);
    static JButton() headlines = new JButton(28);
    static JLabel() votes = new JLabel(28);
    static JLabel title = new JLabel("tHeadlines from r/");
 
    public Reddit(){
        mainPanel.setLayout(null);
        setUpComponents();
 
        title.setVisible(false);
 
        search.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
 
                title.setVisible(true);
                String str = textField.getText();
                title.setText("");
                title.setText("tHeadline from r/"+str);
 
                getSubReddit(str);
 
 
            }
        });
 
 
        add(mainPanel);
        setTitle("Reddit");
        setSize(900,600);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setVisible(true);
    }
 
    public static void setUpComponents(){
 
        JLabel redditIcon = new JLabel();
        redditIcon.setBounds(10, 10, 100, 100);
        resizeRedditLogo(redditIcon);
        mainPanel.add(redditIcon);
 
        textField.setBounds(160, 20, 250, 30);
        search.setBounds(415, 23, 85, 25);
        textField.setBackground(Color.decode("#8B0000"));
 
        search.setOpaque(true);
        search.setBorderPainted(false);
        search.setBackground(Color.decode("#8B0000"));
        search.setForeground(Color.WHITE);
        search.setBorder(BorderFactory.createRaisedBevelBorder());
 
        int y = 120;
 
        for (int i = 0; i < numbers.length;i++){
            numbers(i) = new JButton(String.valueOf(i+1));
            numbers(i).setBounds(20, y, 40,30);
            numbers(i).setBackground(Color.decode("#8B0000"));
            numbers(i).setOpaque(true);
            numbers(i).setForeground(Color.WHITE);
            numbers(i).setBorder(BorderFactory.createLoweredSoftBevelBorder());
 
            y+= 40;
 
            numbers(i).setBorderPainted(false);
            mainPanel.add(numbers(i));
        }
 
        int y2 = 120;
 
        for (int i = 0; i < headlines.length;i++){
 
            headlines(i) = new JButton("");
            headlines(i).setBounds(70, y2, 650,30);
            headlines(i).setBackground(Color.decode("#8B0000"));
            headlines(i).setOpaque(true);
            headlines(i).setForeground(Color.WHITE);
            headlines(i).setBorder(BorderFactory.createLoweredSoftBevelBorder());
            y2+= 40;
            headlines(i).setBorderPainted(false);
            mainPanel.add(headlines(i));
 
        }
 
        int y3 = 120;
 
        JLabel voteTitle = new JLabel("# Votes");
        voteTitle.setFont(new Font("Arial", Font.BOLD, 30));
        voteTitle.setForeground(Color.WHITE);
        voteTitle.setBounds(755, 70, 120, 30);
        mainPanel.add(voteTitle);
 
        for (int i = 0; i < votes.length;i++){
 
            votes(i) = new JLabel("");
            votes(i).setBounds(750, y3, 120,30);
            votes(i).setForeground(Color.WHITE);
            votes(i).setBorder(BorderFactory.createRaisedBevelBorder());
            y3+= 40;
            votes(i).setBorder(BorderFactory.createRaisedBevelBorder());
            mainPanel.add(votes(i));
        }
 
 
        textField.setForeground(Color.WHITE);
 
        title.setBorder(BorderFactory.createRaisedBevelBorder());
        title.setBounds(105, 70, 605, 30);
        title.setFont(new Font("Arial", Font.BOLD, 18));
        title.setForeground(Color.WHITE);
        mainPanel.add(title);
        mainPanel.setBackground(Color.RED);
        mainPanel.add(textField);
        mainPanel.add(search);
 
    }
 
    public static void getSubReddit(String sub){
 
 
        try
        {
            Document doc = Jsoup.connect("https://old.reddit.com/r/"+sub).get();
            Elements el = doc.select("p.title");
            Elements score = doc.select("div.score.unvoted");
            int i,j;
 
            for (i=0,j=0;i<el.size() && j<score.size();i++,j++){
 
                headlines(i).setText(el.get(i).text());
                votes(j).setText(score.get(j).text());
            }
 
        } catch (Exception e) {
            System.out.println(e.toString());
        }
 
    }
 
    public static void resizeRedditLogo(JLabel label){
 
        try {
            ImageIcon imageIcon = new ImageIcon(new ImageIcon("../RedditGUI/src/reddit1.png").getImage().getScaledInstance(120, 120, Image.SCALE_DEFAULT));
            label.setIcon(imageIcon);
        } catch (Exception e) {
            e.printStackTrace();
        }
 
 
 
    }
    public static void main(String() args) {
        new Reddit();
    }