How to get the size of 'MyComponent' when it is used in another place ?
'My component' is JPanel based ( for example)
I find problems to use the real size of MyComponent ( the size it has at the destiny)
In 'Initialize' this.getheight gives me the size of the component by itself
Must I use 'paintComponent' to know the real size or where ?
By other side, must I count 2 paintComponent() ( the first 2 times paintCompnent is called by the 'system' , one for width and one for height ) to make sure the component is already drawed ?
Thank you
Yes, very simply :
import javax.swing.JPanel;
import java.awt.Rectangle;
import javax.swing.JLabel;
public class Wdes extends JPanel {
private static final long serialVersionUID = 1L;
private JLabel jLabel = null;
public Wdes() {
super();
initialize();
private void initialize() {
jLabel = new JLabel();
jLabel.setBounds(new Rectangle(8, 45, 268, 24));
jLabel.setText("hello : mi size at destiny container is :");
this.setLayout(null);
this.setSize(300, 117);
this.add(jLabel, null);
public void paint(Graphics g) {
System.out.println("paint"+this.getWidth()+ " "+ this.getHeight());
public void paintComponent(Graphics g) {
System.out.println("paintcomponent"+this.getWidth()+ " "+ this.getHeight());
}As you can see I have A Jlabel : jLabel.setText("hello : mi size at destiny container is :");
Ok, I put this bean onto my application and I give it the size desired.
I can use paint or paintcomponent to know my real size , isn't it ? ( and please forget my initial condition of 2 paint events ... -simply I come from VB ...- )
Is there another way ?
And, I dont know what is happen but in this example only work paint ( paintComponent does not )
( If i want to use paintcomponent I have to delete paint , isn't it ? )
Thanks
Similar Messages
-
How to get the size of a hard disk?
Hi,
As above, how to get the size of a hard disk by using Java.
Thanks you!
AlexI would be interested in the answer of this question, too.
In core Java there is no way to find it out in a platform independent manner because of the hardware abstraction of the VM. So my only idea is to write a native library for doing this and colling it via JNI -
How to get the size of driver[C: or D:]
Hi Friends,
I have a query regarding to java..
I want to get the name of all the drives that r connected to the System including network drives...
and how to get the size of any system drive[For example C: or D: Drive].
I want the output to be displayed like in the following format
Device type size free Usage_Space
for ex.
C: NTFS 37.5Gb 30.5gb 7gb
Output like as linux command df -h
Edited by: KituPrash on Mar 4, 2009 3:29 AMDoes this help for starters?
File[] roots= File.listRoots();
for (int i= 0; i< roots.length; i++)
System.out.println(roots[i]+": "+roots.getTotalSpace());kind regards,
Jos -
How to get the size of physical memory by using system call ?
how to get the size of physical memory by using system call ?What system call can be used for me to get the size of physical memor? thanks.
%vmstat 3
procs memory page disk faults cpu
r b w swap free re mf pi po fr de sr s0 -- -- -- in sy cs us sy id
0 0 0 3025816 994456 4 19 6 0 0 0 0 8 0 0 0 459 253 139 1 1 99
0 0 0 2864688 777408 0 2 0 0 0 0 0 3 0 0 0 428 134 175 0 1 99
0 0 0 2864688 777408 0 0 0 0 0 0 0 7 0 0 0 448 112 166 0 0 100
one interesting observation about vmstat I found out is (mostly on Solaris)
the first line of information always off chart, so I usually do a few interval to get constant result.
if you use linux
just
cat /proc/meminfo -
How to get the size of partition?
The following SQL will get the rows of the fact table & aggregation. But how to get the size (MB) of the partition. select * from $system.discover_partition_stat That should be doable, because in BIDS, we can see the size of a partition, but from which
view we can do that?This is the best bet you have SELECT * FROM SystemRestrictSchema($system.discover_partition_stat ,DATABASE_NAME = 'Adventure Works DW' ,CUBE_NAME = 'Adventure Works' ,MEASURE_GROUP_NAME = 'Internet Sales' ,PARTITION_NAME = 'Internet_Sales_2003') Refer
this article: http://geekswithblogs.net/darrengosbell/archive/2008/12/02/ssas-are-my-aggregations-processed.aspxvinu -
How to get the size of the webpage?
I am designing a program to
analyse the webpage content.
wondering how to get the size of
the webpage including its image's
size and etc. Thanks in advance.As i know , the getContentLength just return
then number of characters of its HTML code.
By knowing the length of the HTML code, is
not possible for me to calculate its download
time... i wonder is there any way to get the
total size of the page including its image size,
applet size, and etc... Thanks : ) -
How to get the size of the table
Hi All,
How to get the size of the table in Oracle 10g?
Is there any script which needs to be run?
Regards,
ApoorvHi All,
Sorry but somehow the table user_segments is not populated in my case. But we have another table SYS.ALL_TABLES whose structure is given below. Would I be able to calculate the table size based on the columns given below:
ColumnName Data Type
OWNER VARCHAR2 (30 Byte)
TABLE_NAME VARCHAR2 (30 Byte)
TABLESPACE_NAME VARCHAR2 (30 Byte)
CLUSTER_NAME VARCHAR2 (30 Byte)
IOT_NAME VARCHAR2 (30 Byte)
STATUS VARCHAR2 (8 Byte)
PCT_FREE NUMBER
PCT_USED NUMBER
INI_TRANS NUMBER
MAX_TRANS NUMBER
INITIAL_EXTENT NUMBER
NEXT_EXTENT NUMBER
MIN_EXTENTS NUMBER
MAX_EXTENTS NUMBER
PCT_INCREASE NUMBER
FREELISTS NUMBER
FREELIST_GROUPS NUMBER
LOGGING VARCHAR2 (3 Byte)
BACKED_UP VARCHAR2 (1 Byte)
NUM_ROWS NUMBER
BLOCKS NUMBER
EMPTY_BLOCKS NUMBER
AVG_SPACE NUMBER
CHAIN_CNT NUMBER
AVG_ROW_LEN NUMBER
AVG_SPACE_FREELIST_BLOCKS NUMBER
NUM_FREELIST_BLOCKS NUMBER
DEGREE VARCHAR2 (10 Byte)
INSTANCES VARCHAR2 (10 Byte)
CACHE VARCHAR2 (5 Byte)
TABLE_LOCK VARCHAR2 (8 Byte)
SAMPLE_SIZE NUMBER
LAST_ANALYZED DATE
PARTITIONED VARCHAR2 (3 Byte)
IOT_TYPE VARCHAR2 (12 Byte)
TEMPORARY VARCHAR2 (1 Byte)
SECONDARY VARCHAR2 (1 Byte)
NESTED VARCHAR2 (3 Byte)
BUFFER_POOL VARCHAR2 (7 Byte)
ROW_MOVEMENT VARCHAR2 (8 Byte)
GLOBAL_STATS VARCHAR2 (3 Byte)
USER_STATS VARCHAR2 (3 Byte)
DURATION VARCHAR2 (15 Byte)
SKIP_CORRUPT VARCHAR2 (8 Byte)
MONITORING VARCHAR2 (3 Byte)
CLUSTER_OWNER VARCHAR2 (30 Byte)
DEPENDENCIES VARCHAR2 (8 Byte)
COMPRESSION VARCHAR2 (8 Byte)
DROPPED VARCHAR2 (3 Byte) -
How to get the full image directory when i upload the image to web page???
hai, how to get the full image directory when i upload the image to web page???
here is the example:
<form action="uploadfile.jsp" method="post">
image<input type="file" name="image" />
<input type="submit" value="submit"/>
<%
String s=request.getParameter("image");
%>
<%=s%>
</form>
i upload the image from C:\image\center.gif. i use request.getParameter just can get the image name like "center.gif". Can anybody help me how to get the full path name. Thanks a lot..There is no need to get the path. It is also fairly pointless as the server cannot access the client's local file system.
Carefully read this article how you can upload files the right way: http://balusc.blogspot.com/2007/11/multipartfilter.html -
How to get the Application perform actions when exits?
How to get the Application perform actions when user clicks on the "X" icon in the top right hand corner?
OR
If i placed an Exit Button.... when actions that i need to use to allow my application to perform a certain action when it exits?
Thanksframe.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
// do your stuff here
});The WindowListener and WindowEvent can be found in java.awt.event package
//David -
How to get the size of the cuurrent illustration
Sorry, I made a mistake before this one. The questios is this: can anybody tell me how can I get the size of the current illustration, (as oposed to the page size) in points. Something like 120 points wide and 87 points High?. What function do I need to call?
From AI Function reference (included with CS2 SDK):
AIDocumentSetup setup;
error = sDocument->GetDocumentSetup(&setup);
if (error) goto processError;
writeDocumentSetup( &setup );
The AIDocumentSetup record returns the following information:
typedef struct {
AIReal width, height;
AIBoolean showPlacedImages;
short pageView;
AIReal outputResolution;
AIBoolean splitLongPaths;
AIBoolean useDefaultScreen;
AIBoolean compatibleGradients;
AIBoolean printTiles;
AIBoolean tileFullPages;
} AIDocumentSetup; -
How to get the size of a file DONE
How can I get the size a file? I want to do the following....
File clobDataFile = new File("clob.dat");
PrintWriter clobpw = new PrintWriter(new BufferedWriter(new FileWriter(clobDataFile)));
int offset = //get the number of chars in the fileOk I am a tard... figured it out...
File clobDataFile = new File("clob.dat");
PrintWriter clobpw = new PrintWriter(new BufferedWriter(new FileWriter(clobDataFile)));
int offset =colbDataFile.length();read API http://java.sun.com/j2se/1.5.0/docs/api/java/io/File.html#length()
next time you have a similar question please refer this document -
How to get the size of the file
Hi All,
I want to get the size of the file in terms of bytes. I used the following code it returns the value in long how can get it in bytes
import java.io.File;
public class ServerBackupCheck {
public static void main(String args[]){
File f = new File("C:/Program Files/Apache Software Foundation/Tomcat 5.5");
System.out.println(f.isDirectory());
System.out.println(f.getTotalSpace());
output:
true
20964163584
regards,
Maheshwaran Devarajif it is a folder you can use this recursive algorithm
public static long recurse(File f) throws IOException
long bytes = 0;
File files[] = f.listFiles();
for(int i =0 ;i<files.length;i++)
File file = files ;
if(file.isFile())
FileInputStream fis = new FileInputStream(file);
byte[] by = new byte[fis.available()];
fis.read(by);
bytes = bytes + by.length;
if(file.isDirectory())
bytes = bytes + recurse(file);
return bytes;
System.out.println(recurse(f)); gives you the total bytes....
Ayberk Cansever .. -
Hi
I want to know the size of the file from Java. ie If i have 10 lines in that file each of 15 characters
then 10 *2*10=200Bytes is the size. How will i get this?
More over, if i am reading the 4 the line, how will get the info that I have read 3 lines =3*2*10= 60 bytes so far?
Regards
SriramThis is from the JavaDocs on java.io.File
length
public long length()
Returns the length of the file denoted by this abstract pathname. The return value is unspecified if this pathname denotes a directory.
Returns:
The length, in bytes, of the file denoted by this abstract pathname, or 0L if the file does not exist
Any of the read methods (except readLine()) on the many stream objects return the number of bytes read, simply accumulate these returns to know how many bytes have been read.
Dave -
How to get the PDF Document version when using Digital Signature
Hi,
I have a form which contains two signature fields.
When i sign the form the pdf document is saved as a version which can be seen by clicking the Signature Panel.
I need to get the binary of the versions stored in the form.
Please suggest me the how to get the version data from the form.
Regards,
S.V.atish KumarHi Mithun:
I think I have run into a similar issue and have not been able to find a resolution.
I have been trying to place three groupings of data and limit them to 15 rows; additional rows would print on a void check on a next page using the rtf template.
Earnings .............. Pre-Tax Deductions .........Taxes
<line 1 earnings> <line 1 pre-tax deductions> <line 1 tax dedcutions>
<line 2 earnings> <line 2 pre-tax deductions> <line 2 tax dedcutions>
<line 3 earnings> <line 3 pre-tax deductions>
<line 4 earnings> <line 4 pre-tax deductions>
<line 5 earnings>
<line 6 earnings>
The template works fine with these lists as nested tables until I add in the restriction and filler for the 15 rows for the first table. The data in the 2nd two lists does not appear once the limitation is added.
Check Writer (XML) - Issues with payroll check stub in rtf
As an alternative, I have been thinking adding the remaining line totals (over 15 rows) and adding a 16th row. However I have been running into an error when trying to use the code for-each-group.
*** XML-22056: exactly one of four group attributes must be present in xsl:for-each-group
Can you send me your template to review? My email is: Karen.Lacey(AT)paetec(DOT)com
Thanks!
Edited by: RedLacey on Dec 17, 2009 11:48 AM -
How to get the size of the blob file uploaded ?
Hi ,
Is there anyway to get the size of the file i have uploaded to a blob type attribute ?
What i can see is that when we upload a file in contributor UI ,once the file is uploaded successfully and if we hover on it , it will show the filename , type and size of the uploaded file .
From where can we get that details so that we can reuse these details in our code ?
Thanks and Regards,
PraveenA filter is a sensible solution, or you can get it in a roundabout way like this for example if you have the blobid (this is paraphrased from OpenMarket/Gator/AttributeTypes/IMAGEPICKERShowImages.jsp):
<ics:sql sql='<%="select urldata,filevalue from MungoBlobs where id=" + ics.GetVar("blobid")%>' listname="blobdata" table="MungoBlobs" />
<ics:listget listname="blobdata" fieldname="urldata" output="urldata" />
<ics:setvar name="blobpath" value='<%=ics.GetProperty("cc.urlattrpath", "gator.ini", true) + ics.GetVar("urldata")%>' />
<%
File blobFile = new File(ics.GetVar("blobpath"));
long length = blobFile.length();
%>
Phil
Message was edited by: pgleghorn
Maybe you are looking for
-
Is it possible to install Win XP on Satellite P20 w/o DVD drive?
Hi, I'm new to this support forum, but I'm hoping you can help with my problem. Windows has become corrupt on my Satellite P20-521, yet I'm unable to use the Recovery Disc as the DVD drive has ceased functioning. I was wondering if there is any other
-
Here is the message I get when I open Firefox; Could not initialize the application's security component. The most likely cause is problems with files in your application's profile directory. Please check that this directory has no read/write restric
-
How do I recover the actual type of the this object in a class hierarchy?
Hi, This is code snippet from Angelica Langer's FAQ: abstract class Node <N extends Node<N>> { private final List<N> children = new ArrayList<N>(); private final N parent; protected Node(N parent) { this.parent = parent; i
-
Conversion from 5.1 to 8.5
can somebody please convert these files from versio 5.1 to 8.5 thank you in advance Solved! Go to Solution. Attachments: MercLV_320.zip 435 KB
-
24-inch + GT120 in a Windows box?
Howdy, I want to be able to use a new 24-inch display on a Windows machine as well, and am willing to put in a GT120 as well. Does anybody have any experience to let me know if this will work using the normal Nvidia drivers, or is there some "magic"