ALMA Computing Group

MySillyPanel.java

Go to the documentation of this file.
00001 /* 00002 * ALMA - Atacama Large Millimiter Array 00003 * (c) European Southern Observatory, 2002 00004 * Copyright by ESO (in the framework of the ALMA collaboration), 00005 * All rights reserved 00006 * 00007 * This library is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU Lesser General Public 00009 * License as published by the Free Software Foundation; either 00010 * version 2.1 of the License, or (at your option) any later version. 00011 * 00012 * This library is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 * Lesser General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU Lesser General Public 00018 * License along with this library; if not, write to the Free Software 00019 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 00020 * MA 02111-1307 USA 00021 */ 00022 package alma.demo.client.guiapps; 00023 00024 import java.awt.Dimension; 00025 import java.awt.event.ActionEvent; 00026 import java.awt.event.ActionListener; 00027 00028 import javax.swing.JButton; 00029 import javax.swing.JPanel; 00030 import javax.swing.JScrollPane; 00031 import javax.swing.JTextArea; 00032 00033 import alma.JavaContainerError.wrappers.AcsJContainerServicesEx; 00034 import alma.acs.container.ContainerServices; 00035 import alma.demo.XmlComponent; 00036 import alma.demo.XmlComponentJ; 00037 import alma.demo.XmlComponentOperations; 00038 import alma.xmljbind.test.schedblock.SchedBlock; 00039 00043 public class MySillyPanel extends JPanel 00044 { 00045 00046 private XmlComponentJ m_xmlCompJ; 00047 00048 private JButton m_butt; 00049 00053 public MySillyPanel(ContainerServices containerServices) throws AcsJContainerServicesEx 00054 { 00055 org.omg.CORBA.Object compObj = containerServices.getComponent("XMLCOMP1"); 00056 XmlComponent xmlComp = alma.demo.XmlComponentHelper.narrow(compObj); 00057 00058 m_xmlCompJ = 00059 (XmlComponentJ) containerServices.getTransparentXmlComponent(XmlComponentJ.class, 00060 xmlComp, 00061 XmlComponentOperations.class); 00062 00063 m_butt = new JButton("Press me for the best SchedBlock..."); 00064 add(m_butt); 00065 00066 final JTextArea textArea = new JTextArea(); 00067 JScrollPane areaScrollPane = new JScrollPane(textArea); 00068 areaScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); 00069 areaScrollPane.setPreferredSize(new Dimension(500, 250)); 00070 add(areaScrollPane); 00071 00072 m_butt.addActionListener(new ActionListener() 00073 { 00074 public void actionPerformed(ActionEvent e) 00075 { 00076 SchedBlock sb = m_xmlCompJ.getBestSchedBlock(); 00077 textArea.append("the best SchedBlock has the unique ID " + 00078 sb.getSchedBlockEntity().getEntityId()); 00079 textArea.append("\n"); 00080 } 00081 } 00082 ); 00083 00084 } 00085 00086 }