Empty Swing panel when running the logic handler of my java application with IntelliJ

I’m starting to learn Java with the layers model (GUI, business logic, and persistance) and can’t accomplish the implementation of the GUI properly. I’ve the logic and the GUI designed with swing, which works and displays all components properly when using the preview option on the form designer, but the problem cames when i try to handle the gui with the logic handler, which is how it should work naturally, but it opens an empty panel without any components, and almost invisible so i can’t even drag it and had to assign it a fixed size. I’m starting to doubt if maybe is a compatibility problem Linux Mint, but i don’t think so.
It’s Funny because it’s a mini project i was trying to replicate, and thought that it would be easy, but maybe i’m stuck because instead of using NetBeans I selected IntelliJ.

logic handler:

package logic;

import igu.jFrame;

public class logic {
    public static void main (String[] args) {
       jFrame ventana = new jFrame();
       ventana.setVisible(true);
       ventana.setSize(600, 600);
       ventana.setLocationRelativeTo(null);
    }
}

GUI Code:

public class jFrame extends javax.swing.JFrame {
    public JTextField input; // the user inputs a message that wants to copy 
    public JPanel jframe; // main and unique panel
    public JButton copyBtn; // the button that triggers the copy action
    public JLabel output; // where the input text should be copied
    public JButton clearBtn; // the button that should clear the input and output components


    public jFrame() {
        copyBtn.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                String mensaje = input.getText();
                output.setText(mensaje);
            }
        });
        clearBtn.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                input.setText("");
                output.setText("");
            }
        });
    }
}

New contributor

user28614451 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

2

The problem in your code is you have declared components but have not initialized and added to the jframe correctly. To do that in jFrame constructor i have initialized each component and added them to a panel and added the panel to jFrame. lso , to ensure that when you close the application program ends correctly i have added defaultcloseoperation .

import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class jFrame extends javax.swing.JFrame {
   public JTextField input;  
   public JPanel jframe; 
   public JButton copyBtn; 
   public JLabel output; 
   public JButton clearBtn; 

   public jFrame() {

       // Initialize the declared components
       input = new JTextField(20);  
       copyBtn = new JButton("Copy"); 
       clearBtn = new JButton("Clear"); 
       output = new JLabel("Your output area"); 
       jframe = new JPanel(); 

       // Add the initialized components to the panel
       jframe.add(input);
       jframe.add(copyBtn);
       jframe.add(clearBtn);
       jframe.add(output);

       // Add the panel to the JFrame
       this.add(jframe);

       // Set frame properties for closing operation
       this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 

       copyBtn.addActionListener(new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
              String mensaje = input.getText();
              output.setText(mensaje);
           }
        });

       clearBtn.addActionListener(new ActionListener() {
           @Override
           public void actionPerformed(ActionEvent e) {
               input.setText("");
                output.setText("");
           }
       });
   }
  }

New contributor

Arf_code is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Your code have some missing…

package logic;
import igu.jFrame;

public class logic {

    public static void main( String[] args ) {

          // create the "Gui" on the events thread 
        SwingUtilities.invokeLater( () -> {
         
           jFrame ventana = new jFrame();
           ventana.setLocationRelativeTo( null );
           ventana.setSize( 600, 600 );

             // Last one made by the constructor or after him
           ventana.setVisible( true );
        });.
    }
}

  // change name since "JFrame" is the name of a Swing class, so it can generate errors
public class MyClass extends javax.swing.JFrame {

    public JTextField input; 

      // change name of **JPanel jframe** to **panel** to avoid confusion
    public JPanel panel;  
    public JLabel output;  
    public JButton copyBtn; 
    public JButton clearBtn;  
  
    public MyClass() {
          // we call Super, and pass it the name of the application, so that it is visible in the bar
        super( "MyClass" );

          // create the elements
        input = new JTextField(); 
        panel = new JPanel;
          // etc... 

          // set components
        input.setText( "Hello!" );
        panel.setBackground( new Color( 110, 110, 110 ));

          // add to "panel" the inner elements
        panel.add( input );
        panel.add( input );
          // etc...

          // add to "frame" the "panel"
        add( input );
        
        copyBtn.addActionListener( new ActionListener() {
            @Override
            public void actionPerformed( ActionEvent e ) {
                String mensaje = input.getText();
                output.setText( mensaje );
            }
        } );
        clearBtn.addActionListener( new ActionListener() {
            @Override
            public void actionPerformed( ActionEvent e ) {
                input.setText( "" );
                output.setText( "" );
            }
        } );
    }
}

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật