use of javax.swing.JInternalFrame in project JMRI by JMRI.
the class ThrottleFrame method getXml.
/**
* Collect the prefs of this object into XML Element
* <ul>
* <li> Window prefs
* <li> ControlPanel
* <li> FunctionPanel
* <li> AddressPanel
* </ul>
*
*
* @return the XML of this object.
*/
public Element getXml() {
boolean switchAfter = false;
if (!isEditMode) {
switchMode();
switchAfter = true;
}
Element me = new Element("ThrottleFrame");
if (((javax.swing.plaf.basic.BasicInternalFrameUI) getControlPanel().getUI()).getNorthPane() != null) {
Dimension bDim = ((javax.swing.plaf.basic.BasicInternalFrameUI) getControlPanel().getUI()).getNorthPane().getPreferredSize();
me.setAttribute("border", Integer.toString(bDim.height));
}
java.util.ArrayList<Element> children = new java.util.ArrayList<Element>(1);
// children.add(WindowPreferences.getPreferences(this)); // not required as it is in ThrottleWindow
children.add(controlPanel.getXml());
children.add(functionPanel.getXml());
children.add(addressPanel.getXml());
// Save Jynstruments
Component[] cmps = getComponents();
for (int i = 0; i < cmps.length; i++) {
try {
if (cmps[i] instanceof JInternalFrame) {
Component[] cmps2 = ((JInternalFrame) cmps[i]).getContentPane().getComponents();
int j = 0;
while ((j < cmps2.length) && (!(cmps2[j] instanceof Jynstrument))) {
j++;
}
if ((j < cmps2.length) && (cmps2[j] instanceof Jynstrument)) {
Jynstrument jyn = (Jynstrument) cmps2[j];
Element elt = new Element("Jynstrument");
elt.setAttribute("JynstrumentFolder", FileUtil.getPortableFilename(jyn.getFolder()));
java.util.ArrayList<Element> jychildren = new java.util.ArrayList<Element>(1);
jychildren.add(WindowPreferences.getPreferences((JInternalFrame) cmps[i]));
Element je = jyn.getXml();
if (je != null) {
jychildren.add(je);
}
elt.setContent(jychildren);
children.add(elt);
}
}
} catch (Exception ex) {
log.debug("Got exception (no panic) " + ex);
}
}
me.setContent(children);
if (switchAfter) {
switchMode();
}
return me;
}
use of javax.swing.JInternalFrame in project jdk8u_jdk by JetBrains.
the class MetalworksFrame method openInBox.
public void openInBox() {
JInternalFrame doc = new MetalworksInBox();
desktop.add(doc, DOCLAYER);
try {
doc.setVisible(true);
doc.setSelected(true);
} catch (java.beans.PropertyVetoException e2) {
}
}
use of javax.swing.JInternalFrame in project JMRI by JMRI.
the class JmriJInternalFrameInterface method show.
@Override
public void show(final jmri.util.swing.JmriPanel child, jmri.util.swing.JmriAbstractAction act, Hint hint) {
// create new internal frame
JInternalFrame frame = new JInternalFrame(child.getTitle(), //resizable
true, //closable
true, //maximizable
true, //iconifiable
true);
frame.setLocation(50, 50);
// add gui object, responsible for own layout
frame.add(child);
// add menus if requested
JMenuBar bar = frame.getJMenuBar();
if (bar == null) {
bar = new JMenuBar();
}
List<JMenu> list = child.getMenus();
for (JMenu menu : list) {
bar.add(menu);
}
// to code in JmriJFrame
if (child.getHelpTarget() != null) {
// add Help menu
jmri.util.HelpUtil.helpMenu(bar, child.getHelpTarget(), true);
}
frame.setJMenuBar(bar);
// set title if available
if (child.getTitle() != null) {
frame.setTitle(child.getTitle());
}
// arrange to run dispose on close
//frame.addWindowListener( new java.awt.event.WindowAdapter(){
// jmri.util.swing.JmriPanel c;
// { c = child; }
// public void windowClosed(java.awt.event.WindowEvent e) {
// c.dispose();
// }
//});
// add to desktop
frame.pack();
frame.setVisible(true);
desktop.add(frame);
frame.moveToFront();
}
use of javax.swing.JInternalFrame in project sic by belluccifranco.
the class PrincipalGUI method mnu_CajasActionPerformed.
//GEN-LAST:event_mnuItm_PedidosActionPerformed
private void mnu_CajasActionPerformed(java.awt.event.ActionEvent evt) {
//GEN-FIRST:event_mnu_CajasActionPerformed
JInternalFrame gui = Utilidades.estaEnDesktop(getDesktopPane(), CajasGUI.class);
if (gui == null) {
gui = new CajasGUI();
gui.setLocation(getDesktopPane().getWidth() / 2 - gui.getWidth() / 2, getDesktopPane().getHeight() / 2 - gui.getHeight() / 2);
getDesktopPane().add(gui);
gui.setVisible(true);
} else {
//selecciona y trae al frente el internalframe
try {
gui.setSelected(true);
} catch (PropertyVetoException ex) {
String msjError = "No se pudo seleccionar la ventana requerida.";
LOGGER.error(msjError + " - " + ex.getMessage());
JOptionPane.showInternalMessageDialog(this.getDesktopPane(), msjError, "Error", JOptionPane.ERROR_MESSAGE);
}
}
}
use of javax.swing.JInternalFrame in project sic by belluccifranco.
the class PrincipalGUI method mnuItm_FacturasVentaActionPerformed.
//GEN-LAST:event_mnuItm_IrTPVActionPerformed
private void mnuItm_FacturasVentaActionPerformed(java.awt.event.ActionEvent evt) {
//GEN-FIRST:event_mnuItm_FacturasVentaActionPerformed
JInternalFrame gui = Utilidades.estaEnDesktop(getDesktopPane(), FacturasVentaGUI.class);
if (gui == null) {
gui = new FacturasVentaGUI();
gui.setLocation(getDesktopPane().getWidth() / 2 - gui.getWidth() / 2, getDesktopPane().getHeight() / 2 - gui.getHeight() / 2);
getDesktopPane().add(gui);
gui.setVisible(true);
} else {
//selecciona y trae al frente el internalframe
try {
gui.setSelected(true);
} catch (PropertyVetoException ex) {
String msjError = "No se pudo seleccionar la ventana requerida.";
LOGGER.error(msjError + " - " + ex.getMessage());
JOptionPane.showInternalMessageDialog(this.getDesktopPane(), msjError, "Error", JOptionPane.ERROR_MESSAGE);
}
}
}
Aggregations