When the frame become too small, the buttons in a panel are hidden - api

I use a class that extends Frame and in the constructor after defining all the propriety of the new Frame i append with the BorderLayout.SOUTH a new Panel that contains some buttons.
When I reduce the size of the Frame, if the space for the buttons isn't enough some of these disappear from the Frame.
How can I fix this problem?
public AdventureUI(Tappa tappa){
setTitle("Adventure Game");
//DIMENSIONE STANDARD DELLA FINESTRA
setSize(700,500);
setMinimumSize(new Dimension(400,300));
pannelloPrincipale = new Panel(new BorderLayout());
pannelloBottoni = new Panel();
testoTappa = new TextArea(tappa.toString(),25,50,TextArea.SCROLLBARS_NONE);
testoTappa.setEditable(false);
testoTappa.setBackground(new Color(211,211,211));
areaUtente = new TextArea("",25,30,TextArea.SCROLLBARS_VERTICAL_ONLY);
//ADD BUTTONS TO PANEL
setBottoni(pannelloBottoni,tappa.getTappeCollegate());
//AGGIUNGIAMO ELEMENTI AL PANNELLO PRINCIPALE
pannelloPrincipale.add(testoTappa,BorderLayout.CENTER);
pannelloPrincipale.add(areaUtente,BorderLayout.EAST);
//AGGIUNGIAMO PANNELLI AL FRAME
add(pannelloPrincipale,BorderLayout.CENTER);
add(pannelloBottoni,BorderLayout.SOUTH);
// ASCOLTATORE FINESTRA
addWindowListener(new AdventureUIListener());
setVisible(true);
}
Images of the problem:
As you can see the button with 26 is hidden.

As you can see the button with 26 is hidden.
Yes that is because a FlowLayout always displays components at their preferred size. If there is not enough room then the component wraps to the next line, but unfortunately the height of the panel is not increased so you don't see the button.
Check out the Wrap Layout, it was designed to handle this situation. That is it will recalculate the height of the panel so all the buttons are displayed on multiple lines. At least it works with Swing. I've never test it with AWT because most people don't use AWT anymore.

Related

adding textfield over movieclip images

I have several images, which are Symbols (movieClip) with Alpha parameter.
And i'm creating dynamic textfield from AS3 to be able change text every few seconds.
Problem is that everything worked good till i converted images to MovieClips. But after that my textfields are not visible.
Here is the code:
textFormat = new TextFormat();
textfield = new TextField();
textFormat.font = new customFonts().fontName;
textFormat.size = 16;
textFormat.align = "center";
textFormat.color = 0xFFFFFF;
textfield.defaultTextFormat = textFormat;
textfield.embedFonts = true;
textfield.width = 480;
textfield.height = 95;
textfield.x = 185;
textfield.y = 22;
textfield.wordWrap = true;
addChild (textfield);
So the question is - how to bring this textfield to the top so it would be visible?
You're adding your Text field after the movie clips are being initiated. Think of it as a layer, the text field is at the bottom layer, hence they will not be seen.
I would look at the container class
The Container class is an abstract base class for components that controls the layout characteristics of child components. You do not create an instance of Container in an application. Instead, you create an instance of one of Container's subclasses, such as Canvas or HBox.
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/core/Container.html
You should be able to change what is displayed.
EDIT:
Anytime you add a clip it is added on top by default.
You should also look into Z-Index.
If you are coding with Flash Develop then it can get tricky, whilst using Flash Adobe CC can make your life so much easier!
Sorry if it's not that much of an answer.

programatically duplicate xaml control in WP

I'm not getting how I could duplicate a XAML element pgrogramatically. For example if I define on XAML a rectangle om the middle of the screen, the user presses a button and I would like to duplicate this rectangle with all properties of it and then put it to the right of the first one, should this be possible?
Sure - just do a deep copy of the properties you want inserted and then add it to the panel. Assuming your controls are in a StackPanel with horizontal orientation:
Rectangle newRect = new Rectangle()
{
Width = oldRect.Width,
Height = oldrect.Height,
Stroke = oldRect.Stroke,
// repeat for other values you want the same
};
myStackPanel.Children.Add(newRect);

dojo Tooltip repositioning after content is loaded

ALL!
I have dojo tooltip which is connected to an element.
It is created when/after page is loaded/ready. BUT, the problem is that content is loaded dynamically, when connected element is hovered the first time.
Content is loaded via AJAX. And - as far as the size of HTML content is unknown (widget is created, but content is still empty) - after hovering and content loading - Tooltip is appeared, but ARROW does not point to a connected element, but shifted down.
How to reposition a widget arrow after content is loaded dynamically?
Thanx a lot in advance!
UPDATE
After some investigations i have found, that position of tooltip Arrow is adjusted by
.tundra .dijitTooltipRight .dijitTooltipConnector class height (14px by default)
So i made quick and dirty fix for now:
function fixArrowForTooltip() {
// FIX ARROW (TODO HACK)
$(".tundra .dijitTooltipRight .dijitTooltipConnector").css("height",
"14px"); // restore to default for multiple tooltips in the page
var newHeight = $("#dijit__MasterTooltip_0").height() - 14;
$(".tundra .dijitTooltipRight .dijitTooltipConnector").css("height",
newHeight + "px");
// end of FIX
};
And placed this into onShow()...
I know, this should be re-worked, but.. WORKS PERFECT :)))
For any number of tooltips in the page arrows point DIRECTLY to connected elements :)

Child QWidget is not painted correctly

I need to show a virtual keyboard when the user selects an input text field in a webpage. This code runs on an set top box.
I am extending the QWebView, which is creating a new keyboard widget as a child.
WebView::WebView(QWidget* parent = 0): QWebView(parent)
{
WebPage *page = new WebPage(this);
this->m_keyboard = new widgetKeyBoard(this, Qt::Window|Qt::CustomizeWindowHint);
this->m_keyboard->createKeyboard();
this->m_keyboard->hide();
connect(this, SIGNAL(launchVirtualKB(WebView *) ), SLOT(launchKeyboard(WebView *)));
}
The widgetKeyBoard is made up of QGridLayout with many children QKeyPushButton.
When I do a show of keyboard, I see the whole keyboard drawn briefly and then overwritten 30% of the keyboard from the below web page (overwritten near the input field). I tried to have my own repaint for webview and mainwindow, but still see that someone else is overwriting.
What could be causing such an issue. I am using QT4.8.

How to Autofit the widgets in a view to variable window size automatically

I have an RCP application in which i changed position of the window(shell) and its size by overriding the postWindowCreate() method in ApplicationWorkbenchWindowAdvisor class, the widgets in the views are not fitted to the changed window size, to see all widgets either i have to maximize the window or move scroll bars of the view to see all the widgets inside the view, is it possible to auto-fit(show all widgets in the current window size without moving scroll bars or maximizing the window) the widgets in the view even if the screen size varies.
Usually, you change the size of the shell in WorkbenchWindowAdvisor.preWindowOpen(), not in WorkbenchWindowAdvisor.postWindowCreate():
public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor {
#Override
public void preWindowOpen() {
final IWorkbenchWindowConfigurer configurer = getWindowConfigurer();
configurer.setInitialSize(new Point(800, 600));
configurer.setShowCoolBar(false);
configurer.setShowStatusLine(false);
// configurer.setShellStyle(SWT.TITLE | SWT.RESIZE);
}
}
Likewise, you can set the window title and the style of the window.
The position of the window is usually best set in WorkbenchWindowAdvisor.postWindowCreate()...
If you must change the size of the window, then remember to call shell.pack()!