SHARE
TWEET

Untitled

a guest Oct 15th, 2019 83 in 330 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package com.mycompany.interfacesestudioabellan;
  7.  
  8. import javax.swing.*;
  9. import java.awt.*;
  10.  
  11. /**
  12.  *
  13.  * @author abell
  14.  */
  15. public class EjClase {
  16.     private static JPanel col1 = new JPanel();
  17.     private static JPanel col2 = new JPanel();
  18.     private static JPanel col3 = new JPanel();
  19.     private static JPanel col4 = new JPanel();
  20.     private static JPanel panelGrid = new JPanel();
  21.     private static JRadioButton cpu1, cpu2, cpu3, cpu4, ram1, ram2, ram3, ram4, m1, m2, m3, m4;
  22.     private static JCheckBox mouse1, mouse2, kb1, kb2;
  23.     private static JButton bImprimir;
  24.    
  25.     public static void addComponentsToPane(final Container pane) {
  26.         pane.setLayout(new BorderLayout());      
  27.        
  28.         bImprimir = new JButton("Imprimir");
  29.         cpu1 = new JRadioButton("Intel 1");
  30.         cpu2 = new JRadioButton("Intel 2");
  31.         cpu3 = new JRadioButton("AMD 1");
  32.         cpu4 = new JRadioButton("AMD 2");
  33.         ram1 = new JRadioButton("RAM 1GB");
  34.         ram2 = new JRadioButton("RAM 2GB");
  35.         ram3 = new JRadioButton("RAM 4GB");
  36.         ram4 = new JRadioButton("RAM 8GB");
  37.         m1 = new JRadioButton("LG 1");
  38.         m2 = new JRadioButton("LG 2");
  39.         m3 = new JRadioButton("HP 1");
  40.         m4 = new JRadioButton("HP 2");
  41.         mouse1 = new JCheckBox("Raton normal");
  42.         mouse2 = new JCheckBox("Raton pro");
  43.         kb1 = new JCheckBox("Teclado normal");
  44.         kb2 = new JCheckBox("Teclado pro");
  45.        
  46.         panelGrid.setLayout(new GridLayout(1,4));
  47.         col1.setLayout(new GridLayout(4,0));
  48.         col2.setLayout(new GridLayout(4,0));
  49.         col3.setLayout(new GridLayout(4,0));
  50.         col4.setLayout(new GridLayout(4,0));
  51.        
  52.        
  53.         ButtonGroup cpus = new ButtonGroup();
  54.         cpus.add(cpu1);
  55.         cpus.add(cpu2);
  56.         cpus.add(cpu3);
  57.         cpus.add(cpu4);
  58.        
  59.         col1.add(cpu1);
  60.         col1.add(cpu2);
  61.         col1.add(cpu3);
  62.         col1.add(cpu4);      
  63.         col1.setBorder(BorderFactory.createTitledBorder("CPUs"));
  64.         panelGrid.add(col1);
  65.                
  66.         col2.add(ram1);
  67.         col2.add(ram2);
  68.         col2.add(ram3);
  69.         col2.add(ram4);      
  70.         col2.setBorder(BorderFactory.createTitledBorder("RAMs"));
  71.         panelGrid.add(col2);
  72.        
  73.         col3.add(m1);
  74.         col3.add(m2);
  75.         col3.add(m3);
  76.         col3.add(m4);
  77.         col3.setBorder(BorderFactory.createTitledBorder("Monitores"));
  78.         panelGrid.add(col3);
  79.        
  80.         col4.add(mouse1);
  81.         col4.add(mouse2);
  82.         col4.add(kb1);
  83.         col4.add(kb2);
  84.         col4.setBorder(BorderFactory.createTitledBorder("Varios"));
  85.         panelGrid.add(col4);
  86.        
  87.         pane.add(bImprimir, BorderLayout.SOUTH);
  88.         pane.add(panelGrid, BorderLayout.CENTER);
  89.        
  90.     }
  91.    
  92.     private static void createAndShowGUI() {
  93.         //Create and set up the window.
  94.         JFrame frame = new JFrame("EjClase");
  95.         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  96.         //Set up the content pane.
  97.         addComponentsToPane(frame.getContentPane());
  98.         //Display the window.
  99.         frame.pack();
  100.         frame.setVisible(true);
  101.     }
  102.    
  103.     public static void main(String[] args) {
  104.         /* Use an appropriate Look and Feel */
  105.         try {
  106.             UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
  107.             //UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
  108.         } catch (UnsupportedLookAndFeelException ex) {
  109.             ex.printStackTrace();
  110.         } catch (IllegalAccessException ex) {
  111.             ex.printStackTrace();
  112.         } catch (InstantiationException ex) {
  113.             ex.printStackTrace();
  114.         } catch (ClassNotFoundException ex) {
  115.             ex.printStackTrace();
  116.         }
  117.         //Schedule a job for the event dispatchi thread:
  118.         //creating and showing this application's GUI.
  119.         javax.swing.SwingUtilities.invokeLater(new Runnable() {
  120.             public void run() {
  121.                 createAndShowGUI();
  122.             }
  123.         });
  124.     }
  125. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top