Positioning different objects over containers

Dear Forum members,
Thanks to the help of woogly, I have a grid in my program, so my main looks like this:
public class Example extends JFrame {
public static void main(String[] args) {
new Example();
public Example() {
super("Grid Example");
setSize(new Dimension(300,300));
setDefaultCloseOperation(EXIT_ON_CLOSE);
getContentPane().add(new Grid(),BorderLayout.CENTER);
show();
1. Please tell me how to change the main to put two boxes with labels in the bottom of the grid so it will look like:
G R I D
Labl1 labl2
(The grid and at the bottom 2 labels side by side)
2. Do you now what is the difference between:
BorderLayout.CENTER and
SwingConstants.CENTER
What CENTER each of the mean and when to use each (CENTER is only for the example)?
3. I have seen a code using both of them. Like:
getContentPane().add(new JLabel("Player1", SwingConstants.CENTER),
BorderLayout.SOUTH);
Why both ?
Sorry I have so little Duke Dollars to offer..
Thanks
Eran

Hi.
What you need is to specify a LayoutManager that will actually do the layout in your ContentPane. Those constants are simply instructions to the LayoutManager where and how to place the sub-component.
The code that does what you ask could look like
public class Example extends JFrame {
  public static void main(String[] args) {
    new Example();
  public Example() {
    super("Grid Example");
    setSize(new Dimension(300,300));
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    getContentPane().setLayout(new BorderLayout());   // set the LayoutManager
    getContentPane().add(new Grid(),BorderLayout.CENTER);
    JPanel labels = new JPanel();
    labels.setLayout(new FlowLayout()); // or could be 'new GridLayout(1, 2)'
    labels.add(new JLabel("Label 1"));
    labels.add(new JLabel("Label 2"));
    getContentPane().add(labels, BorderLayout.SOUTH);
    show();
}Those two constnts are very different because
BorderLayout.CENTER is a string of value "Center" and
SwingConstants.CENTER is an int of value 0.
In this code
getContentPane().add(new JLabel("Player1", SwingConstants.CENTER), BorderLayout.SOUTH);
the
SwingConstants.CENTER is a second argument to the JLabel constructor indicating on how JLabel sould draw its text, and the BorderLayout.SOUTH is a second argument to add method.
Read about LayoutManager interface and implementing classes in the API docs
http://java.sun.com/j2se/1.4.2/docs/api/java/awt/LayoutManager.html
and there sould also be some tutorials on Layouts.
Filip

Similar Messages

  • Adding a category on an object over ifsshell

    Hello,
    it's possible to set a category (or special attributes of the INTERMEDIAIMAGE class) for a file over ifsshell?

    And in the case you described, the object you synchronize on should not be the array. Why not? Because your description reveals a misunderstanding. You cannot change the size of an array, so your statement "then the array will be modified by the other thread and will now have n+1 elements in it" must actually mean "then the other thread creates a new array that has n+1 elements in it". So anything that was synchronizing on the original array has no effect on anything that is now synchronizing on the new array -- which is a different object.

  • How to apply same Animation to different Objects?

    Hello,
    So, as the question stated, I am trying to animate multiple objects in the scene with the same animation.
    For example, I have a SQUARE and a CIRCLE in the scene, both of them in different layers. I want them to both scale from 0% to 120%, then back to 90%, and finally to 100%. What I do is going in the SQUARE "scale" section and add keyframes to the time I want each elements (percentage) to be at. When done, the SQUARE works perfectly (scaling from 0>120>90>100 percent). Then, I copy and paste the keyframes I use with the SQUARE to the CIRCLE, which gives me the same animation as the SQUARE (0>120>90>100 percent). But when I want to make changes to both of them, I need to change each keyframes in each objects (SQUARE and CIRCLE) one by one...
    Having only two objects in the scene isn't bad, but I have around 30 objects that needs to be animated exactly the same... so changing them one by one is pretty time-consuming.
    So, the question is, is there a way where I can easily apply a type of animation (scaling 0>120>90>100, and adjustable afterwards) to different objects (SQUARE, CIRCLE, etc.) in my composition without doing it one by one?
    This might be a stupid question, but I'm new with After Effects so this is quite complicated for me...
    Thank you,
    Pascal

    Several ways, parenting and expressions.
    Parenting: Create a small solid or a null object that will be 'controlling' the other layers. Parent the CIRCLE and the SQUARE to it (to achive this, in the Parent column of the Composition Panel, select the name of the controlling layer or directly pickwhip the layer).
    Once done, when you scale/rotate/move the controlling layer the parented layers transform accordingly. It doesnt affect opacity.
    Be aware that parenting modifies the values you see in the Composition panel for each of these properties (scale/rotation/position) for each of the parented layers. This is because the transform properties are now expressed in the coordinate system of the parent layer, and not in the one of the comp. Modifying the transform properties of the parented layers tranform these layers relatively to the controlling one.
    Expressions: You can enter expressions in the transform properties of your layers. For instance, if your controlling layer is named 'controller', alt+click the stopwatch of the property 'Scale' of the SQUARE for instance and enter this in the expression box:
    thisComp.layer("controller").transform.scale;
    Now when you scale the controller, the SQUARE scales accordingly. It works for any property.
    Note that since the expression doesnt refer to the property's own keyframes, those keys are now ignored. To refer to the property's own key value in an expression, use simply 'value'. For instance:
    s = thisComp.layer("controller").transform.scale/100;
    [s[0]*value[0], s[1]*value[1]];
    The possibilities are pretty much infinite.

  • Different Number range for different objects

    HI Gurus
    Could you please explain how can we make different Number range for different objects(O,S,P).Can we do with standards or we can go for UserExit??.
    Your early Advise will be appreciated.
    Thanks
    Chandra

    Hi Chandra,
    SM31 -> T77IV : 01S -> Number Range Maintenance.
    (or SPRO -> Pers Man -> Org Man -> Basic Settings -> Maintain Number Ranges)
    For the subgroups
    01C (plan variant 01, Object type C) Job
    01O (plan variant 01, Object type O) Org unit
    01S (plan variant 01, Object type S) Position
    Define the following number ranges respectively.
    (EX 60000000 69999999)
    (EX 70000000 79999999)
    (EX 80000000 89999999)
    Regards,
    Dilek

  • Tal Mngt Area of Responsibility - use of different object from OrgUnit

    Hi all,
    One of my clients has a requirement to use a different object from an OrgUnit as the Area of Responsibility (e.g. S A 741 O > S A 741 01 where 01 is a new object). Basically, 01 is an OrgArea object that is linked to one or more OrgUnits and some positions.
    My initial thought is that is such an integral part of EhP4 Talent Management security that it would not be possible. Therefore, if anybody knows differently please tell!
    Many thanks in advance,
    Luke

    >
    Luke Marson wrote:
    > Hi all,
    >
    > One of my clients has a requirement to use a different object from an OrgUnit as the Area of Responsibility (e.g. S A 741 O > S A 741 01 where 01 is a new object). Basically, 01 is an OrgArea object that is linked to one or more OrgUnits and some positions.
    >
    > My initial thought is that is such an integral part of EhP4 Talent Management security that it would not be possible. Therefore, if anybody knows differently please tell!
    >
    > Many thanks in advance,
    >
    > Luke
    Hi Luke, from the OM perspective, relationship perspective all of it could be done.  What would be interesting is that I highly doubt the SAP standard TREX index will work correctly. 
    HRTMC Relation S O Area of Responsibility
    AND
    HRTMC Structural authority
    cool thing to test out though, let us know,.,

  • How do I make 2 points in two different objects to stick to eachother?

    As the topic says, I need to make 2 points in two different objects to stick to eachother, so for example when I rotate a line which is "connected" to a square object in one end, the line will rotate around that point.
    Also, if I have lets say two square objects and I "connect" one of the corners of one square object to another corner of another square object, where the points are located exactly on the same location, I need to be able to rotate any of the square objects around the point which is connected to the other square.
    Is this possible?
    Some will probably ask why I need to do this, but I can only say I do, it's a long story

    Its quite complicated guys , I'm quite sure Illy doesn't do what I'm looking for.
    It's basically a line which is "anchored" at one point and connected to a square at the other point. So when I move the square the line is being dragged with it without altering its length. And of course the "anchored" point of the line stays where it was from the beginning, while the other end is attached to the square moving with it.
    This way the squares point, the one which is connected to the line, can neither end up closer or farther from the lines "anchored" point. The square can only move around that point in an exact circle, with constant radius.
    I'm using this for measuring/map creation. It doesn't have to be 100% exact down to the millimetre, but I'd be happy if I could get it centimetres exact if you know what I mean. Of course this is on a scale of like 100x100 metres or more.
    I can do it without this "feature" too, but it takes more time and is not totally exact either.
    I can't use CAD for this, so it'll have to be Illy.

  • How to Display two different objects in a single table header in Cross Tab?

    i All,
    I've a reqiurement for a Cross Tab Report like I need two different objects that should be displayed side-by-side, one object's values after another in a single header. In the picture below I've shown the objects separately in two rows, top header having BSNLNL,MTNLNL,RCOMNL and Header-2 having AIRTIL,RCOMIL. But requirements needs to be showing like this,
    BSNLNL
    MTNLNL
    RCOMNL
    AIRTIL
    RCOMIL
    Actually, the data for the header comes from a single object called Operator. I've show the Operators name ending with NL and after that names ending with IL. So, i've separated the data into two variables using the below formulae.
    IL:
    =[Billing Operator]
    Where
    Match([Billing Operator];"*IL")=1
    NL:
    =[Billing Operator]
    Where
    Match([Billing Operator];"*NL")=1
    Also, the NL data should start first and after the NL data's last value ends, the IL data should begin.
    One more thing is that I've to show '0' for null values. So i've used the below formulae on the column data. You can see below that except the "Outgoing ILD Mins in the month from Mobile Network" everything else showing fine. I don't understand why.
    =If
      Substr([Franchise];3;1)="M"
      Then
       [Mobile Outgoing Charged Usage Minutes]
       Else
       0
    I tried different approaches but couldn't find a solution. Could you please help me?     
    I'm using BO WebI 4.1 SP1
    Regards,
    Naren Vema.

    Hi Naren,
    No need to split Billing Operator object. Create a variable-
    V_IL_NL= If  Match([Billing Operator];"*IL")=1 Then "IL" ElseIf Match([Billing Operator];"*NL")=1 Then "NL"
    1) Put V_IL_NL variable below Billing Operator object header.
    2) Sort and create break on this variable.
    3) Delete Footer column. it will automatically create when you apply break.
    4) Hide V_IL_NL variable from this header.
    ~Anuj

  • Is there anyone there? I hope there is someone who can you understand this problem and have the common sense to respond?  I open gmail. I want to save an email to one of my folders. I position my cursor over the appropriate Folder icon or by choice, to th

    Is there anyone there? I hope there is someone who can you understand this problem and have the common sense to respond?
    I open gmail. I want to save an email to one of my folders.
    I position my cursor over the appropriate Folder icon or by choice, to the Trash.
    The friendly finger pointing cursor icon changes to an arrow icon.
    The hand icon allows me flawless access to opening and/or moving emails.
    The arrow, however does not open the link.
    On the Google menu bar the cursor hand with finger opens the links to Everett (my name), Search, Images, Maps and Play.
    When I attempt to open the remaining links in the menu bar (YouTube, News, Gmail, Drive, Calendar and More) the arrow icon replaces the hand. The arrow icon does not work. It will not activate these links.  Nor does it open email messages in the Inbox.
    Usually I reset, even reboot Safire and sometimes the problem goes away, then reappears.
    Can you imagine if this condition should it happen to a tech savvy Google Support person? Perhaps one can share and make my problem go away.
    I am considering dropping Google as my mail source. Unfortunate!
    Everett Halvorsen
    [email protected]
    718.490.3824

    I have uninstalled my Access Connection, but this problem seems to persist. IBM technician have changed the wireless card of my T60, the first few days after it was changed was very fine, no problem at all. About a week later, the problem occured again, and it happened quite frequently after that occurence. Now i really have no idea what is the cause and how to solve it. Will be greatful if there is anyone that can help me.

  • Can findText find two different objects at once?

    I have written a script that finds all italicized words, then compares them to a character style that italicizes characters. If there are any italicized words that do not use the character style, the user is alerted.
    Of course, not all fonts use a fontStyle that equals "Italic." Some use a fontStyle called "Oblique."
    I was trying to figure out how the findText function could find two fontStyles at the same time. My solution was to realize that each find is an array. So I made two finds and the concatenated the arrays. The resultant array (here called myFoundItems) elements can be searched through to find any that do not have the correct character style applied.
    My question is if the findText function can find more than two different objects at once or are we stuck with concatenating arrays?
    Below is part of the script:
    var myDoc = app.activeDocument;
    initFindReplace(); [This function zeros out anything left in the find/change preferences]
    app.findTextPreferences.fontStyle = "Italic";
    var myFoundItems1 = myDoc.findText();
    initFindReplace();
    app.findTextPreferences.fontStyle = "Oblique";
    var myFoundItems2 = myDoc.findText();
    initFindReplace();
    var myFoundItems = myFoundItems1.concat(myFoundItems2);
    Thanks,
    Tom

    Tom,
    The reason why you end up with an array of arrays is this: you define an array allMyFoundItems, then you iteratively collect other arrays using findText and insert ("push") these arrays into allMyFoundItems. Instead, you should use concatenate:
    var allMyFoundItems = new Array;
    for (. . .
       var myFoundItems = myDoc.findText();
       allMyFoundItems = allMyFoundItems.concat (myFoundItems)
    If you'll allow me a further comment, you could formulate your test to check whether a fontstyle name contains oblique or italic in one line:
    >if (arrFontStyles[k].search (/(italic|oblique)/i) > -1)
    And as the script searches but doesn't change anything, there's no need to set the ChangeTextPreferences. Your script could then be stated as follows:
    var myDoc = app.activeDocument;
    var arrFontStyles = myDoc.fonts.everyItem().fontStyleName;
    aa = findFontStyle (arrFontStyles);
    function findFontStyle (arrFontStyles)
       var allMyFoundItems = new Array;
       var myFoundItems2 = new Array;
       app.findTextPreferences = NothingEnum.NOTHING;
       for(var k = 0; k < arrFontStyles.length; k++)
          if (arrFontStyles[k].search (/(italic|oblique)/i) > -1)
             app.findTextPreferences.fontStyle = arrFontStyles[k];
             var myFoundItems = myDoc.findText();
             allMyFoundItems = allMyFoundItems.concat (myFoundItems);
             }//end if
          }//end for k
       return allMyFoundItems;
       }//end findFontStyle function
    As to formatting scripts in the forum, you can do this by wrapping your code in <pre> and </pre>. Also replace < with &lt; (< causes all lines of code to be displayed on one line). You should also replace curly quotes with straight codes, and tabs with (non-breaking) spaces. I use the following script for that:
    tf = app.documents.add().textFrames.add ({geometricBounds: [0,0,'700pt','500pt']})
    tf.insertionPoints[0].select();
    app.activeDocument.textPreferences.typographersQuotes = false;
    app.paste();
    app.findGrepPreferences = app.changeGrepPreferences = null;
    sara (tf, '&', '&amp;');
    sara (tf, '<', '&lt;');
    sara (tf, '\\t', '   ');
    sara (tf, "'", "'");
    sara (tf, '"', '"');
    tf.parentStory.insertionPoints[0].contents = '<pre>';
    tf.parentStory.insertionPoints[-1].contents = '</pre>';
    function sara (tf, f, r)
       app.findGrepPreferences.findWhat = f;
       app.changeGrepPreferences.changeTo = r;
       tf.parentStory.changeGrep ()
    Copy the text of the script you want to prepare for posting, then run this above script. It creates a new InDesign document, pastes your script into it, and makes all the necessary changes. Then copy that and paste it into the forum.
    Peter

  • Exact, precise positioning of Objects

    I have an application that needs to be very precise in the positioning of a text object (so that OCR can read it).  As an example, I can position an object at x=3.5 inches but I need to position at x=3.53.   I use the "Size and Position" dialog box and enter x=3.53.  Get out of the dialog, go back in and it has changed to 3.52, Get out and in and now it is 3.51.  Once at 3.5 it stays at 3.5.  Position seems to work well at 1/10 of an inch but I need 1/100 of an inch.  Snap to Grid & Free-Form Placement Options can be on or off - no difference.
    This is my first post.

    James Terry You sent a reply via email with discussion regarding setting the grid to 0.01 inches (which is 1/100 of an inch).  When I sent grid to 0.01" and moved them manually without using "Size and Position" dialog window, the objects stayed where they needed.  Going in and out "Size & Position" does cause it to move.  But by forcing 0.01" with snap turned on, I GOT WHAT I NEEDED!  James: put in a response and then I can award points and mark this answered.

  • Dynamic Positioning of Objects in a Grid (rows and columns) AS3 Tutorial

    The topic of a dynamic positioning of objects in a right grid (rows and columns) comes up often so I decided to post an AS3 solution here:
    http://flashascript.wordpress.com/2010/12/25/arranging-objects-into-2d-dynamic-grid-with-a ctionscript-3/

    Hard to tell from your description but this might help:
    http://dtptools.com/product.asp?id=atid
    Bob

  • Dynamic Positioning of Objects in a Grid (rows and columns) with AS3 Tutorial

    The topic of a dynamic positioning of objects in a right grid (rows and columns) comes up often so I decided to post an AS3 solution here:
    http://flashascript.wordpress.com/2010/12/25/arranging-objects-into-2d-dynamic-grid-with-a ctionscript-3/

    Hard to tell from your description but this might help:
    http://dtptools.com/product.asp?id=atid
    Bob

  • How to process for an ECC 6.0 upgrade for different objects (RICEF)?

    Hi eaxperts,
    I am new to upgrad project. Can anyone pls. tell me in details things that need to be undertaken in an ECC upgrade project for different objects e.g. RICEF and How should I process for the same?
    Please also tell me the important T-codes for the same and how to use them.
    Thanks a lot in advance,
    Sandy

    Hi,
    Please read below lines.I think u can get some knowledge about UPGRADE.
    u2022     System preparation and stack level patch upgrade u2013 Basis Team
    First of all, the basis team installs the Latest SAP version on the hardware and they apply all the general patches up to the latest stack level. All the stack levels of various patches u2013 Basis, ABAP, XI etc should be brought up to the latest level by the basis team. In case, all the stack levels are not the latest, it might create problems like new objects coming into the SPAU during the upgrade or thereafter u2013 these will be explained in sections below.. So it is a good practice to get the system to the latest stack level.
    u2022     SPDD Phase u2013 ABAP and Functionals
    This transaction code SPDD is the core step in an upgrade project. The system compares all the dictionary objects u2013 data elements, database tables and structures of the latest system (say ECC) with the previous or the old system (Say 4.6c). These all elements are present under two nodes u2013 with modification assistant and without modification assistant. Objects present under with modification assistant have the modification assistant u2018ONu2019 and we can see the modification logs.
    u2022     Up gradation of the system u2013 Basis Team
    After the SPDD phase is complete, the basis team prepares the system for an UPGRADE u2013 i.e. the old system would be replaced by the new system. In this phase, the system asks for the SPDD request u2013 the single request which generates and activate all the dictionary objects present in SPDD phase in the new system u2013 ECC. If the request do not contains the same objects which were present in SPDD, the system shows a danger alarm u2013 stating that this SDPP request do not contains all the desired objects and it might make the system unstable. In case any other objects are missing, there and then it should be put in the SPDD request.
    u2022     SPAU Phase u2013 ABAP and Functionals
    The SPAU transaction contains the objects u2013 Programs, Reports, Screens, Messages, Notes, Function Modules etc. which have difference in the Latest SAP request and the previous ones. This SPAU phase can be done either just after SPDD or after the Up gradation of the system by the Basis team.

  • Problem in passing/returning objects over dynamic web service call

    Hi Friends,
    I am beginner in java web service.
    Here is the problem I am facing when I pass/return user defined objects to remote web service method using dynamic we service call.
    The client can call the remote web service method in 2 ways.
    1. By generating client stubs using WSDL file
    - In this case, I am able to pass/return the user defined objects to remote method without any issue only when the server side web services are deployed in any server(jboss)
    - But in java 1.6 & above, the web services can be deployed without server using endpoint. In this case, I am not able to pass/return objects over web service calls.
    2. Without generating client stubs (dynamic web service call)
    - This will establish a connection at run time using the given WSDL file (I have attached the document). I have to form an XML(This will contain API name, arguments) string as input at run time
    - In this case, it allows only string as argument while passing & returning.
    Please let me know if you can help me on this.
    Regards,
    pani

    I'm not sure about your question, but this might help:
    [http://forum.java.sun.com/thread.jspa?threadID=5251188|http://forum.java.sun.com/thread.jspa?threadID=5251188]
    You might also want to read on JAXB.

  • What is the best way to handle collections that contains different object

    Hi
    Suppose i have two class as below
    class Parent {
           private String name;
    class Child extends Parent {
          private int childAge;
    }I have a list that can contains both Child and Parent Object but in my jsp i want to display a childAge attribute ( preferrably not to use scriplet )
    what is the best way to achieve this?

    Having a collection containing different object types is already a bad start.
    How are parent and child related to each other? Shouldn't Child be a property of Parent?
    E.g.public class Parent {
        private Child child;
    }In any way, you could in theory just check Object#getClass()#getName(), but this is a nasty design.

Maybe you are looking for

  • How to make Sales Person LOV org specific in case of Multi Org Setup

    HI, We are working on 11.5.10.2 We have a multi org setup and i am required to make the sales person LOV to populate only the org specific salespersons, at the sales order, quote, service contract levels. Is it achiveable and if yes.....please letme

  • Hard drive exchange between MacBook(2007) and MacBookPro(2009)

    I have a MacBook(2005) that I upgraded with a 500GB hard drive and other stuff. I just did a fresh install of Snow Leopard and all my settings are right where I want them and it fells perfect. Currently I am using 300GB of hard drive space. However,

  • How to obtain a square button

    hi there, the question is simple, I want my button to be completely square with hard non-beveled edges, how to achieve that? I tried button.scale9Grid = new Rectangle(0, 0, buttonWidth, buttonHeight); but no luck, I get : ArgumentError: Error #2004:

  • How do I repair currupted mov. files?

    Long story short, I edited a wedding on Final Cut studio. Both the software as well as all my uploaded footage collected on an external harddrive. BOOM  My hard drive completely becomes corrupt and I can't mount it (meaning my computer doesn't recogn

  • Lightroom 3 broken

    When I opened my Lightroom 3 today, everything was gone.  My catalogs, presets and preferences are all GONE.  It's as if the program has been reset.  Does anyone know why this might have happened??  Any advice is greatly appreciated!