How to get Length in pixel of a String in j2ee??
Hi guys, im having a problem trying to find out how to get pixels from a string length, but in j2ee, i've researched, but everyone said to use Graphics2D, but since im using j2ee, i dont know how to use this.
For example i found this piece of code, but this doesnt work for me:
public void paint(Graphics g) {
Graphics2D g2d = (Graphics2D)g;
Font font = new Font("Serif", Font.PLAIN, 12);
FontMetrics fontMetrics = g2d.getFontMetrics();
int width = fontMetrics.stringWidth("aString");
int height = fontMetrics.getHeight();
How to get g2d, if i dont have a graphics to send it to the method??
I would be really happy if anyone could send me a example using a javabean.
How to do this guys???? please help me with this guys,thanks.
yellr
im working on a good explanation for this question, im trying to send pics of my programso you understand me pretty well. But a general idea, its im creating dynamically components, like labels, textFields, dropDowns, etc. My problem comes when im adding to form the labels, these labels are going to show the descripcion of the component, which it could be a textField, dropDown, textArea etc.
I put all these components on a gridPanel, for each row i can have severals componets,
I have a gridPanelGeneral which have all other gridPanels, this gridPanelGeneral have gridPanelRow+"numRow"
This gridPanelRow+"numRow" can have severals components which show like columns.
Sincerely i would like to put pictures of the program, so that way you will understand my problem, i need to set the label.setStyle(width:"+numPixelesOfDescriptionOfComponent+"px). To put these labels well, because the user cant see very well the description of the component when i have severals components, each component does have a label for its description. descriptionOfComponent is a string thats why i need to get the pixels of the string.
One question, how do i do put pics on this forum??
Edited by: yellr on Oct 30, 2007 9:56 AM
Similar Messages
-
How to get length of a data field
Hi Experts,
How to get length of a data field. For example data field /BIC/0COSTCENTER length is 9. and the entry in the table is /BIC/0COSTCENTER = 1000 only. How to get the lenth of value in the table.
Any help greatly appreciated. Thanks.
Best Regards,
Suresh.Below is example code
Data: var1(10) type c value '2500',
var2 type i.
var2 = Strlen( var1 ).
write var2.
<b>Reward Points for helpful answers</b>
Satish -
How to get length of data on column with long datatype
How to get length of data on column with long datatype without using pl/sql block
...another reason not to use LONG datatype for columns.
Oracle advises to switch to LOB columns instead
SQL> create table t
2 (x long)
3 /
Table created.
SQL> insert into t values (rpad ('x', 10000, 'x'))
2 /
1 row created.
SQL> alter table t
2 modify x clob
3 /
Table altered.
SQL> desc t
Name Null? Type
X CLOB -
Length in pixels of a string in J++
Hi,
This is probably very simple but I can�t figure out how to get the length in pixels of a string.
The length function just returns the amount of characters!
i.e. String temp = �Nick�;
int len = temp.length;
len would equal 4.
Thanks in advance
BoomahIt may or may not be simple since you use J++.
In Java it would go getFontMetrics().getStringWidth("string") (assuming you work with a class that extends some component class) -
Hello!
I've a little pb and expect than the java specialist of this forum can be able to solve my trouble!
I get a String[] from a BD and would like to generate some javascript to create a menu. For this menu, i need the length in pixel of the greater String of my menu. I don't find anything to be able to compute this length with the J2EE API. Does anyone know how to solve my problem??
You are all great to used of your time to respond to my question.
Thanks.So, due to the fact that none java specialist can
quickly solve my pb, i suppose that without using
FontMetrics or any kind of graphics features from
java, there are no way to compute a such length for a
String??If you really want all the java specialists to get a chance to answer your question, you should wait 24 hours, because many java specialists live in other parts of the world and are still sleeping. -
How to get these substrings based on the string entered
Hi friends
i want the substring entered in the string
the string is something like this: 1234,3653,7684,3254,8777,987,234
now i want
the substrings between commas
can some one help me with it pls
in the first substring i need 1234
in the second i need 3653...
so on till the end..
what ever the string be until the last one
pls helpHi,
You can do something like this:
SELECT txt
, REGEXP_SUBSTR (txt, '[^,]+', 1, 1) AS part_1
, REGEXP_SUBSTR (txt, '[^,]+', 1, 2) AS part_2
, REGEXP_SUBSTR (txt, '[^,]+', 1, 3) AS part_3
FROM table_x
;If there are fewer than n parts, then the technique above will not raise an error; it will just return NULL for part_n.
I hope this answers your question.
If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only), and the results you want from that data.
Explain how you get those results from that data.
What do you want if the input is like this"
{code}
'foo,,bar'
{code}
? Do you want to consider this as 2 parts ('bar' is the 2nd) or a s 3 (the 2nd is NULL, and 'bar' is the 3rd)? Include examples in your sample data and results.
Always say what version of Oracle you're using. -
How to get Length of Editable Field greater than 10 using ALV_GRID_DISPLAY
Hi Experts,
I am Using , REUSE_ALV_GRID_DISPLAY_LVC For Displaying an ALV Report .
Now i'm Using Few fields in Editable mode , but the problem is that , the length of those, editable fields is restricted only to 10 characteras.
But i need a editable field with length of 20 chars , ,for, entering some remarks..Is it possible ?
Can anyone, help how to do that ..?
Thanx in Advance ..
Regards,
Rajeshyou can make use of INTLEN
set the value to 20 and then you can enter to 20 chars.
FIELDCAT-INTLEN = 20.
FIELDCAT-OUTPUTLEN = 20. -
How to get length and width of a textbox or image box and display on a dialog
Hi,
When I draw a textbox or frame on a document, and If I select it then I want to display its length and width on a dialog.I am not able to solve it, Can anybody help me ?
Can u suggest some sites or online books about Indesign plugin development programming using c++.
Thanks,
Ravi SharmaThanks Schneider. It was very helpful.<br /><br />As I am new to Indesign CS3 SDK programming. <br /><br />I am not able to understand the syntax of this programming ,<br /><br />How to use InterfacePtr.<br /><br />For eg:<br /><br />InterfacePtr<IClassIDData> orgDocFileHandlerData(doc, IID_ORGICLASSIDDATA); <br /><br />Can u please explain me this and suggest some good sites/online books <br /><br />about Indesign CS3 SDK programming for Windows and Mac.<br /><br />Thanks n Regards,<br /><br />Ravi Sharma
-
KM: How to get length and substring?
I write my own IKM and I need detect long string and cut them.
I try to use
<%=odiRef.getTable("L","TARG_NAME","A").length() %> --> returns value: 70 (!) , but real length is 25 (perhaps returned buffer size).
Any ideas?This is not correct code
if (tname.length() > 25)
tname=tname.trim().substring(0);
Because,after
tname = snpRef.getTable("L","TARG_NAME","A");
ODI put into tname <?=snpRef.getObjectName("L", "<table name>", "<schema>", "", "D") ?>. This code will be evaluate on execution.
tname.length() is equal to "<?=snpRef.getObjectName("L", "<table name>", "<schema>", "", "D") ?>".length() and return 70.
I parse <?=snpRef.getObjectName("L", *"<table name>"*, "<schema>", "", "D") ?> and resolve my problem:
<%
var s=snpRef.getTable("L", "TARG_NAME", "A");
var pos1 = s.indexOf('"', 0);
var pos2 = s.indexOf('"', pos1 + 1);
var pos3 = s.indexOf('"', pos2 + 1); // 3-td quote pos
var pos4 = s.indexOf('"', pos3 + 1); // 4-th quote pos
var targ_name = s.substring(pos3 + 1, pos4);
And now, targ_name.length() and targ_name.substring(x,y) return correct values.
%>
Edited by: Aikon on 29.11.2012 1:59 -
How to get XMP MetaData as an XML String in a process?
Hi there,
I have a process where I would like to export a documents XMP MetaData, manipulate the XMP MetaData and then import the MetaData again to the document.
I thougt first I will use the service Name "XMPUtilityService" with the Service Operation "Export XMP" to export the XMP MetaData as a document.
Hoewer I am not sure how to manipulate the output document from the Export XMP service.
When I print out the document.toString() in a execute Script Service I get the following:
<document state="active" senderVersion="0" persistent="false" senderPersistent="false" passivated="false" senderPassivated="false" deserialized="false" senderHostId="null" callbackId="0" senderCallbackId="0" callbackRef="null" isLocalizable="true" isTransactionBound="false" defaultDisposalTimeout="600" disposalTimeout="600" maxInlineSize="65536" defaultMaxInlineSize="65536" inlineSize="3440" contentType="null" length="-1"><cacheId/><localBackendId/><globalBackendId/><senderLocalBackendId/><senderGl obalBackendId/><inline><?xpacket begin="" id="W5M0MpCehiHzreSzNTczkc9d"?>
<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="A...</inline><senderPullServantJndiName/><attributes/></document>
Actually I expected something like this:
<?xpacket begin="" id="W5M0MpCehiHzreSzNTczkc9d"?>
<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="Adobe XMP Core 5.0-jc006 DEBUG-1.0, 2009 Jun 23 11:07:21-PDT">
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<rdf:Description rdf:about=""
xmlns:pdf="http://ns.adobe.com/pdf/1.3/">
<pdf:Producer>Adobe LiveCycle PDF Generator ES2</pdf:Producer>
</rdf:Description>
<rdf:Description rdf:about=""
xmlns:xmp="http://ns.adobe.com/xap/1.0/">
<xmp:ModifyDate>2010-04-20T20:43:59+02:00</xmp:ModifyDate>
<xmp:MetadataDate>2010-04-20T20:43:59+02:00</xmp:MetadataDate>
</rdf:Description>
<rdf:Description rdf:about=""
xmlns:xmpMM="http://ns.adobe.com/xap/1.0/mm/">
<xmpMM:DocumentID>uuid:0cf2c6c6-2fba-2b39-5fb6-33ad8ccf58aa</xmpMM:DocumentID>
<xmpMM:InstanceID>uuid:187bc5a2-acb0-2fa9-711d-33ad8ccf58aa</xmpMM:InstanceID>
</rdf:Description>
</rdf:RDF>
</x:xmpmeta>
<?xpacket end="w"?>
What do I need to do to get the XMPMeta data as an XML String from a document within a process?
Thanks in advance!
PaulHi,
thanks for the answer.
I know that I can retrieve the XMPUtilityMetadata object, but this object provides only access to a few information suche as creator, subject, producer, etc.
However I would like to retrieve the whole XML String of the XMP Metadata.
How is this possible?
Thanks.
Paul -
How to get int value from [session.getAttribute("String")]
i am not able to get int value from the following statiment
int i=session.getAttribute("String");
i also try by casting it into int but it dont work, can somebody help me in this regardabuu wrote:
i am not able to get int value from the following statiment
int i=session.getAttribute("String");
i also try by casting it into int but it dont work, can somebody help me in this regard
Integer i=(Integer)session.getAttribute("String");
i.intValue();but know how it is working. that is useful.
Diablo. -
How to get a single quote in a string
this is my code, how do i get a * ' * around the :p2_marketingcode so that the result will be
and marketingcode_id LIKE 'SP09663'
i tryed something like this ||'''||:p2_marketingcode||''';
if :p2_marketingcode is not null then
q:=q||' and marketingcode_id LIKE '||:p2_marketingcode;
end if;Try:
if :p2_marketingcode is not null then
q:=q||' and marketingcode_id LIKE '''||:p2_marketingcode||'''';
end if; -
How to get the MD5 value of a string
Ok, I'm haveing a bit of a problem with a login for a website I'm building.
So I set users up in a mysql datebase with a user name and password. the password is put into an MD5 hash table so Password = 8569854hth75t56ht8ygt89 or some crazy string.
"INSERT INTO passTable( Username, Password ) VALUES ('"+Username +"', MD5('"+Password+"'))";But I'm having trouble when the user puts in there Password as a string in a HTML form that goes to a servlet, how do I turn the string "Password" into a value such as "8569854hth75t56ht8ygt89" in order to compare it to what I have in the datebase????
Any ideas? P.S i'm not a very good programmer at all.[url http://java.sun.com/j2se/1.4.2/docs/guide/security/CryptoSpec.html#MDEx]http://java.sun.com/j2se/1.4.2/docs/guide/security/CryptoSpec.html#MDEx
from
[url http://java.sun.com/j2se/1.4.2/docs/guide/security/CryptoSpec.html]http://java.sun.com/j2se/1.4.2/docs/guide/security/CryptoSpec.html
should get you started. -
How to get Sum for my Elapse Time string for my group
Hi,
How can I get the sum of an elapse time string in my group footer 2 and group footer 1 from the report screenshot attached.
I have a report that display TimeIn and TimeOut of an employee.
For the total time I have created a formula that will take my time in seconds and displaying it in hrs, minutes and seconds.
How can I get the sum of all the total time per day and display this in my group footer 2.
As well I will need to add the grand total to group footer 1 for the total of days.
The formula I have for the total time is as follow:
WhileReadingRecords;
NumberVar TotalSec := {TimeLogs.TotalTime};
NumberVar Hours := Truncate (Remainder ( TotalSec , 86400) / 3600) ;
NumberVar Minutes := Truncate (Remainder ( TotalSec , 3600) / 60) ;
NumberVar Seconds := Remainder (TotalSec , 60) ;
Totext ( Hours , '00' ) + ':' +
Totext ( Minutes , '00' ) + ':' +
Totext ( Seconds , '00' )
This is a seperate question below but related as well to this report.
Another question I have is how can I round up for example 03:30:58 to 03:31:00
And also how can I round down for example 03:26:10 to 03:26:00
Any help would be appreciated.
Thank you,
JoeHi Jamie,
Well I ran into an issue with this. My Daily Total, there is no issue, it is displaying the proper time. But when I add a summary to my Group Footer 1, it doesn't add up properly.
If I select only 1, 2, or 3 days my Date Range Total is adding fine but when selecting 5 days for example, as you can see from the picture below, for an unknowned reason the total of hrs is wrong.
Do you know why this is happening.
Than you for your help.
Joe
Picture below, this is working fine? -
HOw to get a common substring from two strings.
Hello,
I have a question like..how to print a common substring in to different strings.
example: String str1="dynamic" String str2="programing" so the output for this application is "am".If the OP is looking for the 'longest common substring', have a look
here for a nice explanation of Ukkonen's online suffix tree construction.
A suffix tree is the ideal data structure for finding a LCS.
kind regards,
Jos
Maybe you are looking for
-
What is the latest and hottest in SAP jobmarket?
Found a different place to put this thread. sorry for the confusion. Please let me know if i can delete this thread..
-
Reset and reverse for various vendor groups.
Hello, We have two distinct vendor groups. For Group A there is no tax implications. For Group B withholding tax is mandatory. When we are trying to run TCode FBRA for the Group A vendors, we find that it's giving me the option of 'Reset' and 'Reset
-
Is there any limit of character that can be sent as body of the mail ?
Hi, we are in exchange 2010 server environment. Is there any limit of character that can be sent as body of the mail ? Sankar M http://messagingdevelopment.blogspot.in/
-
The newest version of Firefox is not supported by my laptop.
I inherited a MacBook that runs Mac OS X version 10.4.11. Today, I downloaded Firefox, but when I tried to launch the program, it said that Firefox is not supported for my computer. I searched for an older version of Firefox, but could not find any,
-
V$SYSMETRIC values and login username/SID/servicename/hostname.
Hi all, Does the values in V$SYSMETRIC depend on the login username/SID/servicename, or is it just the hostname that matters? Regards, Alex