Absolute Position of Component
hi!
i'm currently creating a formvalidator.
is a field-validation failed, the validator paints a small red dot on the glasspane over the lower left corner of the field/component.
my problem now is the following:
is the component i want to validate in a container, the getLocation()-method of the component does not give me the absolute position of the component... so my red dot is painted on the false position.
does anybody know how i could get the absolute position of my component? (absolute; relative to my topcontainter, the JFrame or the JDialog)
thx a lot!
greetz
swissManu
Hi,
have a look here :
http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/SwingUtilities.html#convertPoint(java.awt.Component,%20int,%20int,%20java.awt.Component)
it should permit you converting coordinates relatively to anything ;-)
Nico
Similar Messages
-
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 do i add a Scroll Bar to a JList Component using absolute positioning?
I've got a applet whose content pane is set to null. I've create a jlist component on this applet and using absolute positioning set the bounds at
ListBox1.setBounds(380,10, 500, 500);.
My problem is creating add a scroll bar to the list box.
JScrollPane scrollPane = new JScrollPane(ListBox1);
C.add(scrollPane);
The above code is what i use and when i run this applet i don't see the list box at all. How do i add a scrollbar to this list box or JList component. Please help.You need to setBounds() on the JScrollPane, not the JList.
The JScrollPane is the component that is being added to the panel. -
What does 'absolute' for the position attribute of a component mean?
And what others possible values?
Regards,
Marlos Rodrigues.It's a standard CSS2 property.
http://www.w3.org/TR/CSS21/visuren.html#absolute-positioning
-- Tor
http://blogs.sun.com/tor -
Find browser or applets absolute position
Hi,
I am designing an applet where I open a number of small pop up windows at the beginning of the applet. Users of this system have two monitors, thus I need to determine where they have positioned the browser so that the windows will open above the browser. At the time the windows open there is nothing else on the screen so getLocation doesn't work.
If I can determine the absolute position of the applet this would also do.
All help would be greatly appreciated.I use the following to get a reference to a Frame which I pass to a JDialog constructor to ensure that the Dialog is always centred over an Applet no matter where the Applet is positioned on screen. Maybe you can adapt it for your needs.
public Frame getDialogFrame()
/* creates and positions a Frame used by dialogs
* to ensure that dialog is modal and centred over the Applet
Object parent = this.getParent();
while(!(parent instanceof Frame))
parent=((Component)parent).getParent();
Frame dialogFrame = (Frame) parent;
Point p = this.getLocationOnScreen();
dialogFrame.setLocation(p.x, p.y);
return dialogFrame;
} -
Page footer absolute position issue - Crstal Reports
Hi,
I have a page footer section in the crystal report.
There are 2 sections Page footer A and Page footer B.
Here I am displaying Page Footer A in the first page and Page Footer B on all the pages.
Here the issue is, as I applied a suppress condition on page footer A in order to display only on frist page. This is working fine. But in the second page the page footer B is displayed a bit above the end of page as the page footer A is suppressed.
Can we set absolute position for page footer B? So that, the page footer B will be displayed at the same way in all the pages as like the first page.
Thankyou,
Regards
Gowtham Sen.Hi All,
The issue got resolved. I used the option underlay. It worked well.
Thanks. -
Box model/none absolute positioning with flash
In recent years none-absolute positioning (or box model positioning) has become the norm with HTML/CSS
this is uselfull for dynamic functions which appear on an event (such as an object which appears when a button is clicked on or a error message that appears when a form box is given invalid input because it automatically inserts itself it the right place.)
One very important example of this is when you have a form which automatically produces an error message and the error message appears bellow the input area which caused it and the rest of the page is pushed down.
With none absolute positioning the developer does not need to worry about this.
But if the objects are given absolute position then it becomes a massive problem, the developer has to go about giving the objects differetn positions dependant on if dynamic objects appear or not
potentially the developer has to consider all possible variables, and code if statements which determine the position of all static objects for all possible variables which dynamic objects could take.
so does flash have a "none absolute positioning" solution to this problem.Before you get all happy and pleased with yourself, APDivs or Layers seldom work well as a primary layout method. Here are some reasons why:
http://apptools.com/examples/pagelayout101.php
You're much better off using default CSS positioning (which is no positioning at all) along with CSS margins, padding and floats. If you don't believe me, check your page in non-IE browsers with increased/decreased text-sizes (zoom, text only).
From Tables to CSS Web Design Part 1 -
http://www.adobe.com/devnet/dreamweaver/articles/table_to_css_pt1.html
Nancy O.
Alt-Web Design & Publishing
Web | Graphics | Print | Media Specialists
http://alt-web.com/
http://twitter.com/altweb
http://alt-web.blogspot.com -
Many comments have been made elsewhere about the wisdom of
using 'absolute', particularly when a crossbrowsers are considered
and user's adjustment of text size..to quote one problem...
So, in order to eliminate these glitches from my pages, I
should apparently convert to 'static'..
What would be the steps to take to accomplish this without
too much hassle. I do have a lot of CSS code, which, I guess, when
adjusted would take care of some of the problems.
Is there a tutorial/publication which deals with this
procedure?Any element without an explicit positioning style is static,
by default,
e.g.,
<html>
<head>
</head>
<body>
<div>This is a static div</div>
<p>This is a static paragraph</p>
</body>
> So, in order to eliminate these glitches from my pages,
I should
> apparently
> convert to 'static'..
That's a gross oversimplification. You should re-design your
layout so that
the page elements are placed on the page as dictated by THE
NORMAL FLOW,
mediated through the CSS rules. Simply taking a page that has
been designed
using absolutely positioned elements, and converting the
absolute position
to static position (by removing the positioning altogether)
will most likely
not work very well. I think you understand this, but I'm not
sure.
> I do have a lot of CSS code
This, too, is a bit troubling. Having a lot of CSS often
means inefficient
use of rules and selectors.
In general, you don't need many custom classes. And, in fact,
they
make your life more difficult when you come back to maintain
the page a year
later. Use ID selectors and create descendent selector rules.
An example -
#maintable { .... }
#maintable td { .... }
#maintable td table { ... }
each of those rules would apply explicitly to a) this table -
<table id="maintable">,
and b) this cell -
<table id="maintable">
<tr>
<td>...</td>
</tr>
</table> (and all others in that table),
and to this table -
<table id="maintable">
<tr>
<td>
<table>
<tr>
<td></td>
</tr>
</table>
</td>
</tr>
</table>
Then you could use this rule -
#maintable table td.special { .... }
to apply to this cell explicitly -
<table id="maintable">
<tr>
<td>
<table>
<tr>
<td class="special">this one</td>
<td>but not this one</td>
<td class="special">this one</td>
<td>but not this one</td>
</tr>
</table>
</td>
</tr>
</table>
Also, it is not necessary to define default styles, e.g.,
font-weight:normal, unless you are trying to counteract some
cascading rule.
Further, it is not necessary to define styles that are
normally inherited,
e.g.,
body { font-family: Calibri, verdana, arial, helvetica,
sans-serif; }
will style all characters used on the page, no matter where
they are located
or in which container.
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.projectseven.com/go
- DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs,
Tutorials & Resources
==================
"Karlhevera" <[email protected]> wrote in
message
news:[email protected]...
> Many comments have been made elsewhere about the wisdom
of using
> 'absolute',
> particularly when a crossbrowsers are considered and
user's adjustment of
> text
> size..to quote one problem...
>
> So, in order to eliminate these glitches from my pages,
I should
> apparently
> convert to 'static'..
> What would be the steps to take to accomplish this
without too much
> hassle.
> I do have a lot of CSS code, which, I guess, when
adjusted would take care
> of
> some of the problems.
> Is there a tutorial/publication which deals with this
procedure?
>
> -
Use incremental rotary encoder to measure the absolute position and velocity
Hi all,
I faced a problem by using incremental rotary encoder to measure the absolute position of the rotation.
I'm not using NI-Daqmx but NI-motion module. In NI-motion module, I use read encoder position.vi to read the position of the encoder.
However, the readings is in incremental form. I'm doing the feedback control, so I need the absolute position and velocity.
Is there any functions or vi in the labview that can be used to transform the information of incremental encoder to the absolute one?
Thanks
Jun WongJun,
1. The incremental encoder provides incremental position. After switching on the encoder power the encoder counts upwards or downwards. For the absolute position you need the index (R or I) signal. I don't know which type of incremental encoder you have but there should be A, B and (I or R) signals. The index signal should reset the counter to zero setting this way a pseudo-absolute-position (which is lost after the first switch of). Most of the motion controllers have a mode, just after switch on, in which the controller search for the Index. This mode is called Homing.
2. Velocity. It's very simple. You sample the position with a fix sampling clock. Let's say: 10kHz. The speed is: (Actual Position - Previous Position) / Sampling Period. Pos[n] = 10.000inc, Pos[n-1] = 9.900inc. Speed = 10.000 - 9.900 / (1/10kHz) = 1.000.000 inc/sec. If one increment is 0.0001mm then the speed is 100mm/sec.
Paul -
Can Layers be given RELATIVE, rather than ABSOLUTE position
I'm having no luck finding an answer to this in HELP. I place
the layer's anchor in a table, then position the layer. If I
subsequently add (or remove) any lines above the anchor, everything
on the page moves down (or up), but the layer stays where it was,
relative to the page, not the anchor.
If there are several layers on the page this means a wholeot
of repositioning every time I do an edit up-page.
Any advice?This may help you understand positioning a bit -
There are 4 different types of positioning:
Absolute
Relative
Fixed
Static
Here is a brief explanation of each kind of positioning (with
regard to
placement of elements on the page only)....
Position:absolute (or A/P elements)
This does several things -
1. It 'removes' the element from the flow of the code on
the page so that
it can no longer influence the size or position of any other
page element
(except for those contained within it, of course).
2. The absolutely positioned element takes its position from
the position of
its closest PARENT *positioned* element - in the
absence of any explicitly
positioned parent, this will default to the <body> tag,
which is always
positioned
at 0,0 in the browser viewport.
This means that it doesn't matter where in the HTML code the
layer's code
appears (between <body> and </body>), its
location on the screen will not
change (this assumes that you have not positioned the A/P
element within
a table or another A/P element, of course).
Furthermore, the space in
which
this element would have appeared were it not positioned
is not preserved
on the screen. In other words, absolutely positioned elements
don't take
up any space on the page. In fact, they FLOAT over the page.
Position:relative (or R/P elements)
In contrast to absolute positioning, a relatively positioned
page element is
*not* removed from the flow of the code on the page, so
it will use the
spot
where it would have appeared based on its position in
the code as its
zero point reference. If you then supply top, right,
bottom, or left
positions
to the style for this element, those values will be
used as offsets from
its
zero point.
This means that it DOES matter where in the code the
relatively positioned
element appears (, as it will be positioned in that location
(factoring in
the offsets) on the screen (this is true for any placement in
the code).
Furthermore, the space where this element would have
appeared is
preserved in the display, and can therefore affect the
placement of
succeeding elements. This means that the taller a relatively
positioned element is, the more space it forces on the page.
Position:static
As with relative position, static positions also "go with
the flow". An
element with a static position cannot have values for
offsets (top, right,
left, bottom) or if it has them, they will be ignored. Unless
explicitly
positioned, all div elements default to static positioning.
Position:fixed
A page element with this style will not scroll as the page
content scrolls.
Support for this in elements other than page backgrounds is
quirky
There are several other things you need to know:
1. ANY page element can be positioned - paragraphs, tables,
images, lists,
etc.
2. The <div> tag is a BLOCK level tag. This means that
if it is not
positioned or explicitly styled otherwise, a) it will always
begin on a new
line on the screen, and b) it will always force content to a
new line below
it, and c) it will always take up the entire width of its
container (i.e.,
width:100%).
3. The placement of A/P elements *can* affect the BEHAVIOR of
other
elements
on the page. For example, a 'layer' placed over a hyperlink
will mask that
hyperlink.
You can see a good example of the essential difference
between absolute and
relative positioning here -
http://www.great-web-sights.com/g_layersdemo.asp
You can see a good demonstration of why using layers for a
page layout tool
is dangerous here -
http://www.great-web-sights.com/g_layer-overlap.asp
Based on this, a static div (no longer a 'layer') would be
what you want.
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com
- Template Triage!
http://www.projectseven.com/go
- DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs,
Tutorials & Resources
http://www.macromedia.com/support/search/
- Macromedia (MM) Technotes
==================
"bwilsonduncan" <[email protected]> wrote in
message
news:[email protected]...
> I'm having no luck finding an answer to this in HELP. I
place the layer's
> anchor in a table, then position the layer. If I
subsequently add (or
> remove)
> any lines above the anchor, everything on the page moves
down (or up), but
> the
> layer stays where it was, relative to the page, not the
anchor.
>
> If there are several layers on the page this means a
wholeot of
> repositioning
> every time I do an edit up-page.
>
> Any advice?
> -
How to get the caret position of component embedded in JTextPane?
Hi great java developers ;-)
I want to get the caret position of component which is embedded in StyledDocument / JTextPane.
How has it to be done?
Thank you very much!!!The Document doesn't know which textPane it belongs to. (It could even be shared by mulitple textPanes).
You get the caret position of a any text component by using:
textComponent.getCaretPosition(); -
Position of component buttons off artboard
Does Flash Catalyst support positioning of component buttons off the artboard? I have an image that I would like to scroll with a vertical scroller and then embed external url click links. The page that I'm working on is here in the portfolio section:
http://facetmedia.com/new/
The image is scrolling but the buttons are locked in one position. Any help on making the buttons scroll with the image would be appreciated.Hi trancepriest,
Can you give us some additional info on how you've structured your Catalyst project? The scrolling area is a Data List, I assume. If you double-click to edit the list and then double-click again to edit the Repeated Item, what do you see? If you place both an image and your row of buttons inside here, then each image and its corresponding buttons should scroll in lockstep together.
Or do you only want one set of buttons total, not one per image? If so, I'm confused about the behavior you're looking for -- if the buttons are not associated with any one specific image, which image would they sit on top of / next to?
- Peter -
Adding a Layer (absolute position div) to a locked page
Maybe I am just not understanding templates but I have a
really simple one that has one editable region called "content". I
want to add a absolute positioned div to the content area but DW
tells me this would require changing code that is locked by the
template. I thought that the editable area automatically put in by
DW would accommodate the added code (css) that DW puts in when
adding a template to the page.
So what is the Editable area called "Head" used for anyways
if not for situations like this?
ThanksHere's the problem with layers in template child pages, and a
simple
solution.
When you DRAG a layer onto the page in DW (this means you
click on the layer
icon in the Insert Toolbar and drag the layer on the page),
DW wants to put
the code for that layer immediately under the body tag, e.g.,
BEFORE DRAG -
<body...>
<table>
AFTER DRAG -
<body ...>
<div id="foo" style="position:absolute; ...>LAYER
STUFF</div>
<table>
In a template child page, this region is usually not part of
your editable
region, and so the layer's code is rejected by the template
engine. This is
a bad thing.
If instead of dragging the layer onto the page, you use
INSERT | Layer, that
should work provided your cursor is in an editable region,
but since
editable regions are usually within tables or other layers,
you have just
broken one of the rules listed above. This is also a bad
thing.
THE SOLUTION -
Open your template page in DW, and create a special place
where it is SAFE
to put your layers. In code view, find this -
</body>
and click so that your cursor insertion point is just to the
left of
</body>.
Now, use INSERT | Template Objects > Editable Region, and
name this region
"Layer Pad" or something like that.
When you save your template page, all your child pages will
now have the
LayerPad editable region on them.
THE BIG FINISH -
On any child page where you need a layer, just click in this
editable
region, and use INSERT | Layer. Bada bing, bada boom.
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com
- Template Triage!
http://www.projectseven.com/go
- DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs,
Tutorials & Resources
http://www.macromedia.com/support/search/
- Macromedia (MM) Technotes
==================
"htown" <[email protected]> wrote in message
news:[email protected]...
> Maybe I am just not understanding templates but I have a
really simple one
> that
> has one editable region called "content". I want to add
a absolute
> positioned
> div to the content area but DW tells me this would
require changing code
> that
> is locked by the template. I thought that the editable
area automatically
> put
> in by DW would accommodate the added code (css) that DW
puts in when
> adding a
> template to the page.
>
> So what is the Editable area called "Head" used for
anyways if not for
> situations like this?
>
> Thanks
>
> -
Rendering bug with absolutely positioned button tags
I'm using Firefox 10.0.1 and I've found a bug regarding button elements that are absolutely positioned. The problem is setting both the right and left CSS attributes does not affect the width of the button as it should.
Here is some example code to show what I mean (the forum is mangling the html, hopefully you can get the gist of it):<br />
<br />
<pre><nowiki><html>
<body>
<div style="width: 500px; position: relative;">
<button style="position: absolute; left: 0; right: 0;">Test</button>
</div>
</body>
</html></nowiki></pre>
In all other browsers the button will be 500px wide. In Firefox, it will fit to the text.Why don't you give that button a width:100% if you want it to take the full width of that DIV container?
-
Problem with Absolute Positioning
I have a LARGE number of web pages (>1500) that have fields that are absolutely positioned. I have to process these pages (JSPs) and create a temporary HTML file that will be edited in Dreamweaver. The editing will only modify the CSS file: the temporary HTML is throw-away.
The goal is to use Dreamweaver to organize fields on the screen and have it modify only the position in the CSS.
My problem is that when I create the temporary HTML, it looks fine in the browser, but Dreamweaver displays the elements using a normal flow, and not using the absolute position. I have checked the "AP Elements" tab in DW, and it shows all my fields and the "Prevent overlaps" checkbox is UNCHECKED.
Any guidance will be appreciated...
Here is a small HTML example (CSS below that):
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>CL0350</title>
<link rel="stylesheet" href="example.css">
<style type="text/css">
body {
background-color: #efe;
#formContainer {
width: 802px;
height: 564px;
font-family: Arial, Helvetica, sans-serif;
font-size: 11px;
font-weight: bold;
border: 3px #444 solid;
background-color: white;
position: relative;
</style>
</head>
<body>
<div id="formContainer">
<div id="lblEPP_MEMBER_NBR">Member#</div>
<div id="lblEPP_YMDRCVD">Recv Dt</div>
<input id="txtEPP_MEMBER_NBR"><input id="txtEPP_YMDRCVD"></div>
</body>
</html>
And finally, the CSS:
#lblEPP_MEMBER_NBR
white-space:nowrap;
POSITION:absolute;
left:17px;
top:43px;
#txtEPP_MEMBER_NBR
POSITION:absolute;
LEFT:17px;
TOP:62px;
WIDTH:110px;
#lblEPP_YMDRCVD
white-space:nowrap;
POSITION:absolute;
LEFT:542px;
TOP:43px;
#txtEPP_YMDRCVD
POSITION:absolute;
LEFT:542px;
TOP:62px;
WIDTH:92px;Ahh - nevermind. I see you fixed your code.... Now I'll take a look.
On this page in DW, the fields seem to be placed using the absolute positioning, not the normal flow. Is the additional CSS contained in the externally linked CSS file?
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>CL0350</title>
<link rel="stylesheet" href="example.css">
<style type="text/css">
body {
background-color: #efe;
#formContainer {
width: 802px;
height: 564px;
font-family: Arial, Helvetica, sans-serif;
font-size: 11px;
font-weight: bold;
border: 3px #444 solid;
background-color: white;
position: relative;
#lblEPP_MEMBER_NBR
white-space:nowrap;
POSITION:absolute;
left:17px;
top:43px;
#txtEPP_MEMBER_NBR
POSITION:absolute;
LEFT:17px;
TOP:62px;
WIDTH:110px;
#lblEPP_YMDRCVD
white-space:nowrap;
POSITION:absolute;
LEFT:542px;
TOP:43px;
#txtEPP_YMDRCVD
POSITION:absolute;
LEFT:542px;
TOP:62px;
WIDTH:92px;
}</style>
</head>
<body>
<div id="formContainer">
<div id="lblEPP_MEMBER_NBR">Member#</div>
<div id="lblEPP_YMDRCVD">Recv Dt</div>
<input id="txtEPP_MEMBER_NBR"><input id="txtEPP_YMDRCVD"></div>
</body>
</html>
Maybe you are looking for
-
Is the 27" iMac display exactly the same as the 27" ACD?
I'm looking at updating my existing set up and want to know whether the above displays are exactly the same. From memory the ACD's were usually of a better quality compared to the iMac displays. Have they achieved parity now? Where will I find full
-
Fonts still missing after installation?
I have a few files that I received to work on that came from a third party company that created them originally. When opened Illustrator gave the message that several fonts were missing. I purchased the missing fonts (or so I thought), installed th
-
Still getting errors when I try to render
I've been working on a title and last week when i went to render I got an error message saying: "After Effects error: crash occurred while invoking effect plug-in "Shatter". then followed by a second message "After Effects error: Crash in progress.
-
Installation Error Java Not Started
Dear All I facing Problum installation BIW 7.0 IDES System Its Give Error Please Suggest Me For This dev_disp File trc file: "dev_disp", trc level: 1, release: "700" sysno 00 sid BWI systemid 560 (PC with Windows NT) relno 7000 pat
-
Mac user: FTP login pw not saved
I tried posting this to another topic that was posted by a PC user, am concerned it will get buried. I'm a Mac user and having this same annoying FTP login issue. I don't have IE7 (can't, thank you Microsoft) and had no problems in MX, only after upg