Results 1 to 2 of 2
  1. #1
    banie is offline Member
    Join Date
    Jan 2008
    Posts
    21
    Rep Power
    0

    Default Merge 2 button become one

    Hi..

    I'm newbie in this java. Need help here.. I want to merge button 10 and 14 become one. How to do that?

    import java.awt.*;

    public class GridExample {
    private Frame f;
    private Button b1, b2, b3, b4, b5, b6, b7, b8, b9;
    private Button b10, b11, b12, b13, b14, b15, b16, b17, b18, b19;
    private Button b20, b21, b22, b23, b24, b25, b26;

    public GridExample() {
    f = new Frame("Contoh Grid");
    b1 = new Button("1");
    b2 = new Button("2");
    b3 = new Button("3");
    b4 = new Button("4");
    b5 = new Button("5");
    b6 = new Button("6");
    b7 = new Button("7");
    b8 = new Button("8");
    b9 = new Button("9");
    b10 = new Button("10");
    b11 = new Button("11");
    b12 = new Button("12");
    b13 = new Button("13");
    b14 = new Button("14");
    b15 = new Button("15");
    b16 = new Button("16");
    b17 = new Button("17");
    b18 = new Button("18");

    }

    public void launchFrame() {
    f. setLayout (new GridLayout(5,6));

    f.add(b1);
    f.add(b2);
    f.add(b3);
    f.add(b4);
    f.add(b5);
    f.add(b6);
    f.add(b7);
    f.add(b8);
    f.add(b9);
    f.add(b10);
    f.add(b11);
    f.add(b12);
    f.add(b13);
    f.add(b14);
    f.add(b15);
    f.add(b16);
    f.add(b17);
    //b13.setHgap(2);

    f.setSize(200,200);
    b1.setVisible(false);
    b2.setVisible(false);
    b6.setVisible(false);
    b2.setVisible(false);
    b3.setVisible(false);
    b4.setVisible(false);
    //b7.setVisible(false);
    b8.setVisible(false);
    //b9.setVisible(false);
    //f.pack();
    f.setVisible(true);
    }

    public static void main (String[] args) {
    GridExample grid = new GridExample();
    grid.launchFrame();
    }
    }

  2. #2
    hardwired's Avatar
    hardwired is offline Senior Member
    Join Date
    Jul 2007
    Posts
    1,576
    Rep Power
    9

    Default

    I don't think you can do it so well with GridLayout. Depends on what you want to do with your grid. I would consider drawing a grid, use an int or boolean array to track/control visibility.

Similar Threads

  1. Merge Two Xml files ????
    By alwz_nikhil in forum XML
    Replies: 5
    Last Post: 01-18-2011, 09:18 AM
  2. Merge Sort in Java
    By Java Tip in forum Algorithms
    Replies: 0
    Last Post: 04-15-2008, 07:43 PM
  3. Replies: 1
    Last Post: 03-27-2008, 05:06 PM
  4. Merge Sort Help
    By Hollywood in forum New To Java
    Replies: 5
    Last Post: 01-30-2008, 03:26 AM
  5. PDF Split and Merge 0.7 beta 1
    By JavaBean in forum Java Software
    Replies: 0
    Last Post: 06-24-2007, 08:46 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •