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

Similar Messages

  • How do I merge two seperate HD's into one.  I upgraded my MBP to an SSD and installed a hybrid in the optical bay.

    I intially planned to use my cloned system on the SSD and the Hybrid to be used as backup, media, whatever else.  But I only had access to certain program on another MBP and so I cloned it to a partition on the Hybrid.  So basically I have two seperate computers each isolated from one another.  I have two startup disks, 2 seperate everything.  And I have to be careful when syncing my dropbox and a myriad of issues when swithing from one to the other.  So does anyone have any questions about this or any suggestions as to how I can merge the 2 so that I can run the initial configuration I desired.  Oh and the performance between the Momentus XT hybrid and the Intel-520 ssd are getting closer and closer as time goes by that I almost don't notice a difference, grnted my MBP is only backward compatible to 3gbs so I don't get the performance of the 6gbps capabilities of the intel.  But GD its awesome. 
    I really would appreciate any suggestions.  the machine is 15" MBP mid 2010 with 10.8.2.

    I don't know that copying them from an external would be any different than doing it internally because they are physically seperated.  I have tried many different configurations.  It won't let me erase or format the SSD so that I can clone the Hybrid to it. Which is what I prefer to do but I haven't boot from the recovery or an external and tried doing it that way.  But even then I have to boot from each seperately, what is holding me up is I've lost both product keys to office and adobe ms 6 due to the fact of not only having them so long and always upgrade using dmg's as well as upgrading os's so often.  So those programs are only available on one computer. Which happens to be on a seperate internal disk.  A slick unix script would be nice.  I am just really tired of trial and error and would like to get back to using my stuff.

  • How do I merge two different libraries, linked to one account? They're on two different computers but I want them to be on one

    How do I merge two different libraries, linked to one account? They're on two different computers but I want them to be on one

    This should do the trick
    Home Sharing Learn More
    http://support.apple.com/kb/HT201976
    Best of Luck

  • HT204053 How do I join two Apple ID purchases into One?

    How do I join two Apple ID purchases into One?

    You can't, accounts can't be merged nor content transferred from one account to another account - content will remain tied to the account that downloaded it.

  • How do I combine two or more pictures into one?

    How do I combine two or more pictures into one?

    I found out how to do what I wanted and I'm giving my steps in hopes that it might help someone else.  I wanted to put several photos from a file onto a new blank image.  This is what I did.
    1.  Create a blank page.    File/New/ Blank File.   Put in the size.  I used 8x10.
    2.  Bring the photo  you want to use into Elements as you always do. It will list along the top next to the blank sheet.
    3.  Choose SELECT (top of screen)/ Select All.
    4.  Choose Edit/Copy   or Command "C"
    5.  Click on the Blank File.   Chose Edit/Paste  or Command "V"
    6.  Click on Image/ Transform or Command "T".  There should be a dotted line around your pasted image.  You can then move and adjust the image to how you want it.  When finished, press the check-mark on lower right of photo.
    7.   Repeat this with all the photos you want on the new blank file.
    8.  You will see on lower right of Elements,  the background layer and as many layers as you have photos.  These layers need to be permanently placed on the background layer. Go to Layers and press Merge Visible.  This will merge all layers to the background.
    9.  Save as and you are done.

  • How do I combine two user iPhoto files into one...keeps blocking the pics between users

    How do I combine two user iPhoto files into one...keeps blocking the pics between users on the same Mac?

    Put the library on an external hard drive that is formatted as shown in this screenshot:
    OT

  • Is there a  way to merge two separate iTunes accounts into one?

    Is there a  way to merge two separate iTunes accounts into one?  I don't want to "share libraries."  I just want one account that once stemmed from two seperate accounts and has all of the purchases and history.  Thanks for any help!

    No.

  • Is there a way to merge two apple id's into one?

    Is there a way to merge two apple id's into one?

    DBO501 wrote:
    Is there a way to merge two apple id's into one?
    This is not possible...
    From Here   http://support.apple.com/kb/HE37
    I have multiple Apple IDs. Is there a way for me to merge them into a single Apple ID?
    Apple IDs cannot be merged. You should use your preferred Apple ID from now on, but you can still access your purchased items such as music, movies, or software using your other Apple IDs.

  • Merge two Livecycle PDF files into one PDF?

    I have a new requirement where I need to take two different PDF forms I'm producing from LiveCycle and merge them together into a single PDF. 
    I have heard that Adobe Acrobat cannot edit LiveCycle files, does anyone know if it is possible to merge two Livecycle PDFs together into a single file?

    Hello Clay,
    This is not available in the standard SAP Interactive Forms by Adobe solution.
    What I can recommend is:
    Step 1: retrive the data back from the PDF files using the getData functionality of the ADS.
    Step 2: Render a new PDF file. The template of this new PDF should contain the template of both original PDF files.
    This should work if both of the original PDF files were created by the SAP Systems ADS.
    Best regards,
    Dezso

  • Can i merge two apple itunes account into one

    I have two different itunes accts. I would like to merge them into one. So that all my music is located in the same place under one apple Id/itunes account.
    Please help.. by the way some of my music under one id is on a pc and the other is on a mac. Please advise how to make this happen.

    Welcome to the Apple community.
    You can't merge content from two accounts, sorry.

  • For some reason, I have several apple id's.  how do you merge several apple id's into one?

    I have one applied which is used in my iTunes account, another that is used for my MacBook Pro and another that is used for my iPhone 5s  How do I consolidate all of my apple id's into one?

    Apparently, you cannot do that:
    Set up your Apple ID for iCloud and iTunes - Apple Support
    If you have made purchases using more than one ID, call Apple Support and state your case. I have heard that they may be able to do something to help you.
    I do not know why Apple makes it so easy to create Apple IDs; they suggest creating them left and right, but make it very difficult to undo once a person realizes how bad it is to use multiple Apple IDs for the same purpose, for example, iTunes Store, or App Store purchases.

  • How do I combine two I-tunes libraries into one?

    I have an I-tunes library and my daughter has her own.  We would like to combine them into one account.  She has her own account and log in a well as her own appple ID.  I also have my own but seems would make things easier to have one so we can share all of the apps and other things.    Instead of buying the same apps for my phone and then for her ipod touch it would make sense to have it all on one account

    Time flies Goldie.
    I'm back with MAC's any luck with merging.  I have a hundred's of CD's waiting to be downloaded to a hard drive but I just don't trust the constant updating with I-tunes.  The cloud is probably the solution and home sharing.

  • How do I combine two or more CDs into one album?

    How do I combine multiple CDs, like box sets, into one album in iTunes?

    See also Grouping tracks into albums.
    tt2

  • How to merge two separate Muse files into one file?

    Have 220 pages built for a website, client wants to add another 180 pages. The Muse file is already slow to load and cumbersome to work with at 220 pages, it's going to be much worse at 400 pages. Is there a way to create two separate Muse files and then merge them prior to publish (or at publish, or post-publish). The only other solution I have is to build the second batch of pages in a separate file, then copy them into the main file one by one. Is there a batch copy/paste? Is there a merge?

    Hello,
    It's not possible to merge muse files as such. The pages have to either be created in the same file or they must be copied over individually later on from the other file to this file.
    Cheers
    Parikshit

  • How do I combine two groups of podcasts into one

    I have a particular podcast that I have been listening to for a long time (This Week in Tech). I decided to archive all of the episodes and pull them off of my machine. However, I have noticed that the first 20 or so are not grouped with the remaining ones. In iTunes if I click on 'Podcasts' in sidebar, the first 20 or so TWIT podcasts show up as a podcast called 'The Best Article Ever' where as the remaining 170 show up as they should as 'this week in tech'.
    I looked through all of the information in the 'get info' window and it does not contain the name 'The Best Article Ever'. However, if I 'Right-click' on one of the early podcasts, and select 'Show Description' instead of 'Get Info' then the resulting window shows up and indicates that the podcast name is 'The Best Article Ever'.
    I can not find any way to change this information in the 'Show Description' window.
    I am assuming that if I can, then the early podcasts will then be grouped with the newer ones.
    Any help if appreciated,
    John

    I found out how to do what I wanted and I'm giving my steps in hopes that it might help someone else.  I wanted to put several photos from a file onto a new blank image.  This is what I did.
    1.  Create a blank page.    File/New/ Blank File.   Put in the size.  I used 8x10.
    2.  Bring the photo  you want to use into Elements as you always do. It will list along the top next to the blank sheet.
    3.  Choose SELECT (top of screen)/ Select All.
    4.  Choose Edit/Copy   or Command "C"
    5.  Click on the Blank File.   Chose Edit/Paste  or Command "V"
    6.  Click on Image/ Transform or Command "T".  There should be a dotted line around your pasted image.  You can then move and adjust the image to how you want it.  When finished, press the check-mark on lower right of photo.
    7.   Repeat this with all the photos you want on the new blank file.
    8.  You will see on lower right of Elements,  the background layer and as many layers as you have photos.  These layers need to be permanently placed on the background layer. Go to Layers and press Merge Visible.  This will merge all layers to the background.
    9.  Save as and you are done.

Maybe you are looking for

  • How can I read my ebook on a hand held?

    I bought $350 worth of ebooks from ebooks.com. They have no support and refer all of their technical questions to Adobe, so I hope someone from here can answer me. These are the instructions on how to transfer the ebook to the hand held on the ebooks

  • Issues with Thinkpad yoga on Windows 7 64-bit

    I uninstalled the windows 8.1 that came with my Thinkpad Yoga to installe windows 7 64-bit because there was no support for Power Manager ( a tool that allows you to charge your battery only upto a certain percentage (eg 40%) which helps reduce batte

  • Adobe acrobat DC download trial not working

    Hi, I've tried downloading & installing the trial 2 times, however whenever I click on 'launch acrobat' nothing happens. Is there another way to download and install the trial? Thanks

  • Excel to Adobe losing characters

    Hi all This has just started happening and was intermittent but now all the time? When I preview or print an Excel doc it looks ok, but when I choose Adobe PDF printer driver it previews (and prints) with text chopped off on the far right side. Can a

  • Acrobat 8 - Adobe PDF Printer hanging when printing

    Hi I have an installation of Adobe CS3 Design Standard on a Windows 7 64-bit machine. When attempting to use the 'Adobe PDF' printer from an Adobe application, i.e. Illustrator, Photoshop, the application freezes and the PDF printer does not proceed