How to create an object from processing class in eclipse ?

Hello, I want to use swing with processing in eclipse. But when i generate object from my processing class i don't know what am i supposed to send to constructor method ? Image1 is my processing class and i want to generate an object by using it.

import java.awt.EventQueue; import javax.swing.JFrame; import javax.swing.JButton; import javax.swing.JComboBox; import java.awt.event.ActionListener; import java.awt.event.ActionEvent;

public class main {

private JFrame frame;
private JComboBox comboBox ;

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

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

/**
 * Initialize the contents of the frame.
 */
private void initialize() {
    frame = new JFrame();
    frame.setBounds(100, 100, 450, 300);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.getContentPane().setLayout(null);

    JButton btnNewButton = new JButton("New button");
    btnNewButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            String selected = comboBox.getSelectedItem().toString();

            if(selected=="Image1")
            {
                Image1 o1 = new Image1();
                o1.imageDraw();
            }
        }
    });
    btnNewButton.setBounds(29, 30, 89, 23);
    frame.getContentPane().add(btnNewButton);

    comboBox = new JComboBox();
    comboBox.setBounds(29, 104, 142, 23);
    comboBox.addItem("Image1");
    frame.getContentPane().add(comboBox);
}

}

Answers

Sign In or Register to comment.