Two group layouts inside one another

Hi!
I use group layout to add two buttons to a panel. Then I use group layout again to add that panel on top of my applet's content pane. For some reason the second button shows only after I move mouse over it. I tried different things like invoking repaint method of the second button or drawing via paint component method (method paintComponent(Graphics g)). Any ideas why the repaint method of the other button is not invoked?
import java.awt.*;
import java.lang.reflect.InvocationTargetException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.*;
import javax.swing.GroupLayout.SequentialGroup;
public class TestButton extends JApplet {
* Initialization method that will be called after the applet is loaded
* into the browser.
public void init() {
try {
// TODO start asynchronous download of heavy resources
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
setSize(new Dimension(300, 300));
// setBackground(Color.black);
Container c = getContentPane();
c.setBackground(Color.GREEN);
final JButton button1 = new JButton() {
@Override
public void paint(Graphics g) {
super.paint(g);
g.setColor(Color.RED);
g.fillRect(0, 0, 100, 100);
final JButton button2 = new JButton() {
@Override
public void paint(Graphics g) {
super.paint(g);
g.setColor(Color.RED);
g.fillRect(0, 0, 100, 100);
JPanel panelBig = new JPanel() {
@Override
public void paint(Graphics g) {
super.paint(g);
g.setColor(Color.YELLOW);
g.fillRect(0, 0, 200, 200);
GroupLayout glBig = new GroupLayout(panelBig);
SequentialGroup horBig = glBig.createSequentialGroup();
SequentialGroup verBig = glBig.createSequentialGroup();
horBig.addComponent(button1, 100, 100, 100);
verBig.addComponent(button1, 100, 100, 100);
horBig.addComponent(button2, 100, 100, 100);
verBig.addComponent(button2, 100, 100, 100);
glBig.setHorizontalGroup(horBig);
glBig.setVerticalGroup(verBig);
panelBig.setLayout(glBig);
// c.add(button1);
GroupLayout gl = new GroupLayout(c);
SequentialGroup hor = gl.createSequentialGroup();
SequentialGroup ver = gl.createSequentialGroup();
hor.addComponent(panelBig, 200, 200, 200);
ver.addComponent(panelBig, 200, 200, 200);
gl.setHorizontalGroup(hor);
gl.setVerticalGroup(ver);
c.setLayout(gl);
} catch (InterruptedException ex) {
Logger.getLogger(TestButton.class.getName()).log(Level.SEVERE, null, ex);
} catch (InvocationTargetException ex) {
Logger.getLogger(TestButton.class.getName()).log(Level.SEVERE, null, ex);
// TODO overwrite start(), stop() and destroy() methods

This would be because you overrided the paint method.
JPanel panelBig = new JPanel() {
    @Override
    public void paint(Graphics g) {
        super.paint(g);
        g.setColor(Color.YELLOW);
        g.fillRect(0, 0, 200, 200);
};The call to super.paint(g) paints the component, the border, and the children. You then proceed to fill in a yellow rectangle over everything that was painted in the panel. The solution, of course, is to do it the correct way and override paintComponent(...) as you are suppose to do for Swing.

Similar Messages

  • How do I make two pictures alternate between one another like a video game sprite?

    Hello everyone!
    I'm currently making a animation of space invaders, however I have encountered an issue. I need to be able to have all the space invaders move, and with each movement change shape. My original plan was to use two models and change their opacity every 15 frames from 0 to 100 so one would be at 100 opacity while the other would be at 0. I can't figure out how to do this other than to go through it frame by frame, changing the movement and opacity, and I have to believe there is any easier way to do this. I need the opacity to change from 0 to 100 with no transition (So 0-100 not 0-20-40-60-80-100).
    Any help is appreciated!

    you can do this with expressions.  For fun I played around with a test animation
    to do this you would have 2 precomps for each row of aliens depicting the two (one comp has the first alien look, the second comp has the second look all in the same position as the first)
    the two comps are placed in a master comp, positioned vertically to where you want them.
    this expresion would go in the position parameter of both comps.  it starts horizontal positioning at 0 and increments 100 every 15 frames
    /////////////////////// position
    var increment = 100;
    var t = timeToFrames(t = time + thisComp.displayStartTime, fps = 1.0 / thisComp.frameDuration, isDuration = false);
    var s = parseInt(t/15);
    var pos = transform.position;
    [s*increment,pos[1]]
    //////////////end position
    the next expression would go in the opacity parameter of both comps, it alternates giving 100% opacity between the two comps every 15 frames.  The comps need to appear 1 after the other in the layer stack for it to work.
    /////////////////////opacity
    var t = timeToFrames(t = time + thisComp.displayStartTime, fps = 1.0 / thisComp.frameDuration, isDuration = false) % 30;
    var s = (t%30);
    var i         = this.index %2;
    var change = [0,100];
    if(i){
        change = [100,0];
    if(s<15){
        o = change[0];
    }else{
        o = change[1];
    o;
    //////////end opacity
    Like I said, I just threw it together to show how expresions could solve it.  Ideally you would need some code in the posion to shift down and reset horizontal position to 0 every so often

  • Two Sessions Waiting for One Another Across DB Link

    Hi,
    Version: 9.2.0.8, patchset 8
    OS: Windows Server 2003
    Server: Itanium 2
    During our overnight ETL process last night, one of the stages which normally takes serveral minutes to run became stuck. The calling process in the DW database was showing as ACTIVE and the wait event was for "SQLnet message from DB Link". When looking at the session in the database where the changes are being collected from, the session was shown as INACTIVE and to be waiting for "SQLnet message from client".
    The process was stuck for 6 hours and until we managed to kill the job from the schedule so that the remainder of the ETL process could continue. There were no errors on either of the two servers (the DW and source DBs run on separate boxes). The network engineers reported 0 problems with the network at the fault time. There are no trace files or reported errors in the alert logs of either DBs.
    Has anyone seen this type of problem occuring before? Or can anyone suggest possible causes/ways to determine what the possible cause was?
    We have since re-run the offending stage and it completed within 5 minutes.
    Thanks in advance

    There was no answer from here or from Oracle. We use a different process now.

  • Placing an object/photo over gutter in two page layout in Pages???

    So here's my issue. I'm new to pages and need all the help I can get. I have a two page layout and I'm trying to place a large photo across the gutter so that it will show on both pages. It will let me create the object and place a picture in it but it disappears on the other page. What am I not doing? Thanks for your help!
    mrs.rodgers

    Welcome to the forums, mrs. rodgers.
    Do you mean you have an actual two page layout (with "Facing Pages" selected in the Document Inspector)? If so (and it's not just a two column layout on one page), then there is unfortunately no way to set a picture to span two pages automatically.
    Your best bet is to fake the effect by placing two copies of the picture, one on each side of the gutter, with appropriate masks set on each, so that the left page has the left side of the picture, and the right page has the right side. Do note, however, that most printers won't print right to the edge of the page (so-called "borderless" or "full-bleed" printing), and so it may not turn out exactly as you desire.

  • How to use layout of one view(some part) in another view

    Hi All,
                 I need how to use a layout of one view(some part) in another view.if anybody knows, help me.
    Ex : I took two views.but some part of layout in first view is also needed in second view.Is it possible.
    Thank You,
    Anupama.

    Hi,
    Whichever common ui elements you want to put in both views. Keep them in one view.
    Now create two views which You want to display.( i.e you have to create three views in that two only will be used for display purpose ) In that both views add viewcontainer ui element and embedd that view which has common UIs. And Then add rest uncommon UIs in both views.
    I hope it helps.
    Regards,
    Rohit

  • IBNS with two groups of XP Machines, one PEAP-MSCHAPv2 & one EAP-TLS

    Hello,
    I'm planning to implement a IBNS network. We have two groups of XP Machines. One group has machine certs and we're planning to check their certs using EAP-TLS. The second group of machines is managed by other departments, each having their own Active Directory, and configured with PEAP-MSCHAPv2. I'm not very familiar with this kind of setup, so hints are highly appreciated.
    1. Can I assume that, when properly configured, we can differentiate the authorizations per group (for exemple, at least two VLANs one for group 1 and another one for group 2 - I must at least seggregate the users per group and can't mix them in the same environment, since they belong two different departments).
    2. For the first group, no big issue. I can check against my central AD. For the users of the second group, since they can come from different departments, each having its own AD, can I differentiate them, by any means, to know which AD I'll have to query? Or do I have to query only one single AD? Is it required that all the users of group 2 belong to the same domain?
    Thanks in advance for your help.

    Hello,
    I'm planning to implement a IBNS network. We have two groups of XP Machines. One group has machine certs and we're planning to check their certs using EAP-TLS. The second group of machines is managed by other departments, each having their own Active Directory, and configured with PEAP-MSCHAPv2. I'm not very familiar with this kind of setup, so hints are highly appreciated.
    1. Can I assume that, when properly configured, we can differentiate the authorizations per group (for exemple, at least two VLANs one for group 1 and another one for group 2 - I must at least seggregate the users per group and can't mix them in the same environment, since they belong two different departments).
    2. For the first group, no big issue. I can check against my central AD. For the users of the second group, since they can come from different departments, each having its own AD, can I differentiate them, by any means, to know which AD I'll have to query? Or do I have to query only one single AD? Is it required that all the users of group 2 belong to the same domain?
    Thanks in advance for your help.

  • Two layouts in One form

    Hi,
    I want to create two layouts in one form. how can we create that.
    Thanks in Advance.
    Regards,
    Ramana

    Hi all,
    I have one requirement. I have created a form for Medruck and assigned it in nace tcode for purchase order. My requirement is if version number is ' 0 ' one page should be called and if version number is not zero another page layout should be called. I have created 2 different page layouts in my SAP Script i.e. one page named first layout and second named other layout. if version number is 0 first layout should be called and version number ne 0 other layout page should be called. Is it possible to do it? if so, how shall i do this...
    Kindly help me...
    Thanks and regards,
    subbu.

  • How do I copy the same app folder layouts from one device to another? We have a several iphones and ipads.

    how do I copy the same app folder layout from one device to another. We have several apple devices.
    It's a challenge when syncing a device for the first time to go through all the apps and apply them back to the same folders as on your other iphone.
    I've seen suggestions of taking pictures of the correct layout, then manually applying it to the new device. Big time waister.
    What's the work around?
    Thank you

    I'm afraid there is no short workaround. One thing that you could do if you were REALLY desperate is reset your device to factory settings and then restore it from your other device's backup, but that is rather risky and you probably don't want to take your chances just for folder layouts. I would just do it manually.

  • I live in a home with two other people, and one housemate tried to sync up his content from iTunes and iCloud onto another housemate's new iPad. the iTunes library only contains my content. is there any way to retrieve the there person's iCloud?

    i live in a home with two other people, and one housemate tried to sync up his content from iTunes and iCloud onto another housemate's new iPad. the iTunes library only contains my content. is there any way to retrieve the other person's iCloud? Can they go out of my account? Their content is saved on their iPads, but can another iCloud be on the same home computer?

    The syncing of music is one way, computer to phone. See this helpful document from a fellow user. Credit goes to the author.
    https://discussions.apple.com/docs/DOC-3141

  • GUI - How do i merge two diffrent layout managers into one tab?

    Hello
    I want to create a cellphone, and when you click a button it will be displayed in a textfield
    the buttons are in a grid layout (4,3) and the textfield is in a border layout (NORTH)
    I have the layouts in two seperate tabs, but how do i merge two diffrent layouts in to one tab ?
    textfield:
    package guitelefon;
    import java.awt.*;
    import javax.swing.*;
    public class BorderPanel extends JPanel
       public BorderPanel()
          setLayout (new BorderLayout());
          setBackground (Color.green);
          JTextField output = new JTextField(5);
          add (output, BorderLayout.NORTH);
    }Buttons:
    package guitelefon;
    import java.awt.*;
    import javax.swing.*;
    public class GridPanel extends JPanel
        public GridPanel()
          setLayout (new GridLayout (4, 3));
          setBackground (Color.green);
          JButton b1 = new JButton ("1");
          JButton b2 = new JButton ("2");
          JButton b3 = new JButton ("3");
          JButton b4 = new JButton ("4");
          JButton b5 = new JButton ("5");
          JButton b6 = new JButton ("6");
          JButton b7 = new JButton ("7");
          JButton b8 = new JButton ("8");
          JButton b9 = new JButton ("9");
          JButton bs = new JButton ("*");
          JButton b0 = new JButton ("0");
          JButton bf = new JButton ("#");
          add (b1);
          add (b2);
          add (b3);
          add (b4);
          add (b5);
          add (b6);
          add (b7);
          add (b8);
          add (b9);
          add (bs);
          add (b0);
          add (bf);
    }driver:
    package guitelefon;
    //  LayoutDemo.java       Java Foundations
    //  Demonstrates the use of flow, border, grid, and box layouts.
    import javax.swing.*;
    public class LayoutDemo
         public static void main (String[] args)
          JFrame frame = new JFrame ("Cellhpone");
          frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
          JTabbedPane tp = new JTabbedPane();
          tp.addTab ("Grid", new GridPanel());
          tp.addTab ("Border", new BorderPanel());
          frame.getContentPane().add(tp);
          frame.pack();
          frame.setVisible(true);
    }

    a simple example with compilable code:
    import java.awt.BorderLayout;
    import java.awt.GridLayout;
    import javax.swing.*;
    public class Main {
      public static void main(String[] args) {
        JFrame frame = new JFrame("Cellhpone");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        JPanel panel = new JPanel(new BorderLayout());
        panel.add(new FooPanel(), BorderLayout.CENTER);
        panel.add(new BarPanel(), BorderLayout.NORTH);
        frame.getContentPane().add(panel);
        frame.pack();
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
    class FooPanel extends JPanel {
      private static final String[][] BTN_STRINGS = {
        {"1", "2", "3"},
        {"4", "5", "6"},
        {"7", "8", "9"},
        {"*", "0", "#"}};
      public FooPanel() {
        setLayout(new GridLayout(BTN_STRINGS.length, BTN_STRINGS[0].length, 5, 5));
        for (int row = 0; row < BTN_STRINGS.length; row++) {
          for (int col = 0; col < BTN_STRINGS[row].length; col++) {
            JButton btn = new JButton(BTN_STRINGS[row][col]);
            add(btn);
    class BarPanel extends JPanel {
      private JTextField field = new JTextField();
      public BarPanel() {
        setLayout(new BorderLayout());
        add(field, BorderLayout.CENTER);
    }Edited by: Encephalopathic on Oct 29, 2009 7:56 AM

  • Hey, im really sick of this, how can i open folders but in the same windows, when i open a folder which is inside of another one, it just open me a new window, its so annoying, could anyone tell me what to do? im using mac os 10.7.2

    hey, im really sick of this, how can i open folders but in the same windows, when i open a folder which is inside of another one, it just open me a new window, its so annoying, could anyone tell me what to do? im using mac os 10.7.2

    Finder > Preferences > General > Always open folders in a new window: uncheck

  • Importing form field layout from one form to another ?

    I often create forms in both English and French. Many are long and complicated and I have to create them all individually. Is there any way I could use the form field layout from one form, for another form? That would be fantastic.

    Sure. To replace the underlying page contents and retain any fields, document-level code, links, etc., select: Document > Replace Pages
    you will likely have some tweaking to do to some field positions.

  • Group custom page layouts in one group

    down vote
    favorite
    I have created page layouts based on custom content types.
    At the time of creating page from that page layout I want to show my custom page layouts in one group.
    As shown in above image, my page layouts are not shown in single group. Want to show them in single group.
    How can I achieve that?

    Hi,<br/>
    Thanks for reply.<br/>
    Actually I have written code to create content type programmatically.
    Following code creates CT:
    SPContentType parentCT = web.AvailableContentTypes[parentContentType];
    contentType = new SPContentType(parentCT, web.ContentTypes, dispalyNameFromResx);
    contentType.Group = groupName;
    contentType.Description = description;
    web.ContentTypes.Add(contentType);
    contentType.Update();
    I am passing "VDE WebPlus" as contentType.Group, but the page layouts created based on CT do not shown in VDE WebPlus group.
    Page layouts get attached with content type on feature activation using this code:
    PublishingSite pubSite = new PublishingSite(site);
    string vdePageCT = "MyCT";
    SPContentType ct = site.RootWeb.ContentTypes[vdePageCT];
    if (ct != null)
    string pageLayoutName = "VdePage.aspx";
    string layoutURL = site.ServerRelativeUrl + "_catalogs/masterpage/AuthoringLayouts/" + pageLayoutName;
    PageLayout layout = pubSite.PageLayouts[layoutURL];
    layout.AssociatedContentType = ct;
    layout.Update();
    Any suggestion?

  • TThere are now two keyboard layouts" software and hardware" keyboard layout. Why does hardware one a

    Under Settings'/general/keyboards, There are now two keyboard layouts" software and hardware" keyboard layout.  I can easily just pic US in the software one, but the hardware one has three style choices of only arabic keyboards and it requires me to pick one.  So I still get arabic when I hit the globe.  If anyone knows how to solve this one (get rid of it!) i will respect u forever.
    On this discussion board i always hear, go to settings  keyboard and change to US. As explained above, that does not solve the problem, nor many other users I read on here have the same issue as I do.  VERY ANNOYING.

    You are might knight in shining armor.  If u road on,a white steed with a glass of grand marnier I'd marry u! Lol. Oh yea. Im already married to one. Seriously thanks dude, u have no idea how much this has driven me nuts that i couldn't even see an edit button?  Thanxs again!
    Lisa

  • I have two groups for my Coldplay collection. How do I get them back into one group?

    In early 2009, my Coldplay collection jumped from their then-four studio albums to a collection in triple digits. Somewhere along the way, certain songs and albums were going into a separate group called 'Coldplay', just like the regular 'Coldplay'. Countless times, I have gone through each and every song and album in the second group to check for any inconsistincies, but, everything looks identical.
    I am OCD in terms of things belonging where they should and having two groups of the same thing drive me insane.
    When the problem first arose, I was using Windows XP. I received a MacBook Pro for graduation this past May and I used Home Sharing to transfer my music to my new Mac. I was hoping something could be changed, but alas, nothing.
    Any help?

    Look at Steve MacGuire's helpful article:  http://samsoft.org.uk/iTunes/grouping.asp  It explains how to solve this much better than I can.

Maybe you are looking for

  • External Hard Drive Not Found in Finder

    I have an Oxford 120gb external hard drive that I am using with my PPC iMac G5. It is connected via firewire. My computer is not showing the drive on my desktop like it normally does. I have tried using a different firewire cord, using a different fi

  • How do i download office mac 2008, i already have number license (i bought the disc, but can't use them with my macbook air)

    Hello! I'm using a MacBook Air, Processor 1.4 GHz, Memory 4 GB, Software OS X 10.9.4 Years ago I bought office:mac 2008 with 3 licenses, and I want to use one for this MacBook. The problem is that I can't use the disc 'cause it doesn't have CD/DVD dr

  • Write off

    Ability to offset auto write off. We need to see if a write-off payment comes back from the patient say after a year.  If customer pays back after write off is done. we want to reverse write off. Thanks Nik

  • Shuts Down After One Minute?

    I can turn on the Mac and load it all the way to the desktop, but after a minute or so, a pop-up of "Logout, Cancel, Restart, Shutdown" will occur. Even though nothing is pressing against the keyboard, it will turn itself off after a minute. I know t

  • DMG files will not open.  Possibly corrupt installer app?

    I just tried to uninstall Safari 3 Beta and return to the previous version of Safari 2.0. The uninstallation stopped prematurely and told me to try the uninstallation again. I tried, but the dmg file would not load. I rebooted my machine, and it stil