Advertisement
Guest User

Untitled

a guest
Dec 17th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.78 KB | None | 0 0
  1. import javax.swing.*;
  2. import javax.swing.border.Border;
  3.  
  4. import java.awt.*;
  5. import java.awt.event.*;
  6.  
  7. public class Swing {
  8.     public static void main(String[] args) {
  9.         String[] primaryData = {"nova","xm1014","mag7","m249","negev","mp9","mp7","ump45","p90","bizon","famas","m4a1","ssg08","aug","awp","scar20",};
  10.         JList primaryList = new JList(primaryData);
  11.         JScrollPane primaryPane = new JScrollPane(primaryList);
  12.        
  13.         String[] secondaryData = {"hkp2000","elite","p250","fiveseven","deagle",};
  14.         JList secondaryList = new JList(secondaryData);
  15.         JScrollPane secondaryPane = new JScrollPane(secondaryList);
  16.        
  17.         JTextField primaryTitle = new JTextField("Select a Primary Weapon:");
  18.         JTextField secondaryTitle = new JTextField("Select a Secondary Weapon:");
  19.        
  20.         JButton confirm = new JButton("Confirm");
  21.        
  22.         JFrame frame = new JFrame("Swing Demo");
  23.         JPanel topPanel = new JPanel();
  24.         JPanel bottomPanel = new JPanel();
  25.        
  26.         Color orange = new Color(255, 100, 0);
  27.         Color grey = new Color(100, 100, 100);
  28.        
  29.         Border etch = BorderFactory.createEtchedBorder();
  30.         Border bevel = BorderFactory.createBevelBorder(1, orange, grey);
  31.         primaryTitle.setEditable(false);
  32.         primaryTitle.setPreferredSize(new Dimension(180, 30));
  33.         primaryTitle.setBorder(bevel);
  34.         Font primary = new Font(primaryTitle.getFont().getName(), Font.BOLD, primaryTitle.getFont().getSize());
  35.         primaryTitle.setFont(primary);
  36.        
  37.         secondaryTitle.setEditable(false);
  38.         secondaryTitle.setPreferredSize(new Dimension(180, 30));
  39.         secondaryTitle.setBorder(bevel);
  40.         Font secondary = new Font(secondaryTitle.getFont().getName(), Font.BOLD, secondaryTitle.getFont().getSize());
  41.         secondaryTitle.setFont(secondary);
  42.        
  43.        
  44.         primaryPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
  45.         secondaryPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
  46.        
  47.         primaryPane.setBorder(BorderFactory.createTitledBorder(etch, "Primary List"));
  48.         primaryPane.setPreferredSize(new Dimension(120, 100));
  49.        
  50.         secondaryPane.setBorder(BorderFactory.createTitledBorder(etch, "Secondary List"));
  51.         secondaryPane.setPreferredSize(new Dimension(120, 100));
  52.        
  53.         topPanel.setLayout(new FlowLayout());
  54.         topPanel.setBackground(grey);
  55.         topPanel.add(primaryTitle);
  56.         topPanel.add(primaryPane);
  57.         topPanel.add(secondaryTitle);
  58.         topPanel.add(secondaryPane);
  59.        
  60.         bottomPanel.setBackground(grey);
  61.         bottomPanel.setLayout(new BoxLayout(bottomPanel, BoxLayout.LINE_AXIS));
  62.         bottomPanel.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10));
  63.         bottomPanel.add(Box.createHorizontalGlue());
  64.         bottomPanel.add(confirm);
  65.        
  66.         frame.add(topPanel, BorderLayout.CENTER);
  67.         frame.add(bottomPanel, BorderLayout.PAGE_END);
  68.        
  69.         frame.setSize(400, 300);
  70.         frame.setVisible(true);
  71.         frame.setResizable(false);
  72.     }
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement