Need help in Java using swing tools

kuruganti

kuruganti

@kuruganti-owqz7r Oct 20, 2024
How can we build a app that has 4 boxes and on clicking them boxes can be joined to other .
Needd urgently ...
plz help me out

Replies

Welcome, guest

Join CrazyEngineers to reply, ask questions, and participate in conversations.

CrazyEngineers powered by Jatra Community Platform

  • Morningdot Hablu

    Morningdot Hablu

    @morningdot-6Xuj4M Jan 8, 2011

    It's a simple thing to do buddy...where you find problem in doing so....?
    try to use setVisible().
    Check this...
    import java.awt.*;
    import java.applet.*;
    import java.awt.event.*;
    /*<Applet code="ne" height=400 width=400></applet>*/
    public class ne extends Applet implements ActionListener
    {
        Button b[]=new Button[3];
        int i;
        public void init()
        {
            for(i=0;i<=2;i++)
            {
                b[i]=new Button("mohit");
                add(b[i]);
                b[i].addActionListener(this);    
            }
        }
        public void actionPerformed(ActionEvent e)
        {
            repaint();
            b[0].setVisible(false);
            b[1].setVisible(false);
        }
        public void paint(Graphics g)
        {
            
        }
    }