CrazyEngineers
  • I have created a frame..see uploaded file...if we resize it ..I want controls (labels,textboxes,button) arranged properly and size according to frame size...
    Control's size should be arranged as per frame's current size..
    and i want to do same with controls of all frames ....how can I do it...help me with code...
    Replies
Howdy guest!
Dear guest, you must be logged-in to participate on CrazyEngineers. We would love to have you as a member of our community. Consider creating an account or login.
Replies
  • Kaustubh Katdare

    AdministratorNov 7, 2012

    Updated the thread title.
    Are you sure? This action cannot be undone.
    Cancel
  • rahul69

    MemberNov 12, 2012

    Hi, for resizing the controls, u should first get the current size of window, whenever the size is changed and then adjust the size of all controls with respect to the current size.
    Also plz show the code u attempted, if u want to get help with the code.😀
    Are you sure? This action cannot be undone.
    Cancel
  • ultimatechange

    MemberNov 22, 2012

    import javax.swing.*;
    import java.awt.*;
    import java.sql.*;
    import java.awt.event.*;

    public class abc extends JFrame implements ActionListener
    {

    JButton b1;
    JLabel l1, l2;
    JTextField t1, t2;

    public abc()
    {
    setTitle("WELCOME"); //Title for JFrame
    setLayout(null);
    //YOU CAN ALSO do
    setResizable(false); //i.e Disabling JFrame resizing- Maximize button is DISABLED & also cannot manually resize window using mouse

    l1= new JLabel("jLabel1");
    t1= new JTextField(25);
    l1.setBounds(85,100,100,20); // setting the location of LABEL1
    t1.setBounds(150,100,200,20); // setting the location of Field1

    l2= new JLabel("jLabel2");
    t2= new JTextField(25);
    l2.setBounds(85,130,100,20); // setting the location of LABEL2
    t2.setBounds(150,130,200,20); // setting the location of Field2

    //b1= new JButton("jButton1");
    b1.setBounds(165,170,80,20); // setting the location of BUTTON

    add(l1);
    add(t1);
    add(l2);
    add(t2);
    add(b1);

    setSize(500,400); //Set JFrame size
    setVisible(true); //Make JFrame visible. So we can see it.
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //Set default close operation for JFrame

    b1.addActionListener(this);
    }
    public void actionPerformed(ActionEvent ae)
    {
    String str = ae.getActionCommand();
    // your events .............................mention here
    }
    public static void main(String args[])
    {
    new abc();
    }
    }


    In case need any further help, just let me know
    }
    Are you sure? This action cannot be undone.
    Cancel
Home Channels Search Login Register