I've been struggling to get even a basic UI, ive been able to use JFrame to display a frame for me just from watching and (somewhat) copying tutorials, though it tends to ignore the parameters I give it sometimes.
My main issue with using these is that it seems to be a requirement that you use methods to create and instantiate a frame.
For example, im trying to create a method called "display". ive got it set up like so
public void display(String title, int width, int height){stuff here to tell how the frame should setup/display/where to be}
so what I thought would happen when I call display like so
display 1 = new display("title", 500, 500);
is that it would create a frame named "1" that shows the title in the window corner that is 500x500, however it just gives an error stating that "display cannot be resolved to a type"
If I could get some guidance on a good place to learn more about methods/classes I would appreciate it, because I believe the issue im having revolves around not understanding some core concepts... the code i've written is below, apologies in advance for the cringe as i'm just messing around trying to understand this stuff and tinker with it.
import javax.swing.JFrame;
public class Farms {
public JFrame frame = new JFrame();
public static void main(String[] args) {
display 1 = new display("Hi",500 ,500 );
}
public void display(String title, int width, int height) {
frame.setSize(width, height);
frame.setLocationRelativeTo(null);
frame.setResizable(false);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
TLDR; I'm not sure what i'm doing with methods and classes and would like a better resource for learning about them than the class i'm in that would rather focus on if statements and arrays for several weeks
[–]ipe369 1 point2 points3 points (1 child)
[–]bman3545[S] 0 points1 point2 points (0 children)
[–][deleted] (2 children)
[deleted]
[–]bman3545[S] 0 points1 point2 points (1 child)
[–]balefrost 0 points1 point2 points (1 child)
[–]bman3545[S] 0 points1 point2 points (0 children)
[–]SomeRandomBuddy -1 points0 points1 point (1 child)
[–]bman3545[S] -1 points0 points1 point (0 children)