Getting 'with_frame(":1")' in my tests - java

My app has the ability to 'load' a deal. After it's loaded, a new frame renders with the deal's information.
I'm having trouble targeting this frame with Marathon. I am able to target other parts of the app, but if I control-click on the new frame, I get with_frame(":1") in my scripts. When I try to replay, Marathon cannot identify the frame, and hangs.
I surmise it has something to do with a name or id attribute on the panel, though I don't know much about Java. Could someone point me in the right direction?

#DanielDiazCarrete was correct, I added
this.setTitle("SomeTitle");
to my frame, and Marathon was able to identify it.

Related

Java Gui empty frame

I am currently developing a project with a genetic algorithm.
It works fine, I get the results I wants, so no problem on this side.
I displayed all the information in the console so I decided to create a GUI to improve the software.
I have two frames. One is a selection frame where you select your options for the run.
The other is a frame with a textArea. The purpose of this second frame is to display the information about the run in it. For both frame I used the MVC design pattern. It works fine, I have run some tests for the GUI and all is displayed normally.
Now the problem is when I try to integrate the two sides.
I launch my first frame in the main. Then it switch to the second frame and run the Genetic algorithm when the information are complete and the user clicked the OK button. I make verification of the information and let the button enabled false until it is correct ;).
In theory it is suppose to display the second frame empty then launch the GA then input text in the frame dunring the run with the MVC model.
The problem happens when I click the button, the second frame display partially. I mean I have the frame with the title and the red close button but there is nothing in it. I can move the frame with my mouse but if i click the red close button, nothing append, so I guess the frame is kind of freeze. The Ga run perfectly during this time. At the end of the
GA's run the rest of the frame appears with all the information that should have been input in it. So the Mvc model is working good. It is just the frame that don't display normally.
I use the following code :
Vue2 vrga = new VueLorsRunGa(); //create the 2nd frame
vue1.dispose(); //destroy the first one
//code to run the GA
I am not use with the GUI so maybe I made it wrong and so I don't free something needed.
If we take it sequentially, the vue2 is supposed to be totally launch before the ga code is executed. But i read in a article that the GUI's things are managed in a special thread. And so it not suppose to be freeze by the GA ... The GA got its specific threads but I haven't done any for the GUI.
So if anyone had a idea where I can be wrong or how to managed to suppress my bug, it would be great :)
Thank you for help
Scyn
You are probably running your code in the EDT thread (like directly from the actionPerformed method) which blocks other events being processed.
You should move long running operations out of the EDT thread

combine multiple windows to a single window

I am developing an application which have the following windows
If the information entered in the windows are correct than only the user will be prompted with the windows in the above sequence. Now the customer has demanded me with this user interface.
Now I have to add all these windows in the last window format, with the specification's as the user will be allowed in the 2nd portion of the last image if the first information entered is correct.And the user when launches this app see the last image and can change the values as any time in the respective portions of the last window.
I have coded it in Swing Java.I am new to Java. I am working in Netbeans 7.1.2 I have three files as
1)Login.java
-containing my LoginDemo class which have main and form object of extended Jframe class
-Login class extending J frame and implementing action listener(this class creates an J frame of next file Enter the information.
2)Algorithm.java
creates new J frame object of next file if information is correct.
3)TravellingSalesmanProblem.java
gives the output as shown in Optimal Travel Route window.
I am accessing the information using REST call to a website.
So can anyone help me in this?
This will depend on how you structured you code. If you simply placed components directly onto the the windows/frames themselves, then you might be in for some work.
Alternatively, if you used panels, which you then placed onto windows, this might save you some time.
Anyway. Assuming you only have windows.
for each window do
myLastWindow.add(window.getContentPane());
This is pretty simple, but you'll also need to know the layout you want. I'd suggest something like GridLayout or VerticalLayout from the SwingX project.

Java JPanel/GUI contents appear only sometimes when run

i'm new to Java programming, but I've done C++ for a while now. the whole GUI thing is new to me. i created two JPanels and added them to JFrame using FlowLayout. When I run the program, i get http://imageshack.us/photo/my-images/43/36213853.jpg/ as opposed to http://imageshack.us/photo/my-images/88/86682510.jpg/ only SOME of the times. the other times, the content appears just fine
for some reason, when i resize the window when the window is blank, the contents appear fine.
i'm not sure what the problem is that gives me this inconsistency!
any help would be appreciated. thanks!
It's hard to answer without code, but by chance are you calling setVisible(true) before packing your GUI and before adding components to the GUI? Do the components show up if you resize your GUI?
If so, you'll want to make this call only after your GUI has been fully populated with components, and usually after it has been packed (so that your layout managers can lay out all components and size the GUI correctly).
If this advice doesn't help, then you'll likely need to post some of the offending code. How much to post -- it's hard to say -- enough so that we can identify the problem ;) but not to much as to be drowned in code not related to your problem. The best code to post is an SSCCE if you have the ability to create one.

OfficeBean won't display after moving containing Swing Panel from one Container to another

I'm developing a Java 6 applet which allows users to view OO (v.3.2) documents (read only), and if they choose, click a button which launches a new JDialog window, with the document displayed in it which allows the user to and mark and redact it as they wish. Once they are done, they can close the JDialog, which saves the document to a server and redisplay the updated document (read-only again) in the original applet window
I guessed that I could do this with a single instance of an OfficeBean, embedded in a Swing Panel. However, I cannot seem to successfully move my Panel (containing the OfficeBean) from the applet to the JDialog when the "Redact" button is clicked. All I get is a blank area in the JDialog where the document should be. I get no errors.
I have currently managed to get round this by creating new instances of the OfficeBean every time I need to display the document (once when the applet is loaded, again when the user chooses to redact and it is opened in a JDialog, and finally when they click "Save" in the dialog and the redacted result is displayed in the applet again.) However this means three trips to and from the server where the documents originate. That seems mad to me.
I'm in no way a Swing expert and may well be making a silly mistake. However, I've done a lot of fiddling around, debugging and googling and can't seem to get this to work. Can anyone help me in this? Am I trying to do something which is fundamentally impossible? I hope not.
One rule in Swing is that a component can only be displayed / attached to one part of the gui "tree" at a time. When you "move" your component to the dialog, are you first removing it from the applet?

Netbeans 6.7.1 mainPanel resizing problem

I've created a small gui app in Netbeans. As I was adding in some buttons and text areas the mainPanel resized itself. Now it is really wide [probably 4x as wide as I want] but when I try to drag the edge in it won't resize back down. If I drag it out, making it bigger, it takes that change. I would just like to return the mainPanel back to a reasonable size. Not sure what I'm doing wrong here. I've tried to change the min size, max size, and preferred size settings for the mainPanel with no success. I've even tried to change the menuBar & statusPanel settings at the same time as the mainPanel [thinking that one of them was making the others too big] without success.
Any ideas?
Netbeans does do really stupid things like that sometimes, and I generally get around them using either of these two methods:
First thing to try is to change the layout used. Try the Grid Bag Layout, or any of the others and see if you get better results.
If that doesn't work, then probably the easiest thing to do is to change stuff in the code. You will notice that Netbeans automatically adds a call to initComponents(); in the constructor (you have to switch to Code view from Design view). And if you look at initComponents, it will have a whole heap of auto-generated code to create the GUI. Do NOT edit this, because it's just a matter of time before Netbeans overwrites your changes. What I do is to create a new method initComponentsFix, and call that immeidtaely after initComponents in the constructor. In initComponentsFix, I would add the code to resize the component to the preferred size, and any other things you you want to fix.
BTW I empathise with you - Netbeans' GUI editor is still in need of much work. However, it's code auto-generation is still very useful, so I wouldn't recommend coding the GUI the good ol' fashioned way. That's why I'm advocating using it up until you start felling its limitations, after which you "take control".
There is also a third way, which I would not recommend, is to edit the file that Netbeans stores the Design view in, which is basically shares the same file name as your frame's class' source code, except with a .form extension.
This file is XML, and is pretty easy to edit. I don't recommend this because it is sorta going around the back door, but as a last resort, you can still try it.

Categories