0

I have multiple classes in the project and this class does not want to initialise the JFrame and i am not quite sure why. Every other class is initialising the UI perfectly fine, the class is called from the main window class with uradiUslugu.main(null);

Help would be appriciated, thank you!

EDIT: I am not getting any console errors while trying to run it. It just terminates itself.

EDIT: Description Resource Path Location Type Unbound classpath container: 'JRE System Library [JavaSE-1.8]' in project 'tarikprojekat' tarikprojekat Build path Build Path Problem

Just found this!

FIXED IT! Unbound classpath container in Eclipse

Thank you everyone!

enter image description here

@SuppressWarnings("deprecation")
public static void main(String[] args)
{
    JFrame prozor = new JFrame ("");
    Container sadrzaj = prozor.getContentPane();
    sadrzaj.setLayout(new FlowLayout());
    JLabel lOdabir = new JLabel ("Izaberite uslugu");
    JLabel bNastavi = new JLabel ("Nastavi");
    final JComboBox<String> odabirBox = new JComboBox<String>();
    odabirBox.addItem("");
    odabirBox.addItem("Mali servis");
    odabirBox.addItem("Veliki servis");
    odabirBox.addItem("Zamjena motora");
    odabirBox.addItem("Zamjena guma");
    odabirBox.addItem("Reparacija turbine");
    odabirBox.addItem("Servis kocnica");
    odabirBox.addItem("Servis mjenjaca");
    odabirBox.addItem("Reparacija intercoolera");
    odabirBox.addItem("Remont volana");
    odabirBox.addItem("Ugradnja fiksnog zamajca");
    odabirBox.addItem("Zamjena katalizatora");

    sadrzaj.add(lOdabir);
    sadrzaj.add(odabirBox);
    sadrzaj.add(bNastavi);

    prozor.show();
    prozor.setSize(150, 300);
    prozor.setVisible(true);
    prozor.setResizable(false);
    mainWindow.centrirajProzor(prozor);
Community
  • 1
  • 1
  • 2
    what exactly is this `mainWindow` you're invoking a method of? And what does its method do? – Niklas Jan 15 '16 at 19:50
  • In your main method, you want to place everything in a `SwingUtilities.invokeLater` call. Like `public static void main(String[] args) {SwingUtilities.invokeLater(new Runnable(){public void run(){ /*place everything that is currently in your main method here*/ }});}` – TT. Jan 15 '16 at 19:56
  • the class won't initialize it even when i run it separetly https://i.gyazo.com/8dd4f677eb32ec5bd48669810b0f9a81.gif P.S i am not clicking the terminate button – Meho HoMe Hatić Jan 15 '16 at 20:02
  • What you mean by `does not want to initialise the JFrame`. And with `It just terminates itself.`? – Frakcool Jan 15 '16 at 20:03
  • The java application frame (https://docs.oracle.com/javase/tutorial/figures/uiswing/components/FrameDemoMetal.png) that should come with running the class does not appear and after a couple of seconds after running the class it will just stop working (terminate). – Meho HoMe Hatić Jan 15 '16 at 20:09
  • My best guess: you have classpath issues in your project, so eclipse doesn't compile and is running old version of class. Check problems view for your project – Jan Jan 15 '16 at 20:14
  • 1
    [`Window#show()`](https://docs.oracle.com/javase/7/docs/api/java/awt/Window.html#show%28%29) is deprecated, remove it – Frakcool Jan 15 '16 at 20:15
  • 1
    @MehoHoMeHatić Remove `prozor.show()` (it is deprecated and unnecessary since you're calling `setVisible()`). Also remove `mainWindow.centrirajProzor(prozor);` since you don't post that code and no one knows what it does. After that, does the problem still persist? – martinez314 Jan 15 '16 at 20:15
  • Okay i'll remove it. The centrirajProzor() function is for setting the JFrame position. I just realised that i have this small icon next to my project icon https://i.gyazo.com/e6bd2f50a0ea0c8e14e5d2dc79b16c85.png Could it be the cause of the problem? – Meho HoMe Hatić Jan 15 '16 at 20:21
  • Description Resource Path Location Type Unbound classpath container: 'JRE System Library [JavaSE-1.8]' in project 'tarikprojekat' tarikprojekat Build path Build Path Problem Just found this, how to fix this problem? – Meho HoMe Hatić Jan 15 '16 at 20:23
  • Fixed it! http://stackoverflow.com/questions/2083461/unbound-classpath-container-in-eclipse Thank you everyone! – Meho HoMe Hatić Jan 15 '16 at 20:33

1 Answers1

0

The problem was as @Jan said with the classpath as i managed to somehow mess it up. I did not see the problem on the list as i have a big pile of unfinished projects with stacked up errors. I managed to clear the error with a previously question answer on Unbound classpath container in Eclipse !

Community
  • 1
  • 1