import java.awt.EventQueue;import javax.swing.JFrame;import javax.swing.JPanel;import javax.swing.JButton;import javax.swing.JTextField;import java.awt.event.ActionListener;import java.awt.event.ActionEvent;import java.io.*;import java.awt.Color;import java.awt.Font;import javax.swing.JTextPane;public class Sladky_okno { private JFrame frame; private JTextField zapis; private JTextField vypis; private JButton tlacitko_zobraz; private JTextPane zobraz; private JButton tlacitko_okno; /** * Launch the application. */ public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void run() { try { Sladky_okno window = new Sladky_okno(); window.frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); } } }); } /** * Create the application. */ public Sladky_okno() { initialize(); } /** * Initialize the contents of the frame. */ private void initialize() { frame = new JFrame(); frame.getContentPane().setBackground(Color.LIGHT_GRAY); frame.setBounds(100, 100, 674, 463); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().setLayout(null); JButton btnNewButton = new JButton("Odeslat"); btnNewButton.setBackground(Color.BLACK); btnNewButton.setForeground(Color.WHITE); btnNewButton.setFont(new… Font("Tahoma", Font.ITALIC, 15)); btnNewButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String a = zapis.getText(); vypis.setText(a); } }); btnNewButton.setBounds(12, 35, 125, 39); frame.getContentPane().add(btnNewButton); zapis = new JTextField(); zapis.setForeground(Color.WHITE); zapis.setBackground(Color.DARK_GRAY); zapis.setBounds(195, 35, 182, 39); frame.getContentPane().add(zapis); zapis.setColumns(10); vypis = new JTextField(); vypis.setForeground(Color.WHITE); vypis.setBackground(Color.DARK_GRAY); vypis.setBounds(421, 31, 192, 43); frame.getContentPane().add(vypis); vypis.setColumns(10); tlacitko_zobraz = new JButton("Odeslat"); tlacitko_zobraz.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { BufferedReader soubor = new BufferedReader (new FileReader ("a.txt")); String vypis; String line=""; while ((vypis = soubor.readLine()) != null) line = new String(line + vypis + "\n"); zobraz.setText(line); soubor.close(); } catch (IOException vypis){ System.out.println ("Chyba na vstupu souboru a.txt"); } } }); tlacitko_zobraz.setForeground(Color.WHITE); tlacitko_zobraz.setFont(new Font("Tahoma", Font.ITALIC, 15)); tlacitko_zobraz.setBackground(Color.BLACK); tlacitko_zobraz.setBounds(12, 125, 125, 39); frame.getContentPane().add(tlacitko_zobraz); zobraz = new JTextPane(); zobraz.setForeground(Color.WHITE); zobraz.setBackground(Color.DARK_GRAY); zobraz.setBounds(195, 125, 418, 108); frame.getContentPane().add(zobraz); tlacitko_okno = new JButton("OKNO"); tlacitko_okno.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JFrame okno = new JFrame(); okno.setVisible(true); okno.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); okno.setSize(700, 500); okno.setLocation(100, 100); JPanel panel = new JPanel(); okno.add(panel); panel.setBackground(Color.BLACK); } }); tlacitko_okno.setForeground(Color.WHITE); tlacitko_okno.setFont(new Font("Tahoma", Font.ITALIC, 15)); tlacitko_okno.setBackground(Color.BLACK); tlacitko_okno.setBounds(12, 278, 125, 39); frame.getContentPane().add(tlacitko_okno); }} Ukázat celý příspěvek