Run GUI app in intellij idea

I'm new with intellij idea and jFormDesigner. I want to test my application. I added jFormDesigner file to my project, created form and added simple button and textarea. I added mouse click event for button, but I don't know how to test it.

Here is event handler:

private void startButtonMouseClicked(MouseEvent e) {

Here is generated by intellij idea code:

public class SysJournalForm extends JFrame {
    public SysJournalForm() {

    public static void main(String [] args)

    private void startButtonMouseClicked(MouseEvent e) {

    private void initComponents() {
        // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
        // Generated using JFormDesigner Evaluation license - Vadim Mirgorod
        scrollPane1 = new JScrollPane();
        resultTextField = new JTextPane();
        startButton = new JButton();
        stopButton = new JButton();

        //======== this ========
        Container contentPane = getContentPane();

        //======== scrollPane1 ========

            //---- resultTextField ----
        scrollPane1.setBounds(5, 5, 530, 295);

        //---- startButton ----
        startButton.addMouseListener(new MouseAdapter() {
            public void mouseClicked(MouseEvent e) {
        startButton.setBounds(5, 305, 130, startButton.getPreferredSize().height);

        //---- stopButton ----
        stopButton.setBounds(140, 305, 130, stopButton.getPreferredSize().height);

        { // compute preferred size
            Dimension preferredSize = new Dimension();
            for(int i = 0; i < contentPane.getComponentCount(); i++) {
                Rectangle bounds = contentPane.getComponent(i).getBounds();
                preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
                preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
            Insets insets = contentPane.getInsets();
            preferredSize.width += insets.right;
            preferredSize.height += insets.bottom;
        // JFormDesigner - End of component initialization  //GEN-END:initComponents

    // JFormDesigner - Variables declaration - DO NOT MODIFY  //GEN-BEGIN:variables
    // Generated using JFormDesigner Evaluation license - Vadim Mirgorod
    private JScrollPane scrollPane1;
    private JTextPane resultTextField;
    private JButton startButton;
    private JButton stopButton;
    // JFormDesigner - End of variables declaration  //GEN-END:variables

When I click test form in jFormDesigner form works but events no. How to test events?


for JButton is there better to use

1) Swing Action very scalable workaround for whole Swing JComponents

2) (most common) ActionListener


3) I think that MouseListener is wrong Swing Listener for JButton

Why don't you test it with mocks? There are a lot of mocking frameworks out there. You could use Mockito, JMock, JMockit and so on... Mockito would be a good start. If you want to actually simulate the GUI actions... That's a whole other area. I suggest you mock it first, test it that way.

Also, the form is not genereated by Intellij Idea, but JFormDesigner - which you could use to abstract the GUI, not tying it to a specific IDE - which is a great idea.

Also, if you are going to use a lot of Swing components, I suggest you go with the MVC pattern - - it should simplify testing, maintenence and generaly simplify your form.

Have you ever marked de checkbox "Custom Create"? When you add custom code for the component, in this case the JButton, you have to mark this option in its Properties Inspector.

Need Your Help

how to get the file names stored in sd card in android

java android file sd-card

i have a folder in sd card which contains several files. now i need to get the names of that files. can anybody have any idea how to get the file names stored in sd card? any help will be

Storing a image in mongodb

node.js mongodb stream buffer

I'm trying to store images in mongo after downloading it with request

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.