carlos0722

Untitled

Feb 28th, 2021
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 9.75 KB | None | 0 0
  1. package problems01;
  2.  
  3. import java.awt.EventQueue;
  4.  
  5. import javax.swing.JFrame;
  6. import javax.swing.JRadioButton;
  7. import java.awt.BorderLayout;
  8. import javax.swing.JPanel;
  9. import java.awt.Panel;
  10. import javax.swing.SwingConstants;
  11. import javax.swing.event.ChangeEvent;
  12. import javax.swing.event.ChangeListener;
  13. import javax.swing.Action;
  14. import javax.swing.ButtonGroup;
  15. import javax.swing.GroupLayout;
  16. import javax.swing.GroupLayout.Alignment;
  17. import java.awt.Checkbox;
  18. import java.awt.TextField;
  19. import javax.swing.JComboBox;
  20. import javax.swing.LayoutStyle.ComponentPlacement;
  21. import java.awt.Choice;
  22. import javax.swing.JSpinner;
  23. import javax.swing.JCheckBox;
  24. import javax.swing.JTextField;
  25. import java.awt.event.ActionListener;
  26. import java.awt.event.ActionEvent;
  27.  
  28. public class problema1 implements ChangeListener{
  29.  
  30.     private JFrame frame;
  31.     private final JRadioButton button_2 = new JRadioButton("opcion 2");
  32.    
  33.  JRadioButton button4; JRadioButton button_3;JRadioButton button_1;JRadioButton button_1_espe;JRadioButton button_2_espe;JRadioButton button_3_espe;
  34.  JCheckBox check1; JCheckBox check2;JCheckBox check3;  JCheckBox check_4_espe;JCheckBox check4;
  35.  
  36.  
  37.  
  38.  
  39. private JTextField txtText;
  40. private JCheckBox check_6_espe;
  41. private JTextField textField_espe;
  42.  
  43.  
  44.  
  45.  
  46.    
  47.  
  48.     /**
  49.      * Launch the application.
  50.      */
  51.     public static void main(String[] args) {
  52.         EventQueue.invokeLater(new Runnable() {
  53.             public void run() {
  54.                 try {
  55.                     problema1 window = new problema1();
  56.                     window.frame.setVisible(true);
  57.                 } catch (Exception e) {
  58.                     e.printStackTrace();
  59.                 }
  60.             }
  61.         });
  62.     }
  63.  
  64.     /**
  65.      * Create the application.
  66.      */
  67.     public problema1() {
  68.         initialize();
  69.         ButtonGroup Grupos=new ButtonGroup();
  70.         ButtonGroup Grupos2=new ButtonGroup();
  71.         Grupos.add(button_1);
  72.         Grupos.add(button_2);
  73.         Grupos.add(button_3);
  74.     //
  75.         Grupos2.add(button_1_espe);
  76.         Grupos2.add(button_2_espe);
  77.         Grupos2.add(button_3_espe);
  78.    
  79.        
  80.     }
  81.  
  82.     /**
  83.      * Initialize the contents of the frame.
  84.      */
  85.     private void initialize() {
  86.         frame = new JFrame();
  87.         frame.setBounds(100, 100, 462, 391);
  88.         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  89.        
  90.  
  91.        
  92.         Panel Original = new Panel();
  93.        
  94.         button_3 = new JRadioButton("opcion 3");
  95.         button_3.addActionListener(new ActionListener() {
  96.             public void actionPerformed(ActionEvent e) {
  97.                 button_3_espe.setSelected(button_3.isSelected());
  98.             }
  99.         });
  100.         //button_3.addChangeListener(this);
  101.         button_2.addActionListener(new ActionListener() {
  102.             public void actionPerformed(ActionEvent e) {
  103.                 button_2_espe.setSelected(button_2.isSelected());
  104.             }
  105.         });
  106.         button_2.setVerticalAlignment(SwingConstants.TOP);
  107.     //  button_2.addChangeListener(this);
  108.        
  109.         button_1 = new JRadioButton("opcion1");
  110.         button_1.addActionListener(new ActionListener() {
  111.             public void actionPerformed(ActionEvent e) {
  112.                 button_1_espe.setSelected(button_1.isSelected());
  113.             }
  114.         });
  115.        
  116. //button_1.addChangeListener(this);
  117.        
  118.         JCheckBox check1 = new JCheckBox("opcion 4");
  119.         check1.addActionListener(new ActionListener() {
  120.             public void actionPerformed(ActionEvent e) {
  121.                 check_4_espe.setSelected(check4.isSelected());
  122.                
  123.             }
  124.         });
  125.        
  126.         JCheckBox check2 = new JCheckBox("opcion 5");
  127.        
  128.         JCheckBox check3 = new JCheckBox("opcion 6");
  129.        
  130.         txtText = new JTextField();
  131.         txtText.setColumns(10);
  132.        
  133.         JSpinner spinner = new JSpinner();
  134.        
  135.         JComboBox comboBox = new JComboBox();
  136.         GroupLayout gl_Original = new GroupLayout(Original);
  137.         gl_Original.setHorizontalGroup(
  138.             gl_Original.createParallelGroup(Alignment.LEADING)
  139.                 .addGroup(gl_Original.createSequentialGroup()
  140.                     .addContainerGap()
  141.                     .addGroup(gl_Original.createParallelGroup(Alignment.LEADING)
  142.                         .addGroup(gl_Original.createParallelGroup(Alignment.LEADING, false)
  143.                             .addGroup(gl_Original.createSequentialGroup()
  144.                                 .addComponent(button_2)
  145.                                 .addGap(18)
  146.                                 .addComponent(check2)
  147.                                 .addGap(18)
  148.                                 .addComponent(comboBox, 0, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
  149.                             .addGroup(gl_Original.createSequentialGroup()
  150.                                 .addComponent(button_3)
  151.                                 .addGap(18)
  152.                                 .addComponent(check3)
  153.                                 .addGap(18)
  154.                                 .addComponent(spinner, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)))
  155.                         .addGroup(gl_Original.createSequentialGroup()
  156.                             .addComponent(button_1)
  157.                             .addGap(18)
  158.                             .addComponent(check1)
  159.                             .addGap(18)
  160.                             .addComponent(txtText, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)))
  161.                     .addContainerGap(190, Short.MAX_VALUE))
  162.         );
  163.         gl_Original.setVerticalGroup(
  164.             gl_Original.createParallelGroup(Alignment.LEADING)
  165.                 .addGroup(gl_Original.createSequentialGroup()
  166.                     .addContainerGap()
  167.                     .addGroup(gl_Original.createParallelGroup(Alignment.BASELINE)
  168.                         .addComponent(button_1)
  169.                         .addComponent(check1)
  170.                         .addComponent(txtText, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
  171.                     .addGap(18)
  172.                     .addGroup(gl_Original.createParallelGroup(Alignment.BASELINE)
  173.                         .addComponent(button_2)
  174.                         .addComponent(check2)
  175.                         .addComponent(comboBox, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
  176.                     .addGap(18)
  177.                     .addGroup(gl_Original.createParallelGroup(Alignment.BASELINE)
  178.                         .addComponent(button_3)
  179.                         .addComponent(check3)
  180.                         .addComponent(spinner, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
  181.                     .addContainerGap(46, Short.MAX_VALUE))
  182.         );
  183.         Original.setLayout(gl_Original);
  184.        
  185.         JPanel espejo = new JPanel();
  186.         GroupLayout groupLayout = new GroupLayout(frame.getContentPane());
  187.         groupLayout.setHorizontalGroup(
  188.             groupLayout.createParallelGroup(Alignment.LEADING)
  189.                 .addComponent(Original, GroupLayout.DEFAULT_SIZE, 446, Short.MAX_VALUE)
  190.                 .addComponent(espejo, GroupLayout.DEFAULT_SIZE, 446, Short.MAX_VALUE)
  191.         );
  192.         groupLayout.setVerticalGroup(
  193.             groupLayout.createParallelGroup(Alignment.LEADING)
  194.                 .addGroup(groupLayout.createSequentialGroup()
  195.                     .addComponent(Original, GroupLayout.PREFERRED_SIZE, 161, GroupLayout.PREFERRED_SIZE)
  196.                     .addPreferredGap(ComponentPlacement.RELATED)
  197.                     .addComponent(espejo, GroupLayout.DEFAULT_SIZE, 181, Short.MAX_VALUE))
  198.         );
  199.        
  200.          button_1_espe = new JRadioButton("opcion 1");
  201.         button_1_espe.setEnabled(false);
  202.        
  203.         JRadioButton button_2_espe = new JRadioButton("opcion 2");
  204.         button_2_espe.setEnabled(false);
  205.         button_2_espe.setVerticalAlignment(SwingConstants.TOP);
  206.        
  207.         JRadioButton button3_espe = new JRadioButton("opcion 3");
  208.         button3_espe.setEnabled(false);
  209.        
  210.         JCheckBox check_4_espe = new JCheckBox("opcion 4");
  211.         check_4_espe.setEnabled(false);
  212.        
  213.         JCheckBox check_5_espe = new JCheckBox("opcion 5");
  214.         check_5_espe.setEnabled(false);
  215.        
  216.         check_6_espe = new JCheckBox("opcion 6");
  217.         check_6_espe.setEnabled(false);
  218.        
  219.         textField_espe = new JTextField();
  220.         textField_espe.setEnabled(false);
  221.         textField_espe.setColumns(10);
  222.        
  223.         JComboBox comboBox_espe = new JComboBox();
  224.         comboBox_espe.setEnabled(false);
  225.        
  226.         JSpinner spinner_espe = new JSpinner();
  227.         spinner_espe.setEnabled(false);
  228.         GroupLayout gl_espejo = new GroupLayout(espejo);
  229.         gl_espejo.setHorizontalGroup(
  230.             gl_espejo.createParallelGroup(Alignment.LEADING)
  231.                 .addGroup(gl_espejo.createSequentialGroup()
  232.                     .addContainerGap()
  233.                     .addGroup(gl_espejo.createParallelGroup(Alignment.LEADING)
  234.                         .addGroup(gl_espejo.createSequentialGroup()
  235.                             .addGroup(gl_espejo.createParallelGroup(Alignment.LEADING)
  236.                                 .addComponent(button_2_espe, GroupLayout.PREFERRED_SIZE, 65, GroupLayout.PREFERRED_SIZE)
  237.                                 .addComponent(button_1_espe))
  238.                             .addGap(18)
  239.                             .addGroup(gl_espejo.createParallelGroup(Alignment.LEADING)
  240.                                 .addGroup(gl_espejo.createSequentialGroup()
  241.                                     .addComponent(check_5_espe)
  242.                                     .addGap(18)
  243.                                     .addComponent(comboBox_espe, GroupLayout.PREFERRED_SIZE, 39, GroupLayout.PREFERRED_SIZE))
  244.                                 .addGroup(gl_espejo.createSequentialGroup()
  245.                                     .addComponent(check_4_espe)
  246.                                     .addGap(18)
  247.                                     .addComponent(textField_espe, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)))
  248.                             .addContainerGap(188, Short.MAX_VALUE))
  249.                         .addGroup(gl_espejo.createSequentialGroup()
  250.                             .addComponent(button3_espe)
  251.                             .addGap(18)
  252.                             .addComponent(check_6_espe)
  253.                             .addGap(18)
  254.                             .addComponent(spinner_espe, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
  255.                             .addContainerGap(244, Short.MAX_VALUE))))
  256.         );
  257.         gl_espejo.setVerticalGroup(
  258.             gl_espejo.createParallelGroup(Alignment.LEADING)
  259.                 .addGroup(gl_espejo.createSequentialGroup()
  260.                     .addGap(35)
  261.                     .addGroup(gl_espejo.createParallelGroup(Alignment.BASELINE)
  262.                         .addComponent(check_4_espe)
  263.                         .addComponent(button_1_espe)
  264.                         .addComponent(textField_espe, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
  265.                     .addGap(10)
  266.                     .addGroup(gl_espejo.createParallelGroup(Alignment.BASELINE)
  267.                         .addComponent(check_5_espe)
  268.                         .addComponent(button_2_espe)
  269.                         .addComponent(comboBox_espe, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
  270.                     .addGap(18)
  271.                     .addGroup(gl_espejo.createParallelGroup(Alignment.BASELINE)
  272.                         .addComponent(button3_espe)
  273.                         .addComponent(check_6_espe)
  274.                         .addComponent(spinner_espe, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
  275.                     .addGap(36))
  276.         );
  277.         espejo.setLayout(gl_espejo);
  278.         frame.getContentPane().setLayout(groupLayout);
  279.            
  280.  
  281.        
  282.        
  283.        
  284.    
  285.  
  286.        
  287.     }
  288.     @Override
  289.     public void stateChanged(ChangeEvent e) {
  290.         // TODO Auto-generated method stub
  291.    
  292.        
  293.     }
  294. }
Advertisement
Add Comment
Please, Sign In to add comment