One frustrating thing I find in Intellij's project view is that it shows all the classes in a file instead of just the class for which the file is named.
The problem with this is that to open a file I have to double click twice: once to expand the file and show the classes in the file, and then a second time to actually open the file.
In most cases I don't want to see the classes inside of a file. I just want to see the file in the project view and when I double click on the file I want to open the file, not drill down into its structure.
Is it possible to configure my UI this way?
UPDATE: further explanation
Apparently people are having problems understanding this question. See the above picture of the Intellij Project navigation pane. Notice that some classes (the blue circles) have a + sign and others do not. The ones with a plus sign are files that have multiple classes inside of them.
The problem is that if you double click on a file with only one class (no plus sign) it opens (GOOD), but if you double click on a file with multiple classes in it (has plus sign) then the file does NOT open, it just expands the plus sign to show you the individual classes in the file as BoxArray.java, for example (BAD).
For example, if I double click on the file Coastline.java in the view above it will NOT open the file, it will expand the plus sign. I want it to open Coastline.java when I double click on Coastline.java, not expand it. I do not care about seeing the classes inside of a class file, I just want to open it in one double click.
I know that I can use the hotkey F4 to do this. I do not want to reach for the F4 key. I want to double click on the file and have it open.
When you enable Autoscroll to Source in the little menu of your Project tool window (View > Tool Windows > Project), single clicking a collection (closed and opened) goes straight to the code as well as folding / unfolding it.
This works in IntelliJ 13.1 and 14 (in OSX and Linux)
You could bind Jump to Source function to double click in Settings -> Keymap -> search for "Jump to Source" -> RMB click and choose "Add Mouse Shortcut".
Now double clicking on file will open it. Drawback could be that from now if you double click on some code to select it you will always go to source..
There is a way to open a file without unfolding/drill down via "jump to source" action. Unfortunately, you need a keyboard to do this. On Mac you use F4/⌘↓/⌘Enter, on linux/windows it is F4/Ctrl+Enter.
go to file -> settings -> Editor -> General -> editor tabs
in tab closeing policy and set tab limit and set it to what number you want.
You can avoid navigating through mouse and even double clicking on the file by making use of the shortcut ctrl + shift + n and just start typing the file name or even just first letters of the words( ex: BA for BoxArray) and select the file. Which will open without asking the class name!!
Related
I've been trying to run gui in netbeans using java swing but it won't run at all. All the projects that I execcute that uses jframe does not run. Any tips on how to fix this thing? This is how it looks like:
I got this to run with no problems using NetBeans IDE 8.2. Let's start from the beginning.
Delete your current OfficeManagementSystem project from your IDE and local drive system. Select the OfficeManagementSystem project located within your IDE Project pane located on the left side of the IDE. Right-click on it and select the Delete popup menu item. A Delete Project dialog is displayed. Check-mark the Also delete sources under ..... checkbox then select the Yes button.
Close NetBeans!
To make sure all is gone, open your file browser (in Windows10 this is named File Explorer [win key + E]) and navigate to your NetBeans Projects folder. Default location in Windows is C:\Users\{yourAccountName}\Documents\NetBeansProjects\. Make sure that OfficeManagementSystem project folder is deleted.
With your web browser, go to the Source Code Web Page and select the Code button:
Then from the dropdown menu select Download ZIP:
A Save File dialog will appear possibly similar to this:
Select the Save File option then select the OK button. Choose a location to save the ZIP file and remember it.
Navigate to you downloaded file named HospitalManagementSystemusingJAVASwing-master.zip and Un-Zip it with your favorite decompression software like WinRar or 7Zip. Have it unzip into its own folder.
Navigate to and open the the folder created by your decompression software, it should have been named HospitalManagementSystemusingJAVASwing-master. If done properly you should have yet another folder (a sub-folder) also named HospitalManagementSystemusingJAVASwing-master. Rename this folder to HospitalManagementSystem by right-clicking on the folder and selecting Rename from the popup menu. Delete the unnecessary text within the name then hit your ENTER key.
After Renaming the folder, once again right-click on it and select Copy from the popup menu.
As described earlier, navigate to you NetBeansProjects directory (folder) and double-click on it. Paste the new HospitalManagementSystem folder into the NetBeansProjects folder. This project will now be added to the NetBeans Projects List.
Start NetBeans!
Once NetBeans has completely started, from the menu bar select the File ➞ Open Project... menu item. The Open Project dialog will be displayed. Scroll down the left pane of this dialog until you see HospitalManagementSystem and select it. Now hit the Open Project button. This project will load into the NetBeans IDE Projects pane located on the left side of your IDE under the name of: OfficeManagementSystem. Why this person changed the project name at this point is beyond me but to each their own.
Expand the project and its active package (officemanagementsystem) so as to expose all the classes involved. You should see the following listed:
LoginPage.java // The first Form we want displayed.
MenuPage.java // The Menu page (once login is achieved).
Module1.java // Should really be named PatientPage
Module2.java // Should really be named DoctorAvailabilityPage.
OfficeManagementSystem.java // The application start-up class.
This application still will not run since it contains nothing within the main() method of the start-up class (OfficeManagementSystem). Open this class into the IDE Editor by double-clicking on it.
Expand the main() method code block and add this code line into it:
new LoginPage().setVisible(true);
Run the application! The first Window displayed will be the Login Page. Username is: admin and the password is: admin. (change in code if you like). And away you go. :)
All java applications need a static main method as a bootstrap.
It should look something like the following:
public static void main(String[] args) { YourJFrameClass frame = new YourJFrameClass(); }
That should get you started.
The easiest method is to press Shift+F11 (Clean and Build Project), then hit F6 to run it.
It refreshes Netbeans appropriately and finds your main without all the manual labor; and if you have multiple mains, it will give you the option to select the correct one.
Check if your JFrame Class has this method:
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new YOURFORMNAME().setVisible(true);
}
});
}
The setVisibile(true) allows the form to be visible to the user. The main method is used to define the entry point for the application therefore this method is needed to run the JFrame
I wanted to add a java class to a project, but I did a mistake and added it as a text file. Then, I removed it and tried to add it again as a java class, but unfortunately it doesn't work anymore. And I get the following error:
Unable to parse template "Class" Error message: ABC.java mapped to not java file type text
As I searched, I faced some solutions like
this one but I can't find File Type under Editor or anything similar that I can change as suggested in the solution.
Any help would be appreciated.
PS: I am using IntelliJ 2018.3.4.
Thanks in advance,
Go on File->Settings and a dialog will open. In that dialog navigate on the left part to Editor/File Types and then you need to choose from the section Recognized File Types Java Class and remove from bottom section the problematic extension (note you have a small minus button on the right)
https://www.jetbrains.com/help/idea/creating-and-registering-file-types.html
This is a variant of Markov's answer that worked in my scenario.
Try going to File->Settings->Editor->File Types and to the Recognized File Types tab. Click the "Auto-detect file type by content" choice, and delete the name of the file you are trying to create from the "File Name Patterns" section by using the minus button.
Select required file type in top list (Recognized File Types) -- do it for "Text files"
In bottom list (Registered Patterns) select undesired pattern -- "SomeFileName.java"
Click on "-" (Minus) button to remove pattern from the list
Repeat 1-2-3 for other undesired patterns
If desired, you can also do this manually by editing config file while IDE is closed. Because it's IDE-wide setting, it is not stored in .idea folder (which has project settinsg only) -- the file to look for is called filetypes.xml and shoudl be located in ~/Library/Preferences/IntelliJIdeaXX/options ( see http://devnet.jetbrains.net/docs/DOC-181 for other OS etc )
Certainly inelegant, but you can simply copy the contents of the file to the clipboard (ctrl-c or similar), delete the file (maybe make a temporary backup somewhere outside the project), then in IntelliJ go to the desired package, right click, select new, select Java Class, name it correctly, and then you can paste in the contents of your file (ctrl-v or similar).
Suppose that I am in a layout file named "main.xml" and its corresponding fragment java class is "MainFragment.java".
Is there any shortcut to go to "MainFragment.java" from the "main.xml" or any other way?
It will be helpful to navigate around xml and java classes quickly when there are a lot of java classes and xml files in the project.
Note: For activity, there is a “C” symbol found in the top-left corner of the layout XML file. When we click that "C" symbol it will take us to corresponding java class in which the xml file is used. But for fragments, there is nothing available.
Use 'Related Symbol' (Navigate -> Related Symbol...)
In windows, press ctrl+alt+home, you can switch between activity/fragment and corresponding layout file
You could right click on the file main.xml and in the options menu click Find Usages. You can then see all the places where main.xml is used.
Add to your root layout
tools:context="your_screen_here"
Then you can navigate directly by clicking to this blue button on left side (I'm using material theme, your icon and color can be different)
If I understand your question then you must be looking for short-cut keys for navigating around all *.java and *.xml files in Android Studio IDE editor.
Here are few short-cut keys I use on regular basis which might help you out!
To navigate around any class files from any opened tabs -> ctrl + N
To navigate around any files (including class, xml, etc.) -> ctrl + Shift + N
To navigate through various opened tabs -> Alt + Legt/Right-Arrow Keys
Hope it would help you out!
Cheers!
Suppose I am in Eclipse viewing some .java file. Currently all projects in my package explorer are uncollapsed, i.e. they have not been navigated to any of their subdirectories within package explorer.
What I want to do is to find a hotkey which will cause package explorer to automatically open up all directories and sub-directories all the way down to the class that I'm currently viewing.
I want to do this because sometimes I will go to a class through Call Hierarchy or F3 and would like to view its location in its respective package without manually browsing package explorer for it.
Yes you can do this. See the pic below.
Open the file in an editor
Click on Link with Editor button in Package Explorer View.
Initially there is no hot key assigned to it. You can assign a hot key for this. Go to Windows > Preferences type keys in the top left text box. Ref pic below
Here I assigned Ctrl + [ key to this command. Make sure this key combination is unique and not conflicts with other key combinations.
Note:
The bad part is this key is not working if the Package/Navigator view was not active.
So to activate one of these views press Ctrl + F7 then go on pressing F7 key(while holding Ctrl key) till you reach the Package/Navigator view then release Ctrl key and press Ctrl + [.
I use Netbeans 7 on Kubuntu 12.04. I start Netbeans like this:
netbeans --cp:a /usr/share/java/xercesImpl.jar &
cause of known issue with Netbeans and Kubuntu 12.04. In the middle of my project my palette with Swing components just .. disappeared!
I see only sth like this:
How to restore default Netbeans palette?
I checked Ctrl+Shift+8 shortcut but with no results - the problem is still the same.
**EDIT:
I dont know what I did but now I see ONLY EMPTY palette :( : **
I also tried this:
1) I cd'ed to /home/mazix/.netbeans/7.0/config/Windows2Local/Groups/commonpalette
, ls'ed and saw only this: CommonPalette.wstcgrp
2) cd'ed to /home/mazix/.netbeans/7.0/config/Windows2Local/Components and saw this:
AnalyzerTopComponent.settings output.settings
AnalyzeStackTopComponent.settings projectTabLogical_tc.settings
breakpointsView.settings projectTab_tc.settings
CallHierarchyTopComponent.settings properties_1.settings
callstackView.settings properties.settings
CommonPalette.settings refactoring-preview.settings
ComponentInspector.settings
ReporterResultTopComponent.settings CssPreviewTC.settings
resultsView.settings debugging.settings
search-results.settings DeclarationTopComponent.settings
services.settings evaluator.settings
sessionsView.settings favorites.settings
sources.settings find-usages.settings
StyleBuilderTC.settings gsf-testrunner-results.settings
svnversioning.settings hgversioning.settings
synchronize.settings JavadocTopComponent.settings
TaskListTopComponent.settings localsView.settings
TerminalContainerTopComponent.settings
MultiView-java#007Cform#007C_1.settings threadsView.settings
MultiView-java#007Cform#007C_2.settings versioning_output.settings
MultiView-java#007Cform#007C_4.settings watchesView.settings
MultiView-java#007Cform#007C.settings Welcome.settings
navigatorTC.settings
and didnt see any _hidden files :(
Open NetBeans and choose Window -> Palette
It will appear but it will be empty because you didn't choose a GUI class yet.
To fill the palette with the GUI components like labels, follow these steps:
Create a new project .
Right click in the package name or project name, and choose New -> Other...
In the New File dialog box, choose the "Swing GUI Forms" from category and the "JFrame"
Form file type sub window. Click Next.
Enter name lets say "MyGUI" for the new the class which you created now.
The palette window is now full with components like labels, text,checkboxes, ...
if not appear yet make sure to press "Design" button in the upper of the GUI class bar "MyGUI"class
I got the same issue and this work for me window -> reset window. hope it work for you :)
I think the same problem occur here.Check this solution.it may helpful to you.
This steps for restore the default palette?
Exit the IDE.
Go to your user directory and go down to config/Palette subdir. In this directory, the files or directories deleted from the default palette content are presented as empty files with _hidden suffix in their names.
Delete these _hidden files to let the palette categories and items appear again in the IDE.
I think this will help you
Do one thing, simply right click on your netbeans project and then open it. It resolves the problem. You will observe if u open a new project the palette is there, so just copy the project with a different name, its will solve your problem.
In my case after creating a new project without a default constructor, the search box at the palette holds a single character i.e. '='. this results in an empty palette too.
In that case the solution is obvious: just delete the content of the search input.
It puzzled me for a moment, though, not noticing the search input field content.
I had the same situation with my netbeans. The only solution I did was to backup my project folder (saving it to other drive). Then re-install the netbeans. Afterwards I re-paste the project folder at the directory and re-open it.
Right-click mouse button at palette box. Choose command "reset palette".
I encountered the same problem. Just check the bottom of the palette to see if there is a search box open. If there is, close it. Then the palette will be available once again.
So, nothing suggested here worked for me, I am leaving my solution.
You create the project, name it.
Create a package.
Click on the package with the right mouse button
select New filme
select Other
select AWT GUI Forms
select Frame form
Now you should see the menu at the right part of your screen with the option to create buttons, labels, etc.
As of 2021 for mac users;
Open your NetBeans app and click on "windows" located at the top menu of the application. A drop down will appear.
Scroll down and click "IDE Tools". You'll see another dropdown containing list of items including palette.
Click on the "palette". This will make the palette visible.
That's all!