How to place a JPanel at the center of another JPanel?
Can anyone tell me how to place a JPanel inside another JPanel? The first JPanel consists of three JPanels each consisting of a label&textfield and are placed using BoxLayout. The second JPanel is a big blank screen. So, i would like to put the first JPanel at the center of second JPanel(horizontally & vertically). The problem is that i don't have any other component. So,if i try to use FlowLayout, i am able to put it at the center(horizontally, not vertically) only on the top edge. I tried to use BoxLayout. But, i couldn't(as i don't have any other elements). I tried to create some blank elements. But, they are messing up the elements of my JPanel. Any cluesssssssss??????????
import java.awt.*;
import javax.swing.*;
public class CenteredLayout
private JPanel getPanel()
GridBagLayout gridbag = new GridBagLayout();
GridBagConstraints gbc = new GridBagConstraints();
gbc.insets = new Insets(2,2,2,2);
JPanel p = new JPanel(gridbag);
addComponents(new JLabel("label 1"), new JTextField(8), p, gbc);
addComponents(new JLabel("label 2"), new JTextField(8), p, gbc);
addComponents(new JLabel("label 3"), new JTextField(8), p, gbc);
JPanel panel = new JPanel(gridbag);
panel.setBackground(Color.pink);
gbc.anchor = GridBagConstraints.CENTER;
gbc.insets = new Insets(0,0,0,0);
panel.add(p, gbc);
return panel;
private void addComponents(Component c1, Component c2, Container c,
GridBagConstraints gbc)
gbc.anchor = GridBagConstraints.EAST;
gbc.gridwidth = GridBagConstraints.RELATIVE;
c.add(c1, gbc);
gbc.anchor = GridBagConstraints.WEST;
gbc.gridwidth = GridBagConstraints.REMAINDER;
c.add(c2, gbc);
public static void main(String[] args)
JFrame f = new JFrame();
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.getContentPane().add(new CenteredLayout().getPanel());
f.setSize(400,400);
f.setLocation(200,200);
f.setVisible(true);
}
Similar Messages
-
How to attach a text in the center of the Ellipse using JXML ?
How to attach a text in the center of the Ellipse using JXML ? Can we use labelFor="$topEllipse" ?
<StackPane fx:controller="myfxml.ArchiveLogsController" id="Login" xmlns:fx="http://javafx.com/fxml">
<children>
<AnchorPane>
<!-- Prevent AnchorPane so that it's max = pref. This causes it to center in StackPane -->
<maxWidth><Double fx:value="-Infinity"/></maxWidth>
<maxHeight><Double fx:value="-Infinity"/></maxHeight>
<children>
<Ellipse fx:id="topEllipse" centerX="100" centerY="100" radiusX="50" radiusY="10" strokeWidth="2" stroke="#FF0000" style="-fx-fill: linear-gradient(to right, white 0%, red 100%);"/>
*<Label fx:id="ArchLogs_lb" text="My Ellipse Label" />*
</children>
<properties>
<backgroundColor>
<Color blue="1.0" green="1.0" red="1.0" />
</backgroundColor>
<elementLockSel>
<Boolean fx:value="true" />
</elementLockSel>
</properties>
</AnchorPane>
</children>
</StackPane>I'd suggest putting the Ellipse and the Label in a StackPane.
I wonder why so many people call it JXML?
It is so strange - I guess the JXML name just seems more natural to some people, though I don't know why.
I think Greg is right and that labelFor is not what you want:
http://docs.oracle.com/javafx/2.0/api/javafx/scene/control/Label.html
"Labels also are useful in that they can have mnemonics which, if used, will send focus to the Control listed as the target of the labelFor property . . . A Label can act as a label for a different Control or Node. This is used for Mnemonics and Accelerator parsing. This allows setting of the target Node." -
How see if material exist in the center?
Hi gurus.
Iam a abaper and I hene a problem.
I am using BAPI_SALESORDER_CREATEFROMDAT2 and ocurrs log error in txt file :
The material 40000221 does not exist in the center CE52 / country BR
How see if material exist in the center?(transaction ?table? )
ThanksBeing an ABAPer, you should be knowing in which tables a material would be stored than a functional guy. Moreover, being an old member of the forum, you should be knowing forum rules where it has been clearly spelled out to post queries here after ensuring that you made efforts to search the forum. So according to that, had you searched with that text ( material 40000221 does not exist in the center), you would have found lot of discussions happened on this topic.
Coming to your query, you need to check first in MARA table whether the material is created or not. Next in MVKE where the material has to be extended to Sales Area for which, the sale order is being created.
G. Lakshmipathi -
How can i get rid of the cents in my account ?
how can i get rid of the cents in my account ?
If you want to change countries and can't spend it then you can try contacting iTunes support and ask them if they can remove the balance so that you can do so : http://www.apple.com/support/itunes/contact/- click on Contact iTunes Store Support on the right-hand side of the page, then Purchases, Billing & Redemption
-
How to place a logo in the BEX
Hello All,
I am new to the BW.Could u pl.explain how to place a logo
in the BEX.
Thanks & regards
NSBHi Suresh,
Are you asking about BEx Excel based reports, or the web reports..there are different ways to go about it.
For the excel reports youc an create a workbook template and place the logo along with other custom settings for color, font etc.
For the web based reports you would have to place the logo in your web template.
Hope this helps...post back if you need more information. -
How to Export/Import "report for the query" to another company
Hello,
I do this:
1.create query in SQL analizer
2.copy paste into SBO query generator and save
3.create report for the query
Then, How to Export/Import "report for the query" to another company ?
Thanks for your HELP.Look for SAP Note number 600813
That's the note Adele means, I guess.
<b>Edit (@13:18)</b>
The direct link:
https://websmp101.sap-ag.de/~sapidb/012006153200000183292003E.ITF
---- Replace *SOURCE* with the source database name.
---- Replace *DEST* with the destination database name.
insert into [*DEST*].[dbo].[RDOC]
select [*SOURCE*].[dbo].[RDOC].*
from
[*SOURCE*].[dbo].[RDOC],[*DEST*].[dbo].[cinf],[*SOURCE*].[dbo].[cinf]
where [*DEST*].[dbo].[cinf].[lawsset]=[*SOURCE*].[dbo].[cinf].[lawsset]and [*DEST*].[dbo].[cinf].[version]=[*SOURCE*].[dbo].[cinf].[version] and [*SOURCE*].[dbo].[RDOC].[Doccode]NOT IN (SELECT Doccode from [*DEST*].[dbo].[RDOC])
insert into [*DEST*].[dbo].[RITM]
select [*SOURCE*].[dbo].[RITM].*
from [*SOURCE*].[dbo].[RITM],[*DEST*].[dbo].[cinf],[*SOURCE*].[dbo].[cinf] where [*SOURCE*].[dbo].[RITM].[Doccode] NOT IN (select Doccode from [*DEST*].[dbo].[RITM])AND [*SOURCE*].[dbo].[RITM].[Doccode]IN (SELECT Doccode from [*DEST*].[dbo].[RDOC])
Hope it helps...
Grtz, Rowdy -
How do I authorize music from the cloud from another computer
How do I authorize music from the cloud from another computer? PowerBook4 to a Toshiba with Itunes.
Hi there 7Corydon7,
You may find the information in the article below helpful.
iTunes Store: About authorization and deauthorization
http://support.apple.com/kb/HT1420
-Griff W. -
How do I Place an image into the center of an activated artboard in CC?
I have just upgraded to CC from CS6. In CS6, I could activate an artboard (double click it in the Artboard panel) and then Place an image, which would by default go into the center of the artboard.
With CC, it "loads" the image into the cursor which I then need to Place by clicking somewhere.
How can I get it to either behave as it did in CS6, or customize to load it into the center when I click, such as with a modifier key?
Thanks!Hi,
With the Window > Allign panel,
You can select the option to allign to selection or to Artboard.
When you select "to Artboard" you schould be able to use the Allign option to get it centerred.
See preview bellow.
Hope this helps. -
How do i Pate frames from one movie to the center of another? please help?!
what i am trying to do is, put a flash frame by frame movie into my flash web site. So i go to the frame by frame movie and hit Edit- Time line - Select all frames. i then hit Edit- Time line - Copy frames. i switch over to my web site, Create a new layer select the layer and hit Edit - Time line - Paste Frames. and the frames i copied are pasted into order and all my symbols are brought into my library. The problem is than when it is pasted its pasted in the upper left hand corner of the page on top of all my other stuff when i select the the frames of the frame by frame movie and move them to the center of the stage. It seems to work fine but when i test my movie the first frame will be fine and than some stuff goes back to the original pasted spot and some stuff will stay where i moved it to. my question is. How do you paste the frame by frame movie to the center of the stage so it does not have to be moved at all?
or else how do i move all frames and objects to where i want them and not just the first frame?when you copy and paste frames, object positions will be maintained from the copied to the pasted frames.
if you want to edit multiple frames simultaneously, click edit multiple frames (an icon in the timeline panel just below frame 22, if you're using normal sized frames). -
How to place an image on the dashboard in obiee 11.1.1.5 version
Hi All,
I am using obiee 11.1.1.5.I want to place an image on the dashboard.Can anyone help me on how to achieve this.
Thanks,
PrafulHi,
In OBIEE 11g, an image needs to be placed in two locations. They are
1. Middleware_Home\Oracle_BI1\bifoundation\web\app\res\your_skin\images
Example: D:\OBI11g\Oracle_BI1\bifoundation\web\app\res\s_blafp\images
2. Middleware_Home\user_projects\domains\bifoundation_domain\servers\bi_server1\tmp\_WL_user\analytics_11.1.1\7dezjl\war\res\your_skin\images
Example: D:\OBI11g\user_projects\domains\bifoundation_domain\servers\bi_server1\tmp\_WL_user\analytics_11.1.1\7dezjl\war\res\s_blafp\images
PS: In the above example s_blafp skin is used.
Usage of the newely added image in a Title View:
res/s_blafp/images/new_image.jpg
Award points it is useful.
Thanks,
satya -
How to display a region in the center of the page
Hi,
I am trying to position a region in the center of the page and I am using the following in the region attributes field
style="width:70%; region = "center";"
but the region is positioned to the left only. Is there any other method to do this work.
Please help me out.
Thanks,
Rik
Edited by: Rik281 on Nov 17, 2010 7:31 AMBefore posting, please TRY and do a search on the forum, you MIGHT find your question already asked and ANSWERED..: place a reports region on center of the page
Thank you,
Tony Miller
Webster, TX
On the road of life...There are 'windshields', and there are 'bugs'
(splat!)
"Squeegees Wanted" -
How to make movies open in the center of my screen.
Does anyone know how to make Quicktime open up videos in the center of a screen? When I double click any movie file it pops open in the uppermost far left corner, and I have to drag it down into a more comfortable area. It's annoying with a large monitor.
Thanks
noodle--headThe script writing lobe of my brain was damaged by years of drug abuse, years ago. Try as I might, I can't seem to get it right.
The most common error I get is:
Expected end of line, etc. but found “end tell”.
I tried modeling one of any number of existing scripts but still no dice.
I tried this:
tell application "QuickTime Player"
activate
set the bounds of window 1 to {235, 58, 944, 590}
end tell
And got this error message: QuickTime Player got an error: NSReceiverEvaluationScriptError: 4
I know this is simple but, like I said...
nnooo-dlehead ssslowto catchon -
How to place standard text at the bottom of the last page
Hi Gurus,
I have a requirement to place a standard text at the bottom of the last page.Right now i am having 2 sub forms
in a body page in that one(header details) will not get overflow and only visible in the first page and the second
body page( Item details) will get overflowed, till here it is working fine. Now i need to include terms and
conditions details at the bottom of the last page but i included the standard text in the context area
and i don't know where to place that text in the layout . I tried with including
a sub form in the master page and placed the text in the bottom of that sub form but it gets repeated
in bottom of each and every page and i tried by placing one more sub form in the body page
but the text is coming immediately after the item detail gets ended.I need only at the bottom of the
page where the item details ends. Please make me to solve this problem.Hi,
I gone through the link in that they set the footer part of the purchase order immediately next
behind the body(Table) so after the table growth gets completed the footer gets displayed
but in my case after the table growth ends it should display at the bottom of that page.For
example if the table ends at the top of the second page ultimately the footer should be at the
bottom of second page.If the table ends at the bottom of the first page and if the footer can't
display the whole content in the bottom of the first page then the footer should move to the
bottom of the second page. -
How to place aggregated fields in the page header or group header
Hi,
i have a report where in i have to display a header based on the aggregated value of a field
currently the field has values like
row1 blank
row2 blank
row3 Cookies
row4 blank
I wanted to know how to get the maximum of these rows in the page header i.e. it should come as Cookies for this case.
Is there any way to get this? it is easy in the footer where i can do a maximum of this field and get the value but not sure how to get this in the group header.How do we group maximum at the page header or group header?
Require your help on this at the earliest.
Thanks
ShilpiHi Shilpi,
>
Shilpi Sinha wrote:
> currently the field has values like
> row1 blank
> row2 blank
> row3 Cookies
> row4 blank
>
Do display these things in a subreport(i mean adda subreport in detail section). And Create a formula in the subreport itself with shared varible for assiging the maximum value ..
Then in the main report , create one formula with same shared variable and just display in Header secton..
Regards,
Salah. -
How to stop a thread at the end of another
hello
I want to run two threads. They start at the same time, and I want one of them to end when the first one finishes.
I have a main class, a GUI. When I click on a button, it processes an action( first thread), and since this action takes some time, I decided to create a second thread that is a GUI that is a dialog box that says that it is being processed...
So my dialog bow has to disappear when the process ends.
I've already tried this:
boolean stop = false;
Connect connect = new Connect(this);
connect.start();
LdapSearch searching = new LdapSearch();
searching.start();
while( connect.isAlive() ){
if( !connect.isAlive() ){
stop = true;
if( stop == true ){
searching.interrupt();
}but unfortunately the text written on my dialog box disappears....
does anyone knows how I can make a thread stop at the end of another properly?
thanks for your help!!
Philippesorry the code i tried is:
boolean stop = false;
Connect connect = new Connect(this);
connect.start();
LdapSearch searching = new LdapSearch();
searching.start();
while( stop == false ){
if( !connect.isAlive() ){
stop = true;
if( stop == true ){
searching.interrupt();
}
Maybe you are looking for
-
Problem with scanning document to searchable pdf in HP Envy 4500
I just bought HP Envy 4500 , overall good printer, but I can't find option for scanning to searchable pdf. I already updated my desktop software and printer's firmware, but still there is no option "scan to searchable pdf". Do i have to download some
-
I tried it in Safari to make sure it wasn't a computer problem, but it works in Safari and in iPhoto.
-
What is the purpose of TAG library? I feel so hard while using Tag library in my JSP pages?
-
I recently purchased an Ipod 4G from a family friend. When I set up my account, I originally was going to keep some of the items on it but found they were not appropriate for my 10 yr old. So I reset the IPOD erasing everything and started new. Af
-
I need to retrieve the a set of rows in between two rows from a table.
consider employees table and primary key employee_id. With out using EMPLOYEE_ID column in the where clause or between clause, I need to get the records between 104 and 116 or a set of records between two rows. Can any one help me in this... i know t