import java.awt.Color;
import java.awt.EventQueue;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
public class Obraz1 {
	public JFrame frame;
	public JTextField txtPO1;
	private JTextField txtB1;
	private int max1 = 25;
	// pocet bodov
	private int body1;
	// pocet otazok
	public int otazky1;
	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					Obraz1 window = new Obraz1();
					window.frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}
	/**
	 * Create the application.
	 */
	public Obraz1() {
		initialize();
	}
	/**
	 * Initialize the contents of the frame.
	 */
	private void initialize() {
		frame = new JFrame();
		frame.getContentPane().setBackground(new Color(255, 245, 238));
		frame.setBounds(100, 100, 460, 227);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.getContentPane().setLayout(null);
		JLabel lblRentovA = new JLabel("1. \u00DArokovanie: ");
		lblRentovA.setFont(new Font("Tahoma", Font.BOLD, 12));
		lblRentovA.setBounds(25, 50, 160, 43);
		frame.getContentPane().add(lblRentovA);
		JLabel lblPoetOtzok = new JLabel("Po\u010Det ot\u00E1zok");
		lblPoetOtzok.setFont(new Font("Tahoma", Font.BOLD, 11));
		lblPoetOtzok.setBounds(237, 17, 79, 34);
		frame.getContentPane().add(lblPoetOtzok);
		JLabel lblBody = new JLabel("Body");
		lblBody.setFont(new Font("Tahoma", Font.BOLD, 11));
		lblBody.setBounds(378, 17, 46, 34);
		frame.getContentPane().add(lblBody);
		txtPO1 = new JTextField();
		txtPO1.addKeyListener(new KeyAdapter() {
			@Override
			public void keyTyped(KeyEvent e) {
				char c = e.getKeyChar();
				if (!(Character.isDigit(c)) || c == KeyEvent.VK_BACK_SPACE || c == KeyEvent.VK_DELETE)
					e.consume();
			}
		});
		txtPO1.setText("5");
		txtPO1.setBounds(237, 62, 38, 20);
		frame.getContentPane().add(txtPO1);
		txtPO1.setColumns(10);
		JLabel lblmax = new JLabel("(max 25)");
		lblmax.setBounds(285, 65, 72, 14);
		frame.getContentPane().add(lblmax);
		txtB1 = new JTextField();
		txtB1.addKeyListener(new KeyAdapter() {
			@Override
			public void keyTyped(KeyEvent e) {
				char c = e.getKeyChar();
				if (!(Character.isDigit(c)) || c == KeyEvent.VK_BACK_SPACE || c == KeyEvent.VK_DELETE)
					e.consume();
			}
		});
		txtB1.setText("1");
		txtB1.setColumns(10);
		txtB1.setBounds(378, 62, 38, 20);
		frame.getContentPane().add(txtB1);
		JCheckBox checkBox1 = new JCheckBox("");
		checkBox1.setBackground(new Color(255, 245, 238));
		checkBox1.setSelected(true);
		checkBox1.setBounds(176, 50, 26, 43);
		frame.getContentPane().add(checkBox1);
		JButton btnVytvoriTest = new JButton("Vytvori\u0165 test");
		btnVytvoriTest.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				if (!checkBox1.isSelected()) {
					JOptionPane.showMessageDialog(null, "Prosím, vyberte aspoň jednu oblasť!");
				} else {
					if (checkBox1.isSelected()) {
						String b1 = txtB1.getText();
						String po1 = txtPO1.getText();
						if (b1.isEmpty() || po1.isEmpty()) {
							JOptionPane.showMessageDialog(null,
									"Prosím, zadajte počet otázok a počet bodov pre 1. oblasť!");
						} else {
							// s tymito hodnotami potrebujem pracovat v JFrame Obraz2
							body1 = Integer.parseInt(b1);
							otazky1 = Integer.parseInt(po1);
							if ((checkBox1.isSelected() && otazky1 > max1)) {
								JOptionPane.showMessageDialog(null, "Počet otázok presiahol maximum!");
							} else {
								// prechod na dalsiu stranu
								Obraz2 o = new Obraz2();
								o.setVisible(true);
								frame.dispose();
								
							}
						}
					}
				}
			}
		});
		btnVytvoriTest.setBounds(268, 143, 117, 28);
		frame.getContentPane().add(btnVytvoriTest);
	}
}
import java.awt.Color;
import java.awt.EventQueue;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JScrollPane;
import javax.swing.SwingConstants;
import javax.swing.border.EmptyBorder;
public class Obraz2 extends JFrame {
	private JPanel contentPane;
	private GridBagLayout grid1;
	private GridBagConstraints constra1;
	private Nacitajotazky1 nacitaj;
	private Obraz1 ho;
	private int pocet;
	public int[] potazkyPole1111;
	private int body = 0;
	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					Obraz2 frame = new Obraz2();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}
	/**
	 * Create the frame.
	 */
	public Obraz2() {
		ho=new Obraz1();
		String a=ho.txtPO1.getText();
		pocet=ho.otazky1;
		//pocet = 17;
		getContentPane().setLayout(null);
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 900, 430);
		contentPane = new JPanel();
		contentPane.setBackground(new Color(255, 245, 238));
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		JPanel panel = new JPanel();
		panel.setBackground(Color.BLUE);
		grid1 = new GridBagLayout();
		constra1 = new GridBagConstraints();
		panel.setLayout(grid1);
		contentPane.setLayout(null);
		JScrollPane scrollPane = new JScrollPane();
		scrollPane.setBounds(10, 11, 857, 299);
		contentPane.add(scrollPane);
		scrollPane.setViewportView(panel);
		JLabel lblNewLabel = new JLabel("New label");
		lblNewLabel.setHorizontalAlignment(SwingConstants.LEFT);
		lblNewLabel.setBounds(10, 319, 115, 32);
		contentPane.add(lblNewLabel);
		lblNewLabel.setText("pocet" + pocet);
//naciatnie otazok
		nacitaj = new Nacitajotazky1();
		File subor = new File("1kapitola.txt");
		nacitaj.nacitajaGeneruj(subor, 17);
		JPanel[] podpanel = new JPanel[pocet];
		JLabel[] otazka = new JLabel[pocet];
		JRadioButton[][] jr = new JRadioButton[pocet][4];
		
		JLabel lblPocetBodov = new JLabel("Pocet bodov: " + body);
		lblPocetBodov.setHorizontalAlignment(SwingConstants.LEFT);
		lblPocetBodov.setBounds(189, 321, 197, 32);
		contentPane.add(lblPocetBodov);
	
		JButton btnSp = new JButton("Sp\u00E4\u0165");
		btnSp.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				Obraz1 window = new Obraz1();
				window.frame.setVisible(true);
				dispose();
			}
		});
		btnSp.setBounds(10, 358, 89, 23);
		contentPane.add(btnSp);
		
	}
}