I'm building a Java application using NetBeans 7.0. The app is intended for use on Windows, so I guess the tool I'm really making most use of is Java Swing (for the cool, nifty screen elements).
My question relates to NetBeans' process of creating the various project types. The application I'm building is based on the "Java Desktop Application" template (?). My problem is that there seems to be a nice load of bloat built into that, and I can't figure out how to remove most of it without blowing up the app.
As a test, I created a "Java Application"project, but this has the opposite problem -- there's absolutely nothing built into the code, and I can figure out how to add anything. Specifically, a Java Desktop Application project created in NetBeans give me the ability to directly edit the screen layout like in Visual Studio. However, a Java Application does not appear to have this capability, I have no idea how (or even if) this can be addressed.
If I could start with a no-frills Java application, and add some capability to edit its layout and control the function of the screen elements (i.e. make it a windows application, I think), that would be just about perfect.
Does anybody have a suggestion for a minimal, but functional NetBeans application start point??
Thanks,
R.
If you start with a plain Java Application then as you realize you start with a bare bones type application. To add a GUI you can add New>JFRame Form. It adds a class that extends JFrame and Netbeans will recognize that it should open it in the visual editor for you.
Related
I am working on a primitive online game client that I wrote as a Java Swing application. My problem is that potential users refuse to download and run any unfamiliar executable. I want my game to be reach as many people as possible and users fear that the executable might contain a virus. That is why I would like to embed the game client into my web page instead. How would you turn this Java executable code (liked below) into an applet?
Thus far I have a main which makes the initial connection to the game server...
https://dl.dropboxusercontent.com/u/214507961/Main.java
A Java Swing GUI that I made with the Netbeans GUI builder...
https://dl.dropboxusercontent.com/u/214507961/GUI.form
Object input/output streams connected to my game/web server...
https://dl.dropboxusercontent.com/u/214507961/Clients_Input.java
https://dl.dropboxusercontent.com/u/214507961/Clients_Output.java
And some buffered images for graphics...
https://dl.dropboxusercontent.com/u/214507961/Image_Repo.java
Note that in future development, I would like to replace much of the primitive looking 2D Swing GUI with content rendered with the Lightweight Java Game Library or some other higher-level video game graphics specific library to make the game look better.
Given that information, what is the best way to make this Java application into an embed-able (applet)? Describe your method and reasoning in such a way that even a college freshman could follow.
Note: Following the advice below, I have tried using WebStart, but I still get an intimidating warning:
Update:
I am in the process of refactoring my code so that the top level container is a JPanel.
I have tried making "GUI" extend JPanel and changing the "gamewindow" from a JFrame into a JPanel.
Modified Main:
https://dl.dropboxusercontent.com/u/214507961/Panel_Top_Level_Container/Main.java
Modified GUI:
https://dl.dropboxusercontent.com/u/214507961/Panel_Top_Level_Container/GUI.java
Despite the changes, Netbeans will not allow this program to run with Java Web Start.
When I enable WebStart and Build/Clean, Netbeans creates two files:
I then clicked Build/Clean and it generated two files:
master-application.jnlp
https://dl.dropboxusercontent.com/u/214507961/Panel_Top_Level_Container/master-application.jnlp
preview-application.html
https://dl.dropboxusercontent.com/u/214507961/Panel_Top_Level_Container/preview-application.html
but no JAR file.
Still working on it. AI moved the remainder of this question to:
Why can't I get Netbeans with Java Web Start enabled to work on my executable?
At this point I'm so tired of putting up with the security hassles and see little to no way to get around certification warnings without paying. I have decided that it would probably be better to just re-write the entire client in HTML5 and javascript.
The basic concept is to build your app (GUI basicly) without using applet specific technologies (like commmunication with web page via JS etc.) and with JPanel as a top level container insteed of of JFrame (Window would be accceptable too, as JApplet extends Window). If you do so, that you will be able to deploy the same code as standalone application and via JNLP as applet.
The digital signature could not be verified by a trusted source.
This is caused by the app. being 'self signed' by a digital certificate we generate ourselves using the SDK tools. Security was increased recently so that 'self signed' apps. get that scary warning. This has been discussed extensively across SO in recent times.
Try looking at the posts under applet+security for details.
Redo the client using HTML5 and Javascript so that you don't run into any prompts or security warnings.
My goal is to write a Visual Studio plugin (a VSPackage) for my Java application. I was wondering if it was possible to view some JPanels inside a System.Windows.Forms instance, or rather as an Microsoft.VisualStudio.Editor.
I was thinking an applet but I'm pretty much stuck there...
Is streaming a Swing component as JPEG and displaying it in a Form an applicable idea?
EDIT:
I would really appreciate answers that are more then a "yes"/"no"/"why would you do this?". I made my mind about working this way, so I ask for:
A detailed solution for achieving my goal, OR,
Good insights/ideas of what my approach should be, OR,
A thorough explanation for why it is impossible to achieve.
( ) Way of the warrior
Load the JVM from your extension (use jvm.dll).
Implement your own Applet Container. Something like this AppletViewer.
Put the Applet Container inside your native form. This is hard, there are ways to get the Applet Container HWND (In Java Swing how do you get a Win32 window handle (hwnd) reference to a window?), but I am not sure a simple SetParent can do the trick.
Load your Applet.
( ) Way of the master
Use NPAPI/NPRuntime, like the browsers do.
Load the npjp2.dll Java Plug-In.
Load your applet.
(X) The solution adopted was:
Run the VS Plugin part written in Java (like an Applet) with JVM in another process (the standard for Java).
Get the HWND using FindWindow (Win32 API).
Use SetParent (Win32 API) and MoveWindow (Win32 API), to dock the window and resize it.
I could name it the "the easiest way", but running Java in another process will give you more stability, so this is the "way that works". My only fear about using a window from another process, was the thread that process Windows messages in Java could interfere in Visual Studio. But from what I see, there is nothing to fear.
:-)
We can create Java GUI based application using net-beans IDE and also we can create it using Notepad . Using netbeans or eclipse it is very easy . But I saw every where that every one used notepad. So I just want to know that the best way for create Java GUI application.
Its better preferring some IDE like Netbeans , Eclipse since because, you can consume time in creating the gui by utilizing the features like drag and drop, in-build function support suggestion which proper demonstration of usage and syntax.
If you are developing gui from scratch using notepad, it may takes more time, one developing things in that way should be thorough knowledge in syntax and all other functionalities
The Java Tutorials on Swing are a pretty good resource. If you don't like hand-coding your UI with Java code there are several GUI builders out there where you can lay out your UI visually and just fill in the behaviour in code-behind. E.g. Netbeans has such a thing and there is WindowBuilder for Eclipse.
I have a couple of questions regarding Eclipse and IntelliJ IDEA support for building a plugin that can...
show (and accept user input to) an interactive web application (with drag-and-drop diagram editing functionalities similar to Visio/OmniGrapffle/Inkscape) inside the main workspace (the biggest space to the right:)) of the IDE.
interaction with the web application (e.g. clicking on a box in the diagram) will trigger some action in the IDE (e.g. show a corresponding source file, or opening a dialog to create a new class).
In other words, I plan to let the web application manage most of the GUI aspects to overcome the limitations of Eclipse and IDEA in terms of animation, or flexibility in terms of showing nice graphics.
To this end, the web application needs to be able to communicate with the services/other plugins provided inside the IDE.
Browsing the web and StackOverflow revealed to me that Eclipse supports an OSGI architecture that might enable me to write an webservice that can be accessed from a web application. But I'm not sure where to start with. Also no relevant information concerning building my plugin for IntelliJ IDEA can be found.
It would be great if you can provide me some pointers. Thank you very much.
PS: I was considering building a normal plugin, (e.g. using the Eclipse's Graphiti project) but the user experience (button's shape, dialogs, properties windows, etd.) using only Eclipse platform support seems limited, as opposed to full HTML/CSS/JavaScript/etc/ supported by a web application. I might be wrong with my approach though so any help would greatly be appreciated.
I have a Neatbeans application, that works well and runs well so I want to move it into Android. So I am taking code snippets and moving it into Eclipse, and into a default made droid class. (which compiles, loads, and displays on the virtual device)
The problem, is that a few things that used to "import" into Netbeans, won't in Eclipse, or I am just doing it wrong, not sure.
Usually in Neatbeans I hit "import such and such class" and then it all compiles fine and no red errors appear in the code. In Eclipse, it is not giving any import option to some features, examples are..
DefaultModelList
HTMLUnitDriver/WebDriver (Selenium's program)
JOptionPane
And I am guessing some more will eventually pop up in the future.
Does Eclipse not support those options or something? Or is it Android that does not support those options?
Can someone tell me how to work around those issues, with their respective problems please?
The program itself is a mobile chat application, that will basically be a mobile version, of a chat that already exists on the web. Pulls chat feed data, lets you post chats back; basically the same thing as the chat on the website, but accessible from your smartphone.
Your problem is not with NetBeans vs. Eclipse. It sounds like your app uses the Java UI Framework Swing, from which you have JOptionPane. Swing is not available under Android, and anything that uses Swing will have to be extensively recoded to use the native Android UI instead.
Your app may use other libraries that aren't available in Android, as well.
Eclipse does support those options (press ctrl-shift-o). The problem is most likely the transition to Android -- lots of items change names. The Android native item to use is not JSpinner but Spinner, etc.
Also: In Android most GUI work is done with layout .xml files, a bit different than plain Java programming.
TLDR: you're conflating multiple issues. Eclipse can even import a Netbeans Project directly.
Is Eclipse a strong requirement for you? If you love NetBeans and everything is working, why not to continue with it? I believe you can develop for Android in NetBeans too...
http://binarywasteland.com/2011/07/install-netbeans-android-sdk/