Supposedly creating a new GUI form should be a simple matter of right-clicking your project, package or src folder and go New > GUI Form. The problem is I don't have that option. I've created a Java project and it compiles and runs fine.
But the only options I get under New are Java Class, File, Package, HTML File, and JavaScript File.
Really old question, but if I got here someone else may as well...
So, step by step:
Make sure that the "UI designer" is enabled:
File -> Settings -> Plugins -> UI Designer (checked)
The parent (root) folder must be market as "source root"
Right click on the folder -> Mark Directory as -> Source root
Create a package from the "src" folder:
Right click on the "src" folder -> New -> Package
Create the new form:
Right click on the package -> new GUI Form
PS. I'm not sure, but I reckon it's possible to skip the package step...
Double check that you have UI Designer enabled in Settings | Plugins.
You need the create a package, and after you can create GUI forms.
You need to create a package, and have open a class file within the package, and THEN you can create GUI forms. The options in the File -> New menu change depending on what kind of file you are currently editing.
I know this is an old thread, but it still deserves a straight answer. I had to right click the package itself inside the project directories. You cannot use the "file > new" option. So once you create your package, right click the directory you want the files created in, go to new > GUI Form
In the latest version it's like this:
I had this problem and the only change I needed to do was to use one word in the input fields for the New GUI Form dialog. When I tried clicking the OK button no error message or warnings were displayed, just nothing happened. Probably a pretty obvious thing, but worth sharing in case anyone else runs into it.
Related
Related: IntelliJ does not show 'Class' when we right click and select 'New'
In the above accepted answer, it says the "New" does not give the option for Java Class because it was not the source root (blue directory).
However, as you can see, even though where I am right-clicking is source root, indicated by blue box, it is not giving me the option for Java Class
Any idea why?
This directory is imported from git so it did not follow the usual "Create Project" for java directly from Intellij
You are right clicking in the wrong spot -- youre "too high" up the tree. Go to where you code is (as in the package under "src") and try it there and you will see the option for a New Class.
EDIT: You don't need to be in the source root. You need to be in the source directories themselves. The blue dot I believe is a git status indicator. What you want is an entirely blue folder.
Go down under "src". Likely under "src" then "main" then "java", and you're there (that's blue for me) and then you will see your package folders. Below those are where you likely want to be adding classes.
As many mentioned above you can right click on the folder you would like it in. In your case:
If you push Alt+1, it might be easier for you to right click
src > New Java Class
Alternatively you can push:
Alt+1 (Project View)
Alt+Ins
or
Ctrl+Alt+Ins
1) Right click on src
2) Click New > package
3) Name your package and press OK
4) Right click the newly made package
5) New > Java Class
If the folder where we are trying to create the class is not marked as source or test then the option is not available.
Right click the project and go to project structure then under project settings -> Modules, Select the folder where you wanted to create class and mark as Source or Test appropriately and then click apply and ok.
Now you will see the change of color of the folder/package(Sources->Blue, Test->Green) and you will get the option to create the class.
This worked for me.
I know this is an old thread, but it happened to me because my gradle files were not synchronized. So if you are within a team working on same project and face this issue, make sure to run gradle sync.
You should go inside java project then you can create java class.
From this screen
I cannot figure out how to get a basic template or scratchpad or whatever it's so that I can start writing code in java. Any help would be appreciated.
update
Ok, I did that and got this
Then it brought me back to the same window
It looks like you created an "empty project".
Try to create a new project File -> New -> Project and select Java as the project type.
then, you should see a src folder which is blue. Right click from here to create your first java class.
I have some legacy packages which doesn't have package-info.java. For some reason I need to create package-info.javas for them and I found the task really boring because there is no shortcut in eclipse for me to do that. I have to manually use the New > File procedure to create the file, then manually type in those package names.
Is there a shortcut in eclipse for such task?
It's counter-intuitive, but Eclipse's "New Java Package" dialog with its option to create a package-info.java works for existing packages, too.
Just right-click the existing package, select New > Package, and leave everything except the "Create package-info.java" checkbox unchanged.
This will produce a package-info.java that's pre-populated with the correct package name and an empty javadoc comment block (possibly with #author tags and similar default content depending on your settings). Works even if you don't have an existing file to copy from. Tested with Eclipse Oxygen.
There is no easy way to do this as far as I know, at least "the right way."
What you can do as a shortcut is right-click package-info.java and click "Copy." Then you can use the keyboard shortcut to paste the package-info.java in any package. Eclipse automatically changes the package org.whatever.pkgname; command to match the package you paste the java file into.
Ive made a game with the libgdx framework in eclipse and I want to copy this project in the same workspace so I can make changes to this whilst viewing the original code.
I have tried refactoring before but it all messed up somehow and I ended up having to start a new project and copying over every class ( took a while )
Is there a way to rename the projects in a better way or how do you rename them properly as I obviously did something wrong.
In package explorer
Right click on project
Click Refactor > Rename or press Alt+Shift+R
Give new name
So, we are integrating another project in our code base. It does not follow our formatting rules. I have auto-formatting upon save configured. So, I could go to each file and save it again but is there a way to script Eclipse so that it applies formatting rules to every single file in my workspace?
Right click on the project(s) (can multi-select) and choose Source -> Format in the menu.
Try Source -> Clean up..., Use custom profile -> Configure.... it has more powerful options there.
Make sure you are in Package Explorer, then right-click and select the Source menu. Some of the other views (e.g., Navigator) won't show this option.