File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes How can i display minimize and iconifiable button in JInternalFrame Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How can i display minimize and iconifiable button in JInternalFrame" Watch "How can i display minimize and iconifiable button in JInternalFrame" New topic
Author

How can i display minimize and iconifiable button in JInternalFrame

Brijesh Sah
Greenhorn

Joined: Jan 22, 2009
Posts: 9
Hi All,

My code is as follows:

package practise;


public class ItemForm extends javax.swing.JInternalFrame {

/** Creates new form ItemForm */
public ItemForm() {
super("Item Form",true, true, true, true);
initComponents();
}


private void initComponents() {

setClosable(true);
setIconifiable(true);
setMaximizable(true);
setResizable(true);
setTitle("Item Form");
setMaximumSize(new java.awt.Dimension(800, 600));

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 394, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 278, Short.MAX_VALUE)
);

pack();
}

But Minimize and iconifiable buttons are not displaying on the JIntenalFrame.

Neither I am able to resize the window. Please help.....

Thanks
Brijesh
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
> But Minimize and iconifiable buttons are not displaying on the JIntenalFrame.
> Neither I am able to resize the window. Please help.....

worked fine for me.

perhaps posting a full working (non-working?) program might help resolve your problem
Brijesh Sah
Greenhorn

Joined: Jan 22, 2009
Posts: 9
see the attached image

in Item form no minimize and iconifiable button only close button


[Thumbnail for form2.JPG]

Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
> see the attached image

means zip, without the code.
Brijesh Sah
Greenhorn

Joined: Jan 22, 2009
Posts: 9

Code As Follows:

MainForm.java // It will display the main form with menu

package practise;


public class MainForm extends javax.swing.JFrame {

/** Creates new form MainForm */
public MainForm() {
initComponents();
}


private void initComponents() {

jContainer = new javax.swing.JDesktopPane();
jMenuBar1 = new javax.swing.JMenuBar();
jMenu1 = new javax.swing.JMenu();
mnuCustomer = new javax.swing.JMenuItem();
mnuItem = new javax.swing.JMenuItem();
jMenu2 = new javax.swing.JMenu();
jMenuItem3 = new javax.swing.JMenuItem();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

jMenu1.setText("Forms");

mnuCustomer.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_X, java.awt.event.InputEvent.ALT_MASK));
mnuCustomer.setText("Customer");
mnuCustomer.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
mnuCustomerActionPerformed(evt);
}
});
jMenu1.add(mnuCustomer);

mnuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_I, java.awt.event.InputEvent.ALT_MASK));
mnuItem.setText("Item");
mnuItem.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
mnuItemActionPerformed(evt);
}
});
jMenu1.add(mnuItem);

jMenuBar1.add(jMenu1);

jMenu2.setText("File");

jMenuItem3.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_X, java.awt.event.InputEvent.ALT_MASK));
jMenuItem3.setText("Exit");
jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem3ActionPerformed(evt);
}
});
jMenu2.add(jMenuItem3);

jMenuBar1.add(jMenu2);

setJMenuBar(jMenuBar1);

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jContainer, javax.swing.GroupLayout.DEFAULT_SIZE, 418, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jContainer, javax.swing.GroupLayout.DEFAULT_SIZE, 289, Short.MAX_VALUE)
.addContainerGap())
);

pack();
}

private void mnuCustomerActionPerformed(java.awt.event.ActionEvent evt) {
CustomerView cv=new CustomerView();
jContainer.add(cv);
cv.setVisible(true);
}

private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {
System.exit(0);
}

private void mnuItemActionPerformed(java.awt.event.ActionEvent evt) {
ItemForm iv=new ItemForm();
jContainer.add(iv);
iv.setVisible(true);
}

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new MainForm().setVisible(true);
}
});
}

// Variables declaration - do not modify
private javax.swing.JDesktopPane jContainer;
private javax.swing.JMenu jMenu1;
private javax.swing.JMenu jMenu2;
private javax.swing.JMenuBar jMenuBar1;
private javax.swing.JMenuItem jMenuItem3;
private javax.swing.JMenuItem mnuCustomer;
private javax.swing.JMenuItem mnuItem;
// End of variables declaration

}


then ItemForm.java // code pasted on first part
but i am not getting the buttons
is it clear or i will paste here only

Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19556
    
  16

Please Use Code Tags. You can edit your post to add them.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Brijesh Sah
Greenhorn

Joined: Jan 22, 2009
Posts: 9
I am editing my question. Please go through my problem and give me a solution.

MainForm.java // This class will display the main window and it will act as MDI form






I am not getting the minimize or iconifiable button on the screen. Neither I am able to resize the window. Please help.

If you can give any other way to do the make MDI form in java. Then also i am fine with that.
Thanks

Brijesh
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19556
    
  16

You still hadn't used code tags. I've added them for you this once, and you can see how much better it looks.
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
again, worked fine for me - clicking Forms/Item, JInternalFrame appeared, with all buttons (working).

perhaps an OS or version problem - I'm using java 1.6.0_15 on Vista Home Premium

in the code you posted there's no advantage in extending JInternalFrame (you may be adding code later),
so see if it makes any difference using a standard JInternalFrame

 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How can i display minimize and iconifiable button in JInternalFrame
 
Similar Threads
running a video instance
problem in swing tool bar
JPanel Form Problems
JInternalFrame doesn't show anymore after closing
Maximizing a form (JFrame) by default when it opens