I am making a simple examination app! The questions for various examinations will be present on the server. The clients will access them using RMI, and the UI for client side is being implemented in Applets! (that's according to the spec of the project!).
I want to have multiple applets for various stuff! I want to be able switch from one applet to other depending on the return value of the methods called on the server. I also want to be able to pass information if necessary!
Please tell me how can I do it!
An applet is equivalent to your workspace. You generally have one JApplet per application.
Now, you can have various JPanels within your JApplet. These JPanels can switch depending on the return value of the methods called on the server.
This Oracle tutorial should help you get started: How to Make Applets.
Related
I have a JAVA application that, every five minutes, transfers data from a Data Base A to a Data Base B. Then, the application makes some calculations with the data of the Data Base B, and shows the results in a java swing panel. The application is continuously running. All ok.
I would like to see this java swing panel from other computers (more than one). So the idea is to see the panel from different computer whenever you want. I have thought of making a webpage showing the results, but I have no idea of making webpages and I haven’t much time to deal with it.
Is it possible to make a fast java application (or anything else) that connects with my swing panel from another computer?
Thank you very much!
You could use an applet, your Swing components will be added to a JApplet instead of a JFrame, and any web client can download the full application. You will still need to make a web page, but it could only have your Java applet in it.
I'm new here and not so much familiar with applets.
I searched the site and many other forums for answer but i found nothing.
I have made an application in Java which starts with an applet login form, and continues with JFrame subforms which are doing several things like running JOptionPanes for example when a customer make a change in his profile.
My problem is that when the JOptionPane appears, the applet start form comes on top even if i have opened 2 or 3 JFrames.
I forgot to say that my app is big so i cannot post any code (and i think is not needed).
Thanks in advance!
Avoid mixing frames and applets, your working with competing paradigms. If you MUST use an applet, use something like a CardLayout or JTabbedPane to allow the user to switch between forms.
If you can, try using Java Web Start, which will allow you to start your application off the web, but have the same restrictions as that of any embedded GUI.
As to your problem, it sends like you are mixing the native peer for the JOptionPane. Make sure that the parent reference is correct (ie references the frame or child of the frame)
No, Im not asking for a full made program :) Im kind of new to Java as language so Im not familiar with java libraries at all and my experience is mostly about php, but I understand OOP well.
My scenario:
I want to build a Java applet to my website, by which different users can share a same screen window in which they can drag and drop things(images) to specific positions and when one does, it would update the screen to the others. Before connecting, user would choose to build a new screen or join other. If he wants to join other he would just enter some existing (random) screen id to connect to. If he wants to create a new one he would access this screen in which he would see the screen id to share with someone else. I dont care if two persons wants to drag and drop different item to same spot, it would then just use the one that came last.
Now that you understand what I want to build...
What I really just need is the skeleton structure of something like this. What parts I will need to build something like this? Libraries and such, where should I look for tutorials, Best practices, hierarchy, should I use tcp or udp? I just need something where to start from.
An applet is run in the system memory of each individual client. There are strict rules about what applets can and cannot do, and I am not sure whether or not applets would be allowed to make remote connections to other users. I would advice doing some google leg work on java applet security and seeing what you dig up.
Assuming this is possible:
In terms of architecture, I think you would want one person designated as the host create the game and run all the game logic, while the clients just receive information pertinent to graphics being displayed (location, size, texture, what have you) and sends back information about what the client is doing.
I did something like this as a school project in high school, but I was forced to sign the applet to make it do remote http connections. I would assume this is still the same case.
Hope that helps a little bit.
i want two use output from one applet as an input for another applet running in parallel..
There is no problem to run as many as you want applets simultaneously on one page. But you wish to make applets communicate with each other.
Each applet can access applet context that has API to access other applets on the page:
applet.getAppletContext().getApplets()
applet.getAppletContext().getApplet("appletName")
Then you can call any public method you want.
Like AlexR said, you can run all the apps you want(as long as CPU can handle it). Another 2 options for communicating between them would be
1: To use the 'Model-View-Controller' Design Pattern described in the book "Advanced ActionScript 3 with Design Patterns."
2:Create an Applet that will Encapsulate all the other applets, then with this applet start up all the other applets. Inside each applet declare an instance of each (applet)class you need it to communicate with then create a set method for it. now from your Encapsulating class use the set methods to pass the instances of the applets to each applet that needs it....(yes, I know it's confusing but it works well if you get it right)
I have a windows application which has a complex GUI that I would like to hide from users. In order to do this, I would like to create a wrapper with an extremely simple interface that overlays this application and automates a number of actions when a user clicks a single button on the wrapper. (I hope "wrapper" is the proper term.) Is it possible to use Java to block input to the underlying application so that users cannot inadvertently mess up the automation? How would I go about this? Also, how can I automate key presses and clicks to the application without hijacking the mouse? Is this possible in Java?
I have looked at java.awt.Robot, but it appears to hijack the mouse.
I have also looked at AutoIT, but it too hijacks the mouse and does not integrate with Java.
Neither of these options seem powerful enough for what I need, but I do not know how else to proceed.
I recommend that automation via the GUI only as the last resort if you really have no other alternative.
If there is an API that your application exposes, I would try to use that. For example, if the GUI is implemented in one DLL and the logic in another, then you can use JNA to load your application logic DLL and invoke the application functions directly from java. Even better would be if your application exposes a COM/OLE interface - there are plenty of Java<>COM briges, that will alow you to call this interface directly, e.g. Jacob.
If you really have no choice but to automate via the GUI, then here's how to go about doing that:
Use JNA to access the windows shell API. You can then use ShellExecute to launch your wrapped application. Specifically, passing SW_HIDE as the window mode should help ensure that the application does not appear.
Use JNA to access the windows API FindWindow to find your application window. You can also make it invisible using the ShowWindow API, just in case step 1 did not work (not all applications are written to use the nCmdShow parameter.)
You can now post messages to the application window using PostMessage. You can send keystrokes and mouse events using windows messages. E.g. See WM_KEYUP, WM_LBUTTONDOWN.
Because the wrapped application window is made invisible, you don't need to "block" that application, The user simply cannot access it's GUI. But you can still programmatically send input to it.