package br.com.solutec.gestor.gui;
/**
*
* @author Rodrigo Rocha
*/
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import java.beans.*;
public class ModalInternal extends javax.swing.JInternalFrame {
JPanel glass = new JPanel();
public ModalInternal() {
}
public ModalInternal(JRootPane rootPane, Component desktop) {
initComponents();
jComboBox1.addItem("TEste");
jComboBox1.addItem("TEste1");
jComboBox1.addItem("TEste2");
glass.setOpaque(false);
// Attach mouse listeners
MouseInputAdapter adapter = new MouseInputAdapter(){};
glass.addMouseListener(adapter);
glass.addMouseMotionListener(adapter);
// Define close behavior
putClientProperty("JInternalFrame.frameType",
"optionDialog");
// Size frame
Dimension size = getPreferredSize();
Dimension rootSize = desktop.getSize();
setBounds((rootSize.width - size.width) / 2,
(rootSize.height - size.height) / 2,
size.width, size.height);
desktop.validate();
try {
setSelected(true);
} catch (PropertyVetoException ignored) {
}
// Add modal internal frame to glass pane
glass.add(this);
// Change glass pane to our panel
rootPane.setGlassPane(glass);
// Show glass pane, then modal dialog
glass.setVisible(true);
}
public void setVisible(boolean value) {
super.setVisible(value);
if (value) {
startModal();
} else {
stopModal();
}
}
private synchronized void startModal() {
try {
if (SwingUtilities.isEventDispatchThread()) {
EventQueue theQueue =
getToolkit().getSystemEventQueue();
while (isVisible()) {
AWTEvent event = theQueue.getNextEvent();
Object source = event.getSource();
if (event instanceof ActiveEvent) {
((ActiveEvent)event).dispatch();
} else if (source instanceof Component) {
((Component)source).dispatchEvent(
event);
} else if (source instanceof MenuComponent) {
((MenuComponent)source).dispatchEvent(
event);
} else {
System.err.println(
"Unable to dispatch: " + event);
}
}
} else {
while (isVisible()) {
wait();
}
}
} catch (InterruptedException ignored) {
}
}
private synchronized void stopModal() {
notifyAll();
}
private void initComponents() {
java.awt.GridBagConstraints gridBagConstraints;
jButton1 = new javax.swing.JButton();
jComboBox1 = new javax.swing.JComboBox();
getContentPane().setLayout(new java.awt.GridBagLayout());
setPreferredSize(new java.awt.Dimension(400, 300));
jButton1.setText("jButton1");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
gridBagConstraints.gridheight = 2;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
gridBagConstraints.insets = new java.awt.Insets(11, 53, 238, 0);
getContentPane().add(jButton1, gridBagConstraints);
jComboBox1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jComboBox1ActionPerformed(evt);
}
});
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 0;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
gridBagConstraints.insets = new java.awt.Insets(10, 164, 0, 196);
getContentPane().add(jComboBox1, gridBagConstraints);
pack();
}
private void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
try {
setClosed(true);
} catch (PropertyVetoException ignored) {
}
ModalInternal.this.setVisible(false);
glass.setVisible(false);
}
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JComboBox jComboBox1;
// End of variables declaration
}
O problema é o seguinte o combo box não me lista as opções, se eu deixar o formulário menor q a lista do combo ele me aparece atraz do formulário o q posso fazer?