Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import javax.swing.*;
- import javax.swing.border.Border;
- import java.awt.*;
- import java.awt.event.*;
- public class Swing {
- public static void main(String[] args) {
- String[] primaryData = {"nova","xm1014","mag7","m249","negev","mp9","mp7","ump45","p90","bizon","famas","m4a1","ssg08","aug","awp","scar20",};
- JList primaryList = new JList(primaryData);
- JScrollPane primaryPane = new JScrollPane(primaryList);
- String[] secondaryData = {"hkp2000","elite","p250","fiveseven","deagle",};
- JList secondaryList = new JList(secondaryData);
- JScrollPane secondaryPane = new JScrollPane(secondaryList);
- JTextField primaryTitle = new JTextField("Select a Primary Weapon:");
- JTextField secondaryTitle = new JTextField("Select a Secondary Weapon:");
- JButton confirm = new JButton("Confirm");
- JFrame frame = new JFrame("Swing Demo");
- JPanel topPanel = new JPanel();
- JPanel bottomPanel = new JPanel();
- Color orange = new Color(255, 100, 0);
- Color grey = new Color(100, 100, 100);
- Border etch = BorderFactory.createEtchedBorder();
- Border bevel = BorderFactory.createBevelBorder(1, orange, grey);
- primaryTitle.setEditable(false);
- primaryTitle.setPreferredSize(new Dimension(180, 30));
- primaryTitle.setBorder(bevel);
- Font primary = new Font(primaryTitle.getFont().getName(), Font.BOLD, primaryTitle.getFont().getSize());
- primaryTitle.setFont(primary);
- secondaryTitle.setEditable(false);
- secondaryTitle.setPreferredSize(new Dimension(180, 30));
- secondaryTitle.setBorder(bevel);
- Font secondary = new Font(secondaryTitle.getFont().getName(), Font.BOLD, secondaryTitle.getFont().getSize());
- secondaryTitle.setFont(secondary);
- primaryPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
- secondaryPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
- primaryPane.setBorder(BorderFactory.createTitledBorder(etch, "Primary List"));
- primaryPane.setPreferredSize(new Dimension(120, 100));
- secondaryPane.setBorder(BorderFactory.createTitledBorder(etch, "Secondary List"));
- secondaryPane.setPreferredSize(new Dimension(120, 100));
- topPanel.setLayout(new FlowLayout());
- topPanel.setBackground(grey);
- topPanel.add(primaryTitle);
- topPanel.add(primaryPane);
- topPanel.add(secondaryTitle);
- topPanel.add(secondaryPane);
- bottomPanel.setBackground(grey);
- bottomPanel.setLayout(new BoxLayout(bottomPanel, BoxLayout.LINE_AXIS));
- bottomPanel.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10));
- bottomPanel.add(Box.createHorizontalGlue());
- bottomPanel.add(confirm);
- frame.add(topPanel, BorderLayout.CENTER);
- frame.add(bottomPanel, BorderLayout.PAGE_END);
- frame.setSize(400, 300);
- frame.setVisible(true);
- frame.setResizable(false);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement