Results 1 to 2 of 2
  1. #1
    sachinsharma is offline Member
    Join Date
    Jan 2012
    Posts
    1
    Rep Power
    0

    Default how to set JInternalFrame ? (specific case)

    Hi All,

    Actually i am making a project in which i want to to display all the details of a particular entity on a
    button click in a new JInternalFrame...However, when I do so and add the internal frame on to the
    JFrame it appears as a small minimum sized window because the Layout of my JFrame is FlowLayout.
    If i change the layout of JFrame then the other components in JFrame get disordered...Can you please suggest me any efficient way to achieve this??
    Here's my piece of code..


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

    public class File1 implements ActionListener
    {
    JFrame f;
    JButton[] b = new JButton[50];
    int i;

    public File1()
    {

    f = new JFrame("Title");

    for(i=0;i<50;i++)
    {
    b[i] = new JButton(String.valueOf(i+1));
    b[i].addActionListener(this);
    f.add(b[i]);
    }


    f.setLayout(new FlowLayout());
    f.setSize(500,500);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setVisible(true);

    }

    public void actionPerformed(ActionEvent e)
    {
    JButton b1 = (JButton) e.getSource();
    int no = Integer.parseInt(b1.getText());

    try
    {
    /*JDBC CODE*/

    JInternalFrame jif = new JInternalFrame("Number: "+b1.getText(),false,true);

    f.setLayout(new BorderLayout());
    jif.setVisible(true);
    f.add(jif);


    }
    catch(Exception ae)
    {
    JOptionPane.showMessageDialog(null,ae.toString());
    }
    }


    public static void main(String args[])
    {
    File1 obj = new File1();
    }
    }



    Please HELP...!!

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,202
    Rep Power
    19

    Default Re: how to set JInternalFrame ? (specific case)

    Read the API for JInternalFrame and follow the link to the Swing tutorial on How to Use Internal Frames, where you will find working examples of how to correctly use internal frames in a JDesktopPane.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Replies: 1
    Last Post: 09-27-2011, 04:19 PM
  2. Replies: 4
    Last Post: 09-27-2011, 09:20 AM
  3. Replies: 0
    Last Post: 08-09-2011, 06:07 PM
  4. JInternalFrame Help
    By collin389 in forum AWT / Swing
    Replies: 1
    Last Post: 03-15-2010, 09:24 PM
  5. Replies: 2
    Last Post: 11-08-2008, 10:40 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
  •