Defining the size of swing object which has overriden paint method

Hi All!
I have a text and I want to visualize it by my own. I use font type in the drawing which affects the painting size of the component. Before drawing I need to know the size of this component. because I want to handle mouseevents and other stuffs which need the bound size of this component. Therefore I have to set the bounds . But the size will be known at the drawing ... :(
How can I define the exact size of this component before the drawing?
eha

Generally, you should override getMinimumSize() and getPreferredSize(), and let the layout manager set the size of your component. With this approach, you should be prepared for the case where your component is not given its minimum or preferred size, but some other size.
To calculate the size that you require, you'll need to use a similar strategy to what's in your paint method. For example, you may need to calculate the width and height of your string (using the current font), within getMinimumSize() and getPreferredSize().

Similar Messages

  • The box in my Photoshop Elements, which shows the size and types of brushes has shrunk to one unreadable line. How do I expand the box to its original size?  I have tried dragging it open but nothing moves.

    The box in my Photoshop Elements, which shows the size and type of brushes, has shrunk to one unreadable line. How can I expand this box to its original size? I have tried dragging it open but nothing happens and none of the tool boxes appear to give me an expansion option

    Well, when you open the program, the splash screen, the window you see while the program is opening, should make that clear enough. For example:

  • Extending the BC4J objects which has private methods

    Hi,
    I faced a situation which requires to extended the AM and CO of a page which has some private methods.
    As we cant inherit the which private methods of a class I thought of using the same code in the extended class.
    As it is not feasible solution n not upgrade safe we have not taken up the development..
    Any one faced the same issue and any workaround on the same will be appreciated..
    Thanks,
    Nagu

    Copy the private method code into your extended objects. Then it'll use the private methods in your extended code....

  • How do I determine the size of an object on a particular layer?

    Whether it's a rectangle, circle, line, etc. how do I determine what the size of an object is on a particular layer?

    Right click on the rulers and set the scale to pixels in the dialog
    Go to View>new guide and select the position of the guide lines along horizontal and vertial axes
    Window>info brings up the Info Palette. The information in the right lower corner provides a readout of any selection that you make, e.g. with the marquee tool
    View>grid allows one to bring up a non-printable grid which is useful for orientation. The grid can be set up with subdivisions to suit via Edit>preferences>guides and grid
    You can open a duplicate layer at the top of the stack, then using the brush tool create a straight line for visual projection. The layer can be deleted at any time. To create a straight line, click on the begin point, hold down the shift key, and click on the end point
    Hope that one of these options is useful for your purpose. Please post your progress.

  • Determine the Size of an Object in ObjectInputStream

    Hi all,
    I have a quick question. I have a class that is being written over a socket using ObjectOutputStream and ObjectInputStream. I want to be able to set the buffer size of the socket to fit only ONE object. Can anybody tell me how to determine the size of that object?
    (Note, the object has a Properties object within it, but for the time being, it can be assumed that properties object will always be the same.)
    - Adam

    Having written it to the outputStream, thought, can
    the size be determined somehow by the inputStream?No, it can't
    This is related to my previous question (on Pushlets
    and Thread Priorities). I didn't read that one.
    I believe that it's possible
    that multiple threads are trying to write to the
    socket at the same time, and I cannot synchorize the
    input stream to get a lock on it. Do you mean the outputstream? Why can't you synchronize the method that writes to the outputstream?
    I thought this
    might be causing the data to not be sent over the
    socket until all the threads have finished. That doesn't sound correct. But you could call the flush method when an object is written.
    I
    figured if I reduced the size of the socket buffer,
    it would only accept a single object, eliminating
    this problem?I don't think so.
    /Kaj

  • Last active change request of a object which has been transported

    Hi to all,
    I need a method to obtain the last active change request of a object which has been transported to the corresponding target system. I know that the CR tables are E070 and E071, but how can I know the last active and transported CR of each object? Any suggestion?
    Thank you very much,
    Antonio

    Hi Antonio, As u are aware that you can get TR information from E070 and E071 tables.From these two tables we can get the latest TR. In table E070 there are two fields with AS4DATE, AS4TIME.So, U can find the latest transported object on these two fileds.Also, u need to check the TRSTATUS field which specifies whether the object is transported ( R Released) or still Modifiable( Active as D).
    However this table will also contains subtasks and main request. This can be diffrentiated with the help of STRKORR field of E070. If blank then its a main req else its a subtask where the field would contain the Main Request No.
    Hope this would be of some help for u r development.
    Regards,
    Swaroop

  • How to define the size of the frame

    I have create a frame in my jbuilder env, how can I define the size of the frame and change
    some attributes of the frame.
    Which method shall I invoke?

    To define the size of the frame use setSize method.
    To avoid minimise and maximise button use setResizable method with parameter as false.

  • The number of active Object monitors has overflowed.

    hello,
    please is any one has information about this error? and when it occure?
    Error Message: The number of active Object monitors has overflowed. [87]Exception Rec: EXCEPTION_ACCESS_VIOLATION (00000000c0000005) at 0x000000001006C5E0 - memory at 0x0000000000000000 could not be written.Minidump : Wrote mdmp. Size is 3827MBSafeDllMode : -1
    Fatal Error : The number of used monitors is 2097152, and the maximum possible monitor index 2097151Version
    we found it in the application log file.

    This means that the application currently has over 2 million Objects that are involved in synchronization operations and has created object monitors. This is highly unusual and should be investigated.
    /Staffan

  • Object (which has non-serializable attr.) serialization

    i could not solve object serialization problem in anyway. how can this be performed without "java.io.NotSerializableException"?
    import java.awt.Image;
    import java.awt.Toolkit;
    import java.io.ByteArrayOutputStream;
    import java.io.IOException;
    import java.io.ObjectOutputStream;
    import java.io.Serializable;
    public class Object2ByteArray {
        public static void main(String[] args) {
            Object2ByteArray obj2ba = new Object2ByteArray();
            AnObject anObj = obj2ba.new AnObject();
            try {
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                //FileOutputStream fos = new FileOutputStream("C:\\obj.file");
                ObjectOutputStream oos = new ObjectOutputStream(baos); //or (fos)
                baos.writeTo(oos);
                oos.writeObject(anObj);
                oos.flush();
                byte[] objInBytes = baos.toByteArray();
                System.out.println("An object (which has a non-serializable element[Image]) is written to ObjectOutputStream.");
            } catch (IOException e) {
                e.printStackTrace();
        public class AnObject implements Serializable {
            Image img = Toolkit.getDefaultToolkit().getImage("C:\\anil.jpg");
            int c = 10;
            String desc = null;
    }

    Hi,
    No, transient means that the attribute won't be sent over the stream. You usually declare fields that you don't want to send, or can't send as transient.
    /Kaj

  • How can I change the font in the "Add Text Comment" tool, which has Helvetica as default?

    How can I change the font in the "Add Text Comment" tool, which has Helvetica as default?

    Is this for the ADD TEXT COMMENT tool?  How do you change the default font for the ADD TEXT (EDIT TEXT) TOOL?

  • How to measure the size of an object written by myself?

    Hi all,
    I'm going to measure the performance on throughput of an ad hoc wireless network that is set up for my project. I wrote a java class that represents a particular data. In order to calculate the throughput, I'm going to send this data objects from one node to another one in the network for a certain time. But I've got a problem with it- How to measure the size of an object that was written by myself in byte or bit in Java? Please help me with it. Thank you very much.

    LindaL22 wrote:
    wrote a java class that represents a particular data. In order to calculate the throughput, I'm going to send this data "a data" doesn't exist. So there's nothing to measure.
    objects from one node to another one in the network for a certain time. But I've got a problem with it- How to measure the size of an object that was written by myself in byte or bit in Java? Not.

  • I am trying to decrease the size of my aperature library on my MB Pro HD.  I used  file\ relocate master to move files to my External HD(EHD) and this worked.  However, the size of my MBP library has not decreased.

    I am trying to decrease the size of my aperature library on my MB Pro HD.  I used  file\ relocate master to move files to my External HD(EHD) and this worked.  However, the size of my MBP library has not decreased.  I do not want to delete the files on my MB Pro until I am confident Aperature can see the files on the EHD.  It looks like the relocate master fxn just copies the masters and data to another location. 

    Relocate master (or original in newer versions) does move and not copy the master file. Jut to make sure I just ram a test and moved some images out of the library to an external drive and they were definitely gone from the Aperture library.
    If you look at the images in the library that you moved do they have the referenced file badge? If you run a filter on your library looking for referenced files do the images you relocated show up? If you select one of the images and do a Show in Finder what does it show? Finally if you select the images and do Locate Referenced files do they appear listed as being on the volume you put them on?
    You could go into the library and look for the masters you moved to see if they are still there but if all the above show you they were relocated then I don;t think you will find them.
    How are you checking the library size? Have you quit Aperture and restarted it (better would be to log out and log back in) and then checked the size? It is possible that some of that data is cached and won't get updated till you restart.
    Finally you could do a library repair in case something got 'stuck'.

  • How to stop changing stroke weights when changing the size of an object in CS5 on Windows 7?

    I'm not sure what I did to make this happen or how to change it back, but for some reason when I change the size of an object/line it changes the stroke weight as well. (For example, if I drew an ellipse with stroke weight 2 pt, and then increased the size the stroke weight would be 2.856 pt or some such number instead of 2 pt.) Does anyone know how to change this back?
    Thanks!

    Take a look at the Scale Strokes and effects preference either in the general programme preferences or in the flyout menu of the Transform palette.

  • Can I use Bluetooth 3.0 headphone on the iPod Touch 5th Generation which has Bluetooth Blue 4.0?

    Can I use Bluetooth 3.0 headphone on the iPod Touch 5th Generation which has Bluetooth Blue 4.0?  This will be a first time purchase of a headphone, (preferably behind the head, earbuds) mostly likely from an on-line store.  Any recommendations?

    Yes, it is backwards compatible.

  • Hello, i am interested in buying a 2010 Closeout imac 21.5 One model Is Z0JM5LL/a which has a intel i5 processor and the other is MC509LL/A which has a Intel i3 processor i figured the i5 would be better but specs say the i5 only has one processor

    Hi i am interesed in buying out a closeout model of a Imac 21.5 imac The 2 models are Z0JM5LL/A which has a Intel i5 processor and the other is MC509LL/A which has a Intel i3 processor I figured the i5 would be better has better specs but it says the i3 has a dual core Meaning 2 processors and the i5 only has a single Processor meaning i would think then teh i3 is better or is it false specs about the i5 do they both have dual Core Or which one is better Remember these are 2010 Models Not the New Quadcore Which Processor i am looking at is better????

    Both the I3 and I5 are dual core processors.  The I3 should be the 3.2Ghz model, which has an upgraded video circuit over the base model, which is good. The 21.5" I5 would have the same video circuit. It also has turbo boost, that the I3 doesn't have, which can boost it's speed from 3.6Ghz to 3.86Ghz when needed.
    If you need to compare the 2010 and 2011 models (or even 2010 only comparisons), here's some benchmarking: http://www.barefeats.com/imac11b.html , http://www.macworld.com/article/159631/2011/05/201127inimac31ghz.html , http://www.macworld.com/article/159765/2011/05/imac2011.html

Maybe you are looking for