> 
> **Possible Duplicate:**  
> 
> [Java. GUI WindowBuilder read from JTextField by clicking button](https://stackoverflow.com/questions/14345854/java-gui-windowbuilder-read-from-jtextfield-by-clicking-button) 
> 
> 
> 

I want to ask how to print text from JTextField to panel by clicking button? Could you help me, please? 

This is my program's image:

![enter image description here](https://i.stack.imgur.com/RYTgS.png)

**JTextField** - field where I enter my text which I want to print.

**Print Button** - when I click It my text will publish on panel.

**Text text text**... - place where I want to see printed text which I enter to JTextField.

This is my full code:

```
import java.awt.EventQueue;    
import javax.swing.JFrame;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import javax.swing.JTextPane;
import javax.swing.DropMode;
import javax.swing.JFormattedTextField;
import java.awt.Component;
import javax.swing.Box;
import java.awt.Dimension;
import javax.swing.JTextField;
import javax.swing.JTextArea;
import javax.swing.UIManager;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.Toolkit;
import javax.swing.JMenuBar;
import javax.swing.JMenu;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JMenuItem;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.ImageIcon;
import javax.swing.JDesktopPane;
import java.awt.SystemColor;
import java.awt.Font;
import javax.swing.border.BevelBorder;
import javax.swing.border.EtchedBorder;
import javax.swing.JScrollBar;
import java.awt.Color;
import javax.swing.JLabel;
import javax.swing.JToolBar;

public class KDVizualizuotas {

    private JFrame frmInformacijaApieMuzikos;
    private JTextField txtStilius;

    /**
     * Launch the application.
     */
    public static void main(String[] args) {
        EventQueue.invokeLater(new Runnable() {
            public void run() {
                try {
                    KDVizualizuotas window = new KDVizualizuotas();
                    window.frmInformacijaApieMuzikos.setVisible(true);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    }

    /**
     * Create the application.
     */
    public KDVizualizuotas() {
        initialize();
    }

    /**
     * Initialize the contents of the frame.
     */
    private void initialize() {
        frmInformacijaApieMuzikos = new JFrame();
        frmInformacijaApieMuzikos.setResizable(false);
        frmInformacijaApieMuzikos.setIconImage(Toolkit.getDefaultToolkit().getImage(KDVizualizuotas.class.getResource("/lt/kvk/i3_2/kalasnikovas_stanislovas/resources/Sidebar-Music-Blue-icon.png")));
        frmInformacijaApieMuzikos.setTitle("Muzikos stiliai");
        frmInformacijaApieMuzikos.setBounds(100, 100, 262, 368);
        frmInformacijaApieMuzikos.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        txtStilius = new JTextField();
        txtStilius.setBounds(10, 34, 128, 20);
        txtStilius.setColumns(10);

        JButton btnIekoti = new JButton("Ie\u0161koti");
        btnIekoti.setBounds(146, 36, 89, 19);
        btnIekoti.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {

            }
        });

        JPanel panel = new JPanel();
        panel.setBounds(10, 65, 224, 243);
        panel.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
        panel.setBackground(SystemColor.text);

        JLabel lblveskiteMuzikosStili = new JLabel("\u012Eveskite muzikos stili\u0173:");
        lblveskiteMuzikosStili.setBounds(10, 14, 222, 14);
        frmInformacijaApieMuzikos.getContentPane().setLayout(null);
        panel.setLayout(null);

        JScrollBar scrollBar = new JScrollBar();
        scrollBar.setBounds(205, 1, 17, 242);
        panel.add(scrollBar);

        JPanel panelStiliuTekstas = new JPanel();
        panelStiliuTekstas.setBackground(Color.WHITE);
        panelStiliuTekstas.setBounds(1, 22, 202, 221);
        panel.add(panelStiliuTekstas);
        panelStiliuTekstas.setLayout(null);
        frmInformacijaApieMuzikos.getContentPane().add(panel);

        JLabel lblInformacijaApieMuzikos = new JLabel("Informacija apie muzikos stili\u0173:");
        lblInformacijaApieMuzikos.setBounds(12, 3, 190, 14);
        panel.add(lblInformacijaApieMuzikos);
        frmInformacijaApieMuzikos.getContentPane().add(txtStilius);
        frmInformacijaApieMuzikos.getContentPane().add(btnIekoti);
        frmInformacijaApieMuzikos.getContentPane().add(lblveskiteMuzikosStili);

        JMenuBar menuBar = new JMenuBar();
        frmInformacijaApieMuzikos.setJMenuBar(menuBar);

        JMenu mnFile = new JMenu("File");
        menuBar.add(mnFile);

        JMenuItem mntmExit = new JMenuItem("Exit");
        mntmExit.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {
                System.exit(0);             
            }

        });
        mntmExit.setIcon(new ImageIcon(KDVizualizuotas.class.getResource("/lt/kvk/i3_2/kalasnikovas_stanislovas/resources/exitas.png")));
        mnFile.add(mntmExit);

        JMenu mnEdit = new JMenu("Edit");
        menuBar.add(mnEdit);

        JMenu mnHelp = new JMenu("Help");
        menuBar.add(mnHelp);

        JMenuItem mntmHelp = new JMenuItem("Help");
        mnHelp.add(mntmHelp);

        JMenu mnAbout = new JMenu("About");
        menuBar.add(mnAbout);

        JMenuItem mntmAbout = new JMenuItem("About");
        mntmAbout.setIcon(new ImageIcon(KDVizualizuotas.class.getResource("/lt/kvk/i3_2/kalasnikovas_stanislovas/resources/questionmark.png")));
        mnAbout.add(mntmAbout);
    }
}

```

And this is useful block of my code I think.:

```
private void initialize() {
frmInformacijaApieMuzikos = new JFrame();
frmInformacijaApieMuzikos.setResizable(false);
frmInformacijaApieMuzikos.setIconImage(Toolkit.getDefaultToolkit().getImage(KDVizualizuotas.class.getResource("/lt/kvk/i3_2/kalasnikovas_stanislovas/resources/Sidebar-Music-Blue-icon.png")));
frmInformacijaApieMuzikos.setTitle("Muzikos stiliai");
frmInformacijaApieMuzikos.setBounds(100, 100, 262, 368);
frmInformacijaApieMuzikos.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

txtStilius = new JTextField();
txtStilius.setBounds(10, 34, 128, 20);
txtStilius.setColumns(10);

JButton btnIekoti = new JButton("Ie\u0161koti");
btnIekoti.setBounds(146, 36, 89, 19);
btnIekoti.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent arg0) {

    }
});

```