LWUIT: Layout calculation problem - java

I have a rather large application written with LWUIT. With only a few screens that have the problem.
The problem:
When the page loads, everything looks fine. but when you scroll you can't scroll to the bottom, and when you click on a list it selects the item below where you clicked and not on where you clicked
However, when you click a select the list for a second time, all is fine. Also when a dialog pops up, after clicking it away, all is fine. And when I forget to call show() or repaint() he does not paint anything but when i try to scroll he shows() everything and he calculates it correctly.
I'm really puzzled about this problem. I'm searching on it for a long time now. And I would love to gain some new insights here.

After 5 days of searching on it, I finally found the solution. You have to call form.show() after you have added everything to your form. and not before, like I was doing.
Most of the time it works fine in both ways. Just not always.

Related

Stuck trying to advance to the next loop in GUI class

I'm a long time observer, and first time poster. So forgive me if I seem to skip over some typical guidelines.
Posted below is a link to my GUI class, where I display different "screens"/JPanels in my client program. The client keeps track of these screens by referencing a state variable, which is documented at the top of the class.
Upon launching the client, the GUI builds the JFrame, then starts attaching things to it. First up is a splash screen, then after a short time it moves on to displaying a menu. This part should be clear in the code. The problem I'm experiencing occurs when a menu item component is clicked on. The GUI properly removes the menu from the window, however it doesn't move on to displaying the login screen. Both the menu and, login screens are attached in a similar fashion. Despite my best efforts to debug the code by printing messages at each step, I can't seem to figure out why after changing the state to "3", the GUI doesn't advance into the "Login" phase of the loop and, display the login screen.
http://pastebin.com/xWDpjD14
Also, I should note, the state is being changed by a Mouse Listener class attached to each menu item of the menu screen. I've already debug'd this part. I just can't figure out why the loops aren't working as expected.
Sorry I don't have a SCCE(sp?) to attach, It's my first post, and I'm not quite familiar with the sites posting options yet.

Scroll down after setText

So, what I have currently is basically
displayText.setText();
scroll.fullScroll(View.FOCUS_DOWN);
This goes over and over with user input, and eventually displayText gets big enough that it moves on to another line, which is why I want it to scroll down. I'm pretty new to this and so I'm not too sure what I'm doing wrong.
I'm not completely sure about what you want to do, but if I understood well, look at this, it might help you : How to get the Android TextView to scroll down to the end automatically?

Show a panel after x seconds after button click

i'm extremely new to java. i have a simple program here and what i want is to show a certain JPanel, after x seconds delay, when a button is clicked.
what i want in particular is something like a "start game" button, and upon clicking it, a panel that contains a "loading..." animation would be shown temporarily in the JFrame in x seconds, then another panel would show up after this.
i'm aware Timers would be the answer to this. but i've done all the thinking and research that needs to be done first. my last resort is to ask it here. i need at least a sample code upon which i can figure out the rest by myself
i'm badly in need. i have acquired poor java knowledge in a short period of time and my instructor expects a spectacular output from me. thanks in advance.
Simply write Thread.sleep(x*1000); after clicking the button.
It will make the application wait for x seconds. After completing x seconds application will proceed further.

Clicking on Hidden Menu Item in Selenium 2.33 Java

I have a Menu Element that pops down only when clicked and then fades out on losing focus. My task is to click on a hidden sub menu item.
From previous answers to similar situations I used the following code to click on the Sub menu Items.
Actions builder = new Actions(driver);
WebElement mainMenuElement= driver.findElement(By.id("Mainmenu"));
builder.moveToElement(mainMenuElement).build().perform();
mainMenuElement.click();
Thread.sleep(2000);
WebElement mySubMenu=driver.findElement(By.xpath("//a[text()='Kit Components']"));
mySubMenu.click();
But, when I run the code in chrome v 27, once in three times or so the submenu item never gets clicked. The mainmenu opens up and stays still forever. But the submenu.click() is executed everytime without Exceptions and the submenu is also visible.
Is this because of my code? or
Could this be because the Submenu item has a localized region for Click? i.e Manually when I click on the submenu, the click works only on the text and not on remaining blank regions of the element.
Im using selenium 2.33 Java with chrome v 27.
Any advice would be very helpful, thanks.
First off, please, don't use Thread.sleep in your code. Ever. Instead, use the FluentWait or WebDriverWait commands.
Now, to answer your question, it seems as if you have stumbled upon what some people call a "flapper", or a "flakey test". If your test fails one in three times or so, something is really flakey.
I have noticed every once in a while that the click function doesn't always do the actual click (even though every indication in the code says it did). I wonder if you're happening upon this? Usually I do a check to see if the click seems to happen. If it tried clicking in the code but nothing happens, I will let it retry the click. If the retry doesn't work, then something is really up.

Echo3 Framework - problem setting focus elemnt to text box when screen is built

in echo 3 i have a problem setting focus on a specific text field in a new screen. The probelm occurs when a user holds their mouse on the reference button on the previous screen as opposed to just a simple click.
it looks similar to this:
public void display screen {
build window
if window isnt null{
build screen
if screen.textfield isnt null{
Thread t {
thread sleep 10000
screen.textfield.setFocus
}
}
}
}
in the pseudo above the focus would be set if the user user held the reference button down on the screen before for less than 10 seconds, in which case the focus would not be set until the remaining thread time passed. this isnt good because it take too long; and lower wait delay doesnt insure that the focus will set at all because the user might hold the key for longer.
I have tried launching multiple threads and using timers to hammer the focus in but that didnt work... is there something im missing about how the code is built internally because it seems that the whole thing is built despite the fact that the user hasnt let go of the button.
If thats the case is there a way to do it on release?
Thank You
Found a solution. The problem was with using IE6. I presume the order in which it builds is different to that of IE7+.

Categories

Resources