Get layout-position of a component
Hi!
i have a frame applcation with two toolbars.
they can both be dragged to a new position in the borderlayout with the mouse. it was'nt easy to have no problems with the layout-manager when they are set to a new position.
now i want so save the alignment of the toolbars for the next start of the application.
how do i get the current alignment of a toolbar?
the toolbar is an attribute of the class, i know the panel, and that is no other component in the north, south, east or west.
for example the best thing would be to retrieve
String layoutPosition = toolbarPanel.whereTheHellIsTheToolbar(toolbar);
(e.g. "BorderLayout.SOUTH")
to serialize this string and to initialize at the next start
add(toolbar, layoutPosition);
thanks for any help in advance.
Rainer
Not sure, but this thread might help:
http://forum.java.sun.com/thread.jsp?forum=57&thread=340326
Similar Messages
-
Get the position of the component on GUI ???
Hi All,
How can I get the position (x, y) of a component such as JCompoBox on Frame at runtime ?
Thanks a lot,
HuyTo the the location of a JComponent in it's parent... just use the getLocation method on the JComponent.
If you need that point relative to some other ancestor, I would use SwingUtilities.convertPoint
Hope this helps,
Josh Castagno
http://www.jdc-software.com -
Getting the position of a component in a container for repainting
This may be a stupid question but, I want to get the position of a custom component as it lays in a JFrame. This is needed for a repaint of the special component. getX() and getY() return the origin of the component as it is painted in paintComponent(). How might this be done without messy parameters to an overridden repaint method?
I need the position so that I can cut out a portion of an underlying background image in the JFrame, so that I can repaint the component's text without clearing away the image or painting over it with a color. If anyone has a better idea, I'm all ears. . .
Thanks.as a near solution to my problem, I have created the following method to locate the exact origin of the custom component:
private int[] getAbsolutePosition(Component c)
int pos[] = {this.getX(), this.getY()};
int x = 0;
int y = 0;
Container parent = c.getParent();
while (parent != null)
x = parent.getX();
pos[0] += x; // append next width
y = parent.getY();
pos[1] += y; // append next height
parent = parent.getParent();
pos[0] -= x; // Remove the position of the parent frame
pos[1] -= y; // from the totals.
return pos;
}The custom component has 3 JPanels, one Container, and a JFrame beneath it. I remove the JFrame positions becuase they would mess things up. Still, the x values it returns are off by a small but noticible amount. Does anyone know what might account for this? -
Getting absolute position of component
hi
i want to take a screenshot of the content of a specific JFrame in my ui
what the code below does is take a screenshot of my screen starting at its (0, 0) coordinates
but not starting at the so called (0, 0) of the JFrame
Robot robot = new Robot();
Dimension dimension = getJFrame().getSize();
Rectangle rectangle = new Rectangle(dimension);
BufferedImage screenShot = robot.createScreenCapture(new Rectangle(rectangle));how can i calculate the offset to the JFrame ?
i already tried all kinds of things
and didn't find any reference online
thanksYou use this on the JFrame:
//from the API
getLocationOnScreen
public Point getLocationOnScreen()Gets the location of this component in the form of a point specifying the component's top-left corner in the screen's coordinate space.
Returns:
an instance of Point representing the top-left corner of the component's bounds in the coordinate space of the screen
Throws:
IllegalComponentStateException - if the component is not showing on the screen
See Also:
setLocation(int, int), getLocation()Then use your component location as an offset from the JFrame location. -
How to center loaded swf & get screen coordinates of its component?
I made an swf using Flash CS4, it has a movieclip named 'mc' & and a vertical bar centered horizontally. I then load it using swfloaded & put it inside a canvas & set it's windows & height to 100%.
The codes:
<mx:Canvas id="cv" verticalScrollPolicy="off" horizontalScrollPolicy="off" width="{screen.width}" height="{screen.height}">
<mx:SWFLoader id="template" source="assets/sample.swf" width="100%" height="100%" complete="dump(event);"/>
<mx:HBox id="bb" />
</mx:Canvas>
<mx:Script>
private function dump(event:Event): void {
var panel:MovieClip = MovieClip(template.content);
var pt:Point = panel.localToGlobal(new Point(panel.mc.x, panel.mc.y));
bb.x = pt.x; bb.y = pt.y; bb.width=10; bb.height = 10;
panel.x = (cv.width - panel.conentWidth) / 2;
Alert.show(
"scaleratio x,y = " + panel.scaleX + "," + panel.scaleY +"\n"
+ "panel x,y = " + panel.x + "," + panel.y + "\n"
+ "local x,y = " + panel.mc.x + "," + panel.mc.y + "\n"
+ "global x,y = " + pt.x + "," + pt.y + "\n"
</mx:Script>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The dump result is:
scaleratio x,y = 1,1
panel x,y = 100,800
local x,y = 775, 800
gloval x,y = 875, 800
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Q1. I draw an bound box according to the content object of this swf & saw this bound box is indeed centered. However, the bar object is some offset left from the center of screen. Why it's not aligned center as I saw it in Flash CS4?
Q2. I try to get the screen coordinates of component 'mc' by using localToGlobal to convert it to screen coordinates & draw a box to overlap their top-left point. However the topleft point of box is far left of mc's on screen. I think it's due to the swf is scaled, so I dump scaleX and scaleY of this swf but they are both 1? How can I get correct screen coordinates of mc?
Thanks in advance!
ScottBecause of margins and padding, the Canvas probably won't be positioned at
0,0, so setting its width to screen.width will make it hang over the right
edge. Use width="100%" instead. Same for height.
I believe there is a horizontalAlign property on the SWFLoader. -
How to fix the position of different component?
Hay all,
Can anybody tell how to fix the position of any component so that they cant be moved from there initial positiion
Regards,
Sharad AgarwalSet layout to null and set bounds of the component to whatever you like.
-
How can I tell if my iPad's GPS is even attemping to get a position fix?
MC773LL/A iOS 7.0.4
The main reason I purchased an iPad was to use it as backup for GPS navigation electronics aboard my boat. I've used it several times just to test it, with purchased nav apps, starting from my home port, and everything worked as expected. Recently I didn't power up the iPad until I was at sea but only 15 miles from home port. It could not seem to obtain a position fix, and the GPS arrow indicator did not appear. I had no way of knowing if it was even trying to get a fix. My other GPS devices at least tell me they're trying. Is there some way know if an iPad is even trying to get a first fix? When I returned home, I powered up the iPad and everything worked fine. All the location services settings and others, including wi-fi, were left untouched.
Is there some trick to wake up the iPad's on-board GPS to get it working?
And how would I know that it's activated and trying to get a first fix?
Thanks.My iPad has onboard true GPS. It's Model MC773LL/A
The app is iNavX. The GPS and the app usually work just fine. But, as noted in my original posting, I had an incident where the GPS did not seem to activate. And I could not tell if there was some way to see if it was even trying to get a position fix. The GPS arrow didn't appear. More details in my original posting. My questions remain:
Is there some trick to wake up the iPad's on-board GPS to get it working?
And how would I know that it's activated and trying to get a first fix? -
How to get a position in a string?
I need to get a position in a string like the word CHEESE, where the c is position 1, the h is position 2, the e is position 3 etc... Which input stream should i use and how does it work really?
indexOf(int ch)
Returns the index within a string of the first occurrence of the specified character. -
How to get text position in a pdf?
I need to get text position such has width, height, x, y and base position in a pdf.
Can one help me to work further.i solved PDEForm issue thank you. Now i need to get the text from PDEElement.
Can you help for this?
PDEElement pdeElement;
ASInt32 numElems = PDEContentGetNumElems (pdeContent);
ASFixedRect bBox;
for (ASInt32 i = 0; i < numElems; i++) {
pdeElement = PDEContentGetElem (pdeContent, i);
if (PDEObjectGetType((PDEObject)pdeElement) == kPDEForm)
PDEForm form = (PDEForm)pdeElement;
PDEContent content = PDEFormGetContent(form);
GetCoOrdinate(content);
else if(PDEObjectGetType((PDEObject)pdeElement) == kPDEText)
PDETextState objPDETextState;
PDEText aotextObject;
memset(&objPDETextState, 0,sizeof(PDETextState));
aotextObject = (PDEText)pdeElement;
PDETextGetTextState(aotextObject,kPDETextRun,0,&objPDETextState,sizeof (PDETextState));
if(objPDETextState.renderMode == kPDETextInvisible)
AVAlertNote("Invisible");
else
PDEElementGetBBox (pdeElement, &bBox);
os.str("");
os << ASFixedRoundToInt32 (bBox.top) <<":" << ASFixedRoundToInt32 (bBox.bottom) << ":" << ASFixedRoundToInt32 (bBox.left) << ":" << ASFixedRoundToInt32 (bBox.right);
AVAlertNote(os.str().c_str());
else
os.str("");
os << "Type: "<< PDEObjectGetType((PDEObject)pdeElement);
// AVAlertNote(os.str().c_str());
// Get the bounding box of the PDEElement and fill out the
// selection structure to highlight the image.
PDEElementGetBBox (pdeElement, &bBox);
os.str("");
os << ASFixedRoundToInt32 (bBox.top) <<":" << ASFixedRoundToInt32 (bBox.bottom) << ":" << ASFixedRoundToInt32 (bBox.left) << ":" << ASFixedRoundToInt32 (bBox.right);
//AVAlertNote(os.str().c_str()); -
How to get the position of a tag in XML,when i am using the org.xml.sax
Hi,
I am able to parse a xml document.I want to get the position of a tag in the document.So that by keeping that as reference, i can access other tags.Plz help me.I am using org.xml.sax API.Hello Friends
After research , I could also find another way to check the existence of a node .We can even use CHOOSE to check the existence.
<xsl:choose>
<xsl:when test="(/mynode)">
your action if the mynode is found
</xsl:when>
<xsl:otherwise>
action if mynode is not found
</xsl:otherwise>
</xsl:choose>
Thanks.
Wishes
Richa -
How to get the position of a selected cell in a table ?
Hi,
How can I get the position of a selected cell in a table or in a list multicolumn cmd ?
Thanks.Invoke node >>> point to Row Column
Ben
Message Edited by Ben on 07-19-2007 03:14 PM
Ben Rayner
I am currently active on.. MainStream Preppers
Rayner's Ridge is under construction
Attachments:
Point_To_Row_Column.PNG 22 KB -
Is it possible to get the position of a charcter from a string ?
Hi !
Is it possible to get the position of a charcter from a string ?
Example:
@VAR contains the following text "ABCDEFGHIJKLM"
I'am seaching for FGH, it start on pos. 6 en ends on pos 8.
How can I get these numbers 6 and 8 ?
So, I can use them in the MID(text,start,len) function.
Thanks!Hi Sooraj,
I'll explain more in detail:
From a web-service I get a variable called @Spec.
This variable contains the following:
"MOTORTYPE[CR]D-QW1234[LF]PART[CR]1234-FRD-X[LF]"
or
"MOTORTYPE[CR]ABC[LF]PART[CR]E-435[LF]"
I need the values behind MOTORTYPE[CR] and behind PART[CR]
But youll see that the positions of these values are different each time.
If there is a way to get the (start) position of "MOTORTYPE[CR]" or "PART[CR]" and the (end) position of the first "[LF]" behind that,
then I could use the MID() function to get the correct values.
The values will be displayed in a table view (between other fields).
An ABAP-call/function wont work . . . how should I invoke this within a table column/field object ? (system action ?) -
HELP!! How to get the position of active windows in the desktop
How to get the position of active windows in the desktop
You mean, active windows other than the program you're running, or windows the program puts there? And a real desktop (like where MyComputer is), or a desktop pane?
-
ALV-Grid - Get cursor position
Hi,
I replaced the table control in my dynpro with a custom container and placed an ALV-Grid in there.
So, my problem is now to get the cursor position when the user double clicks at the text in a cell.
It´s important for me to know at which position at the text he double clicked.
e.g.:
| Nr |Text |
|----|-------|
| 1|Hello |
| 2|Test |
The user clicks double between the 'e' and 's' at line 2 ('Test').
I need following information:
line 2
column 2
offset 3 (position, where the user clicked)
When I'm using the table control, it's no problem with
the ABAP-statement 'GET CURSOR' and property 'OFFSET',
but I didn't find a method with the same result for ALV-Grid.
Maybe you know a possibility?
Thank you.
Regards from Germanyhello,
go through these links.these links will surely solve your problem.just have a luk.
Get the cursor position row number in a table control.
upper is for table-ctrl
if you are working with alv.you can achieve it by.
call method cl_gui_control=>set_focus
exporting control = w_grid.
w_grid is ur gid name.
go through this link also
Get cursor position from grid
regards,
Shweta
Edited by: Shweta Joon on Aug 20, 2009 1:15 PM -
Getting the name of the component
How can I get the name of the component at run time. I'm trying to find out the name of components like JTextField. I've already tryed <component>.getName() but it returns null.
Tks
Roberto GarciaThat must be because you didn't ever call the component's setName() method.
Or what did you expect the "name" of the component to be?
Maybe you are looking for
-
Whenever I open a new tab or window the back arrow on the navigation bar doesn't work
When I open a new tab or window the back arrow in the navigation bar isn't highlighted and doesn't work
-
Finder | Move Bug | Does anyone know if Apple is going to fix this ?
I have made a video here: http://de.youtube.com/watch?v=ZEbl0egiujI#GU5U2spHI_4
-
Help! Studio pro 4 stop working since Leopard 10.6.2 OS upgrade.
Has any one got such problem? I even tried reinstalling DVD Studio Pro but it said the installer disk is bad and need a replacement. Do I need a replacement and if so how to get one? Please help!
-
Adobe Flash 11.14 plugin has crashed
I have searched the internet and seen the posts on this site regarding crashes in Firefox, but I have tried all the methods (even though they relate to 11.3 and I have 11.14). My Firefox 14 is up to date and so is flash plugin but it keeps crashing c
-
Can I downgrade my ios from 7.0.3 to 7.0.2?
The problem I had is that ios7.0.3 drain my battery quite a lot compare to 7.0.2. Another thing that makes me want to downgrade is that the 'reduce motion' thing. I very satisfied on what they did on ios7.0.2, which turn of the 3D/ parallax wallpaper