How would i be able to run this function from my main() to build the gui, and then use code from elsewhere to handle the button click and retrieve input from the text field?
package main;
import javax.swing.*;
import java.awt.*;
public class Gui {
public static void mainGUI() {
UIManager.put("swing.boldMetal", Boolean.FALSE);
java.net.URL imgApp = ClassLoader.getSystemResource("res/app.png");
JFrame mainWin = new JFrame("jIRC");
mainWin.setSize(1024, 720);
mainWin.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
mainWin.setIconImage(new ImageIcon(imgApp).getImage());
Container panel = mainWin.getContentPane();
panel.setLayout(null);
JTextArea inputBox = new JTextArea();
inputBox.setSize(300, 100);
inputBox.setLocation(500, 250);
JButton sendButton = new JButton();
sendButton.setText("Send");
sendButton.setFont(new Font("Helvetica", Font.ITALIC, 16));
sendButton.setSize(72, 32);
sendButton.setLocation(500, 500);
panel.add(inputBox);
panel.add(sendButton);
mainWin.setVisible(true);
}
}
Here's my class with the main function:
public class Run{
public static void main(String[] args) {
main.Debug.startupDebug();
main.Gui.mainGUI();
}
}
How would I go about placing some of my code in a non-static field?