Advertisement
Gabri_RDiaz

DialogoLayouts

Mar 14th, 2020
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.43 KB | None | 0 0
  1. public class Dialogo extends JDialog {
  2.         public int filas;
  3.         public int columnas;
  4.        
  5.     public Dialogo(Frame parent) {
  6.         super(parent, "Nivel de dificultad");
  7.         setVisible(true);
  8.         setSize(400,400);
  9.         setLocationRelativeTo(null);
  10.         componentes();
  11.         revalidate();
  12.     }
  13.  
  14.     private JFrame componentes() {
  15.         JFrame compos = new JFrame();
  16.         compos.setLayout(new BorderLayout());
  17.         compos.add(radioButtons(), BorderLayout.PAGE_START);
  18.         compos.add(textAreas(), BorderLayout.CENTER);
  19.         return compos;
  20.     }
  21.  
  22.     private JPanel radioButtons() {
  23.         JPanel rButtons = new JPanel();
  24.         setLayout(new FlowLayout());
  25.         JRadioButton easyMode = new JRadioButton("Fácil");
  26.         add(easyMode);
  27.         JRadioButton mediumMode = new JRadioButton("Medio");
  28.         add(mediumMode);
  29.         JRadioButton hardMode = new JRadioButton("Difícil");
  30.         add(hardMode);
  31.         JRadioButton customMode = new JRadioButton("Personalizado");
  32.         add(customMode);
  33.         ButtonGroup bgModes = new ButtonGroup();
  34.         bgModes.add(easyMode);
  35.         bgModes.add(mediumMode);
  36.         bgModes.add(hardMode);
  37.         bgModes.add(customMode);
  38.         return rButtons;
  39.     }
  40.  
  41.     private JPanel textAreas() {
  42.         JPanel textAreas = new JPanel();
  43.         // Aquí iría otro Layout distinto textAreas.setLayout(new FlowLayout());
  44.         JTextField txtFilas = new JTextField();
  45.         txtFilas.setBounds(10, 110, 200, 40);
  46.         add(txtFilas);
  47.         JLabel lbFilas = new JLabel("Filas");
  48.         lbFilas.setBounds(10, 110, 200, 40);
  49.         add(lbFilas);
  50.         return textAreas;
  51.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement