Problem centering in a Panel
In the following code, I can't figure out how to center the Button and Text components that have been added to a Panel. I can move things vertically by using a Spacer, but I can't figure out how to move them horrizontally. I want to center them in the Panel.
Can anyone tell me what I'm doing wrong?
Thanks!
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" horizontalAlign="center" verticalAlign="middle" backgroundColor="white" applicationComplete="init()" borderStyle="none">
<mx:Script>
<![CDATA[
import mx.controls.Spacer;
import mx.controls.Text;
import mx.controls.Button;
import mx.controls.TextArea;
import mx.containers.Panel;
import mx.containers.Canvas;
import mx.containers.*;
import mx.managers.PopUpManager;
private var panel:Panel=new Panel();;
private function init():void {
var label:Text = new Text();
var spacer:Spacer=new Spacer
spacer.height=50
var button1:Button = new Button();
button1.label = "OK";
button1.addEventListener(MouseEvent.CLICK, closePopUp);
label.text = "Please enter your name:";
//panel.styleName="panel1"
panel.width = stage.stageWidth;
panel.height = 180;
panel.addChild(spacer);
panel.addChild(label);
panel.addChild(button1);
createPopUp()
private function closePopUp(evt:MouseEvent):void {
PopUpManager.removePopUp(panel);
private function createPopUp():void {
PopUpManager.addPopUp(panel, this, true);
PopUpManager.centerPopUp(panel);
]]>
</mx:Script>
</mx:Application>
try this
<?xml version="1.0" encoding="utf-8"?>
<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml"layout="
absolute" backgroundColor="
white"applicationComplete="init()"
borderStyle="
none">
<mx:Script>
<![CDATA[
import mx.controls.Spacer;
import mx.controls.Text;
import mx.controls.Button;
import mx.controls.TextArea;
import mx.containers.Panel;
import mx.containers.Canvas;
import mx.containers.*;
import mx.managers.PopUpManager;
private var panel:Panel=new Panel();;
private function init():void {
var label:Text = new Text();
var button1:Button = new Button();
button1.label =
"OK";
button1.x = 200;
button1.y = 200;
button1.addEventListener(MouseEvent.CLICK, closePopUp);
label.text =
"Please enter your name:";label.x = 200;
//panel.styleName="panel1"
panel.width = stage.stageWidth;
panel.height = 180;
panel.addChild(label);
panel.addChild(button1);
createPopUp();
panel.getChildAt(0).x = panel.width/2; //added by tanweer
panel.getChildAt(1).x = panel.width/2; //added by tanweer
private function closePopUp(evt:MouseEvent):void {
PopUpManager.removePopUp(panel);
private function createPopUp():void {
PopUpManager.addPopUp(panel,
this, true);
PopUpManager.centerPopUp(panel);
]]>
</mx:Script>
</mx:Application>
in the place where i added code try to manipulate it according to your req.
I suugest you to use Hbox container for such type of issues. get back to me for furthur questions
Similar Messages
-
Hello,
I am having incredible problems centering the Tab widget and
am using an "elastic" web page design, so the Tab widget must
resize when the browser window resizes (which is easy with standard
tables).
When I set the "float" to "left" and the width to 100%
(without margins or padding) the Tab container size exceeds the
width of the <div> which is used as its container in a
classic three-column format.
To summarize my design issue I have:
Column 1 (left) which is fixed width
Column 3 (right) which is fixed width
Column 2 (uses the Tab widget) is elastic.
Column 2 with the Tab widget only works visually if I set the
width to ~"96%" and then is not perfectly centered depending upon
how the browser window is sized/resized. The Tab widget in column 2
really acts strangely if the browser is resized to less than 800
pixels, simply falling down to the bottom of the page as if it is
wrapping (which I assume it is). It seems that setting the Tab
width container width to 100% is not possible.
I am not a CSS expert, but have used it enough over the last
four years to know that I am stumped.
Thank you for any help.How come the answers to my questions always seems so obvious..?
Thank you Brad - that made the trick. -
Hello, my problem is that, my panel the creative clout, it don't has information...it is white!
BLANK Cloud Screen http://forums.adobe.com/message/5484303 may help
-and step by step http://forums.adobe.com/thread/1440508?tstart=0
-and http://helpx.adobe.com/creative-cloud/kb/blank-white-screen-ccp.html -
hello,
I have the following problem with my Yahtzee game:
I use a class DicePanel with there on five instances of class 'Dice'. When you push the 'throw' button on the panel, I want the panel to check if there is actually something selected. Because if there's nothing selected there can't be thrown. (This would give problems with the 'throw counter', that's counting 1, 2, 3, 1, 2 ,3).
I have tried a lot of things, but I always get this error:
java.lang.OutOfStackError
When you push on the throw button, first the dices are checked to be selected. I prefer to use a method for this, so i can write something like the following in the throw method:
if( somethingIsSelected() ){
blablabla
or:
if( !somethingIsSelected )
return;
My dices are in an array so i can check each dice witch a for-loop. After this for-loop some boolean should be false or true
So my question is: how can i prevent the StackOverflowError??
What seems to be the most logical way to work with 5 dices and one panel?
excuse me for my bad English ;-)
mzzlIf you're getting a stack overflow, then you're probably recursing but not checking the end conditions properly.
-
hi,
i m new to java still learning new concepts. When i was working with menu and panel i got this problem and i tried a lot but still i havn't got any success. the problem is i m creating a menu with two menuitem - one for "add item" and another for "modify item". What i want to do that on the same frame i want to create two panel of these two item. when i click "add item" option it should show add window and so with modify option. but the problem is if i click add item it shows the addpanel but when i click modify option (add item panel goes- ok ..) but it doesn't show the modify panel, it shows only the main frame on which menu is there.
i cannot understant what is happing here plz guide me.
thanximport java.awt.*;
import java.awt.event.*;
import java.sql.*;
import javax.swing.*;
public class ajitAutomobile extends JFrame implements ActionListener
JMenuBar mb;
JMenu jobmenu;
JMenuItem newJobCard,modifyJobCard;
Font ft;
JPanel pnlnewJobCard,pnlmodifyJobCard;
Container con;
ajitAutomobile()
ft=new Font("Arial",0,12);
mb=new JMenuBar();
setJMenuBar(mb);
jobmenu=new JMenu(" Job Card Form");
mb.add(jobmenu).setFont(ft);
newJobCard=new JMenuItem("New Job Card Detail");
modifyJobCard=new JMenuItem("Modify Job Card Detail");
jobmenu.add(newJobCard).setFont(ft);
jobmenu.add(modifyJobCard).setFont(ft);
mb.add(requisition).setFont(ft);
con=getContentPane();
// setting panel for new JOb Card Entry
pnlnewJobCard=new JPanel();
pnlmodifyJobCard=new JPanel();
con.add(pnlmodifyJobCard);
con.add(pnlnewJobCard);
pnlnewJobCard.setBackground(Color.RED);
pnlnewJobCard.setVisible(false);
pnlmodifyJobCard.setBackground(Color.YELLOW);
pnlmodifyJobCard.setVisible(false);
//setting JFrame resources
setVisible(true);
setTitle("Ajit Automobile Service Center");
setSize(750,300);
setResizable(false);
newJobCard.addActionListener(this);
modifyJobCard.addActionListener(this);
public void actionPerformed(ActionEvent ae)
if (ae.getSource()==newJobCard)
pnlnewJobCard.setVisible(true);
pnlmodifyJobCard.setVisible(false);
if(ae.getSource()==modifyJobCard)
pnlnewJobCard.setVisible(false);
pnlmodifyJobCard.setVisible(true);
public static void main(String args[])
ajitAutomobile objajit=new ajitAutomobile();
objajit.show();
}so, this is the code and as i m expecting that when i click on "New Job Card Detail" then it should display pnlnewJobCard and when i will click "Modify Job Card Detail" it should display pnlmodifyJobCard panel but it is not working.It shows only that panel which is clicked first.
plz help
thnx, any answer will be appriciated. -
Problem with Append Front Panel Image To Report.vi
I'm using LV 7.0 with the MicroSoft Report Generation toolkit installed. Under the Report Generation palette there exists an Append Front Panel Image To Report vi. Also on the same palette there is an Easy Print VI Panel or Documentation.vi which uses another Append Front Panel Image To Report vi located under the VI Documentation subpalette. Here is the problem; I have serval vi's that use Append Front Panel Image To Report.vi from the Report Generation palette and I have a couple of vi's that use the Easy Print VI Panel or Documentation.vi which is linked to the Append Front Panel Image To Report.vi located under the VI Documentation subpalette. Clear as mud!
This creates a conflict of intrest. In a nut shell th
ere are two vi's with the same name in different locations doing different things. I have a program with subvi's that need to call each respective Append Front Panel Image To Report.vi and that just is not working.
Is this a known issue with LV7.0 that has already been addressed and/or resloved?
Thanks.ATC Herman,
Based on the picture you posted and what you are describing, it looks like you might have an incomplete install. What version of the toolkit do you have? Was it first installed on an earlier version of LabVIEW, or did you install it first on 7.0? Your VI Documentation Palette appears the same as if you hadn�t installed the toolkit. I�ve attached a screenshot of what it should look like. The VI in question is a polymorphic VI, which may be causing some of the confusion. If you right-click on it and select �Open Polymorphic VI�, it will show you what options you have, depending on the input. I opened both test and test1, and they appeared the same for me. I was able to have them both on the block diagram. The path to bo
th of them was C:\Program Files\National Instruments\LabVIEW 7.0\vi.lib\printing\ReportDocExtensions.llb\Append Front Panel Image to Report.vi. The .llb ReportDocExtensions has the polymorphic VI, as well as copies of each of the possible instantiations. Make sure you have these VI�s in the .llb in that directory.
There is a KB on having the toolkit on multiple versions of LabVIEW and what files you need. Make sure you have all the files listed.
Please let me know if you are able to get to the bottom of the issue with the above information.
Thanks, and have a happy day!
Robert M
Applications Engineer
National Instruments
Robert Mortensen
Software Engineer
National Instruments
Attachments:
Report_Palettes.JPG 57 KB -
Has anyone had a problem with printing labels centered on HP Photosmart 7510 e-All in one? My labels are printed from Word 2007 and appear on the screen to be centered, however when I print, they are too high on the label. Also when printing an e-mail the bottom of the page where it lists your email name is cut off. Please help!!
Hi,
I'd been having this problem for probably round 30 years on many printers. I bought a labels printer few years back but I don't print labels everyday now.
Regards.
BH
**Click the KUDOS thumb up on the left to say 'Thanks'**
Make it easier for other people to find solutions by marking a Reply 'Accept as Solution' if it solves your problem. -
Problem while minimizing a panel
Hi,
I have a panel where there is html component init....which displays pdf file..
<containers:Panel
id="myPanel"
title="Panel"
width="100%" height="100%"
horizontalAlign="center"
verticalAlign="middle"
resizeEffect="Resize"
allowDrag="true"
allowResize="true"
allowClose="true"
allowMaximize="true"
allowMinimize="true"
moveEffect="Move"
close="panelContainer.removeChild(myPanel);"
>
<mx:HTML id="reader" width="100%" height="100%" y="0"
location="http://121.243.253.109:8080/DBStage/DBPageReference/Bare Acts/State Acts/Arunachal Pradesh/Dept. Of Co-Operative Societies/The Arunachal Pradesh Co-operative Societies Act (Amendment) Act 1989.pdf">
</mx:HTML>
</containers:Panel>cont...
* Minimize the panel.
public function minimize():void
if (!canAnimate)
return;
isMinimized = true;
isMaximized = false;
If we try to call this too soon it will mess up our first transition
so we'll hold off unless we have the properties set.
updateRestoreRect();
if (minimizeRestoreRect)
this.width = 200;
this.height = titleBar.height;
this.move(0,650);//this.parent.height - 30 // move()
var myEvent:SuperPanelEvent = new SuperPanelEvent(SuperPanelEvent.MINIMIZE);
dispatchEvent(myEvent);
The problem is after minimising the panel......
After minimizing the panel to left corner bottom also... a part of pdf window is still visible.....
Pls guide me ..... hwy is this happening....
Thanks & regards -
Problem viewing via Preview Panel (.ai Vector Files)
Hi
I am having trouble viewing vector files via the Preview Panel. The problem is that the thumbnails are not taking up the whole window like they usually do.
I make sure I save my Illustrator files with "Create PDF Compatible Files" checked, as this usually solves this type of issue. It seems to be Mac specific as my colleague can view the same files, located in the same location across our server without a problem on his PC and our Preferences are set the same. I am still having this issue, even if I copy the files to my desktop.
I have taken a screenshot to show the problem (attached or at the location below).
http://img51.imageshack.us/img51/8991/previewproblem.png
Thanks in advance.Hi
I am having trouble viewing vector files via the Preview Panel. The problem is that the thumbnails are not taking up the whole window like they usually do.
I make sure I save my Illustrator files with "Create PDF Compatible Files" checked, as this usually solves this type of issue. It seems to be Mac specific as my colleague can view the same files, located in the same location across our server without a problem on his PC and our Preferences are set the same. I am still having this issue, even if I copy the files to my desktop.
I have taken a screenshot to show the problem (attached or at the location below).
http://img51.imageshack.us/img51/8991/previewproblem.png
Thanks in advance. -
Problem with Spry Tabbed Panels with Explorer 6
I've used Tabbed panels all over my site, and they seemed to work fine in FireFox, Safari, Explorer 7 and 8, etc. but today i checked out Explorer 6 in BrowserLab, after someone said our site looked weird.
In EX 6 it certainly does: all the tabbed panels are preceded by about a screen's worth of empty space!
I'd appreciate it someone could have a look at this and see if they can tell what's going on:
See this page:
http://www.ragandbone.ca/Pages/willows.html
or almost any ohter page on the site!
I'm very far from experienced in web work, so I might need step by step instructions for any fix suggested.
Thanks in advance
JohnHi, John,
Make the width of the .TabbedPanels narrower. In the course of my experiments, I ended up making it 580px, which works in IE6, according to BrowserLab. You had a simple width overrun; your widths + borders+ paddings + margins (within the content div) added up to more than the width available. You might be able to get away with slightly more width, but test it carefully when you start to add it back in...
This might be an instance of the "doubled margin bug" (see http://www.positioniseverything.net/explorer/doubled-margin.html).
I changed the margin on .TabbedPanels to margin: 0 auto; so that any effective centering that had been done by 'filling' the width previously was now achieved by the margin-right and margin-left set to "auto." (The zero applies to top and bottom margin.)
I deleted the left: -40px; that you had applied to .TabbedPanelsTab and zeroed out the right padding on .content ul, .content ol {
padding: 0 15px 15px 0; that your threeColFixHF_RB.css had applied to all ul in the site. This might or might not actually affect anything if you don't make these same changes, but I had altered them in the course of figuring out what was going on. It's never a good policy, in my opinion, to use negative margin if you can simply correct both elements, as I did. You don't want to be progressively compensating for things you don't need anyway!
Beth -
LV2011 problem with several front panels
Hello,
There is a bug in my software and I don't know it is common to every one or not. This not to be worry, I will notify you anyway. When I open only one front panel and one block diagram which having a program to communicate with a serial device. In this case, if I choose the VISA resource name, it obviously takes some time to popup the USB and after it show the port and front panel will stay in front you until you choose the device. Here, every thing is fine but when I open several front panels and working on only with serial program front panel to choose the serial device in VISA resource name. Then after some time, it took me to another front panel. I have seen this problem several times in past two months. More, even when I am decorating the front panel and front panel took some time after pushing some controls and switched another front panel.
Is this bug? Or I common for every one.
Using labVIEW 2011.I am certainly using labVIEW from two months. So, I did not use MAX in my past time. I only used one time to check my USB 6008 device but this is off topic here. I will tell you down here.
Suppose, If I open multiple VI's and I am only working with one VI that can communicate with my SERIAL device and the rest of the VI's(Block diagram and front panel) are rested. This case, if I click the drop downlist of "VISA resource name" of SERIAL VI, then it took some time(200ms or 100 ms, just it is a guess) to populate and it is switched to another front panel which were opened and rested before. Again, I need to come to my serial front panel again to select the COM port. This is one case.
If don't have any other VI's not opened than this serial Vi. Then it stays on the same front panel.
Is this bug came with labVIEW or is it common? -
Problem w/ Tooltips & Collapsable Panels in Safari
Hi,
I have a page that has Collapsable panels along with Tooltips
that are used for a help tip in each panel. My problem is when the
page loads in Safari, the contents of the bottom most Col Panels
are displayed elsewhere in the page. The Col Panels tabs and
containers remain where they should though.
Heres a page displaying the issue:
http://dev.meetingsintelligenceexchange.com/planner/tooltip.php
There are 2 columns with 3 Panels in each. All of the Panels
have a help icon in tab of the panel that acts as the Tooltip
trigger. If you collapse the top most panel in each column then
reopen it, the layout corrects itself.
I can't figure out what is happening. I've tried removing the
help icon to see if the float is causing the problem but it still
occurs.
Any help would be appreciated.
Thanks, ScottThanQ everyone for reviewing my problem. I solve the issue myself... ThanX...
-
Environment selection problem at web control panel start
Hi everybody.
We are facing some problems after BPC web control panel logon. It appears a popup window asking for an environment selection. After that, the browser is refreshed and the popup appears again.
This is the popup. Can someone help us? Thanks in advance.
Best regards,
Julián.Hi Andy,
We tried clearing the cache of the browser, temporal windows files, clearing the server cache via
http://<server>:<port>/sap/epm/bpc/web/clearcache and http://<server>:<port>/sap/epm/bpc/web/resetcachebuster urls and accessing via /sap/epm_bpc/web but the result was always the same: after a few accesses, the popup appears again.
As an extra data, we configure SCPM in the server some time ago. Could this be the cause of the system behavior?
Thanks again to all of you.
Julian. -
Problem creating an extendable panel with a header
Hi -
I'm trying to create a base panel class. What it needs is a header at the
top of it with a title box(another panel) of a different color. The title of
course is in the title box. My primitive solution was to create a parent
panel and place the title box on the header panel, then the header on
the parent panel. My problem is that I can't extend from that and add
components to it with the header there.
Does anybody have a more elegant solution?
Thanks.Hello Steven,
You can use createdby field to determine the docentry of the base document instead of quering docentry by docnum
select createdby, transtype, baseref from jdt1
Note: Always set the correct document type for payments: (createdby is ok in integer format)
Example:
Opening Balance: JE # 8 amount 1000, created by Opening balance (not JE)
vPay.Invoices.DocEntry = 8
vPay.Invoices.InvoiceType = BoRcptInvTypes.it_OpeningBalance
vPay.Invoices.SumApplied = 1000
Call vPay.Invoices.Add
Opening Balance: JE # 8 amount 1000, created by Journal Entry
vPay.Invoices.DocEntry = 8
vPay.Invoices.InvoiceType = BoRcptInvTypes.it_JournalEntry
vPay.Invoices.SumApplied = 1000
Call vPay.Invoices.Add
Sales Invoice: DocEntry: 11 amount 1000
vPay.Invoices.DocEntry = 11
vPay.Invoices.InvoiceType = BoRcptInvTypes.it_Invoice
vPay.Invoices.SumApplied = 1000
Call vPay.Invoices.Add
Regards,
J. -
Problem with scrolling a panel containing an image
I am having a problem adding scrolling capabilities to a tabbed panel containing pages containing an image. In my program, I have a class called ImagePanel that extends JPanel and contains an image read from a file. In another class, I create a tabbed panel and add to it ImagePanels.
The problem I'm facing is that the pages added to my tabbed panel contain scroll bars, but these scroll bars are not scrollable (i.e. I cannot use the bars the scroll and see the missing parts of the image).
Any help on this manner is highly appreciated.
The code is shown below:
JTabbedPane m_pathwayTabbedPane = new JTabbedPane();
ImageIcon overviewImageIcon = IconLoader.readImageIcon(pathway.gif);
ImagePanel overviewPanel = new ImagePanel(overviewImageIcon.getImage());
JScrollPane graphcrollPane = new JScrollPane(overviewPanel,
ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
m_pathwayTabbedPane.addTab(StringManager.OVERVIEW, graphcrollPane);import java.awt.*;
import java.io.*;
import java.net.*;
import javax.imageio.ImageIO;
import javax.swing.*;
public class ScrollingImages
public static void main(String[] args)
String[] fileNames = {
"images/bclynx.jpg", "images/mtngoat.jpg", "images/redfox.jpg"
JPanel panel = new JPanel(new GridBagLayout());
panel.setBackground(Color.black);
GridBagConstraints gbc = new GridBagConstraints();
gbc.insets = new Insets(5,5,5,5);
gbc.gridwidth = gbc.REMAINDER;
for(int j = 0; j < fileNames.length; j++)
panel.add(new ImageComponent(fileNames[j]), gbc);
JFrame f = new JFrame();
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.getContentPane().add(new JScrollPane(panel));
f.setSize(400,400);
f.setLocation(200,200);
f.setVisible(true);
class ImageComponent extends JPanel
Image image;
public ImageComponent(String fileName)
loadImage(fileName);
setBackground(Color.black);
protected void paintComponent(Graphics g)
super.paintComponent(g);
int w = getWidth();
int h = getHeight();
int imageWidth = image.getWidth(this);
int imageHeight = image.getHeight(this);
int x = (w - imageWidth)/2;
int y = (h - imageHeight)/2;
g.drawImage(image, x, y, this);
* For the JScrollPane which will inquire about our size
* which it needs to properly set its scrollbars.
public Dimension getPreferredSize()
return new Dimension(image.getWidth(this), image.getHeight(this));
private void loadImage(String fileName)
try
URL url = getClass().getResource(fileName);
image = ImageIO.read(url);
catch(MalformedURLException mue)
System.out.println(mue.getMessage());
catch(IOException ioe)
System.out.println(ioe.getMessage());
}
Maybe you are looking for
-
I purchased a song from the itunes store and downloaded it to my ipod and it will not play what happens now?
-
Getting error in Exporting the data from legacy system to Tables
Hi, I am trying to export the data. But am getting the below error. Unknown system exception - java.security.PrivilegedActionException: javax.security.auth.login.LoginException: java.net.ConnectException: t3://abc.com:7001: Bootstrap to abc.jdadelive
-
I can no longer use any of my external hard drives or my phone
Hi, I have a macbook pro and everything was fine 4 days ago. Now when I plug in any external hard drives, or even my phone, they do not show up anywhere. the phone is the only thing that even shows up in the system information. It was fine 4 days ago
-
Hi, Trying to use the following in Automate all fail with the same error codes: Lens Correction Merge to HDR Photomerge all have this error; I have tried to change CS6 Preferences/Performance to allow more memory etc but that didnt help. Restarting d
-
Best Practice Re-install Process? (Xcelsius 2008 Engage)
The main impetus of this post is now to request a best practice reinstall process. E.g., what files/directories or registry keys to delete after uninstalling under Windows XP? Running Xcelsius 2008 5.1.1.0 Build 12,1,1,344 (Windows XP SP2)? I want