Drawing graphic component using parsed file

hi,
I have a problem in drawing the graphic components like rectangle,oval etc. I need to draw them on a panel after selecting a xml file from menu,parse it first, based on the contents of the parsed file the dimentions of the component should change.
however i am able to parse the file and save the parsed contents in a separate file, but unable to draw components using its contents

this is the module given to me where i am supposed to
draw the graphic components using the contents of a
xml file. I was told to parse the xml file to get
some values that would represent parameters like
packet size, length etc.. and using these values
draw a data packet representation. But prob here is
the i am able to parse file but not pass its values
simultaneously to draw image on the panel
immediately after parsing. i am storin the contents
in the text format.
ya i have good knowlege of swings,IO and awt...Parse the XML file filling a model that allows listeners (Observer/Observable is one approach). When the parsing is complete fire an event to indicate that the model has changed. Have your GUI listen to the model and when it receive the 'changed' event it updates it's display according to the content of the model.

Similar Messages

  • Draw graphics in ABAP

    Hi,
    i'm looking for a way to draw graphics in my SAP-GUI. I need really drawing, not only charts.
    I searched the forum for this topic, and found the solution via a HTML-Control with SVG.
    Basicly this is exactly what im looking for, but isn't there any other way?? In best case a solution, that don't need a plug-in..

    Hi Bernd
    For pictures you can use the class "cl_gui_picture". You can find more in the demo program Nablan mentioned.
    It may also be OK to use an HTML viewer if possible. It can be instantiated from the class "cl_gui_html_viewer"
    To store your picture files you can use the Web Repository.
    To draw graphics, you can use "GRAPH_MATRIX_*" function modules. You can inspect those.
    A better way that I would prefer to draw graphics, is using GFW (Graphical FrameWork). Inspect demo programs "GFW_DEMO_*" for those.
    Hope this clue helps...
    *--Serdar

  • Error message when using DOMParser.parse(file)

    When I try to use the DOMParser.parse(file) to parse an invalid XML file against a XML schema, with the schema_validation feature set on, error message saying the XML file is invalid because it violates some constraints set in the schema. But I cannot find out how the error message is print. It is not caught as exception. May I know how can I detect the error in the code instead of viewing it as output?

    The error message I got is like the followings:
    [Error] abc3.xml:2:310: cvc-pattern-valid: Value '' is not facet-valid with respect to pattern '(\(\d\d\d\)-)?[\d]{8}' for type 'phoneNoType'.
    [Error] abc3.xml:2:310: cvc-type.3.1.3: The value '' of element 'mobile' is not valid.
    [Error] abc3.xml:2:318: cvc-pattern-valid: Value '' is not facet-valid with respect to pattern '[^@]+@[^\.]+\..+' for type 'emailAddressType'.
    [Error] abc3.xml:2:318: cvc-type.3.1.3: The value '' of element 'email' is not v
    alid.
    May I know how can I catch these errors?

  • Portal XML Component Application Parse Error

    Has anyone tried to use Portal's XML Component application to pull XML data out of iFS via URLs successfully? I've loaded an XML instance and XML style sheet in iFS (that parse fine in XMLSpy) and tried to display them using the Portal XML Component application. I've also tried to cut/paste the instance and style sheet in to the Component's GUI directly and received the same error. The component finds the files in iFS fine, but generates the following error:
    Start of root element expected. at oracle.xml.parser.v2.XMLError.flushErrors(XMLError.java) at oracle.xml.parser.v2.XMLError.error(XMLError.java) at oracle.xml.parser.v2.XMLError.error(XMLError.java) at oracle.xml.parser.v2.NonValidatingParser.parseRootElement(NonValidatingParser.java) at oracle.xml.parser.v2.NonValidatingParser.parseDocument(NonValidatingParser.java) at oracle.xml.parser.v2.XMLParser.parse(XMLParser.java) at oracle.webdb.xmlcomp.XMLTransDoc.Transform(XMLTransDoc.java:136)
    Oracle's sample data works fine too..
    Seems like a basic error, but I can't correct it.. THanks in advance for any help, Tim

    trying files again..
    XML instance:
    <US_FOREIGN_MISSION>
         <ap>
              <metadata>
                   <administrative>
                        <identifiers/>
                        <publisher>
                             <organization agency="AFMIC"/>
                        </publisher>
                        <dates/>
                   </administrative>
                   <descriptive>
                        <security/>
                        <title>
                             <portionmark/>
                             <text/>
                        </title>
                        <subtitle>
                             <portionmark>
                                  <US-SECURITY>
                                       <US-CLASS CLASS="UNCLASSIFIED"/>
                                  </US-SECURITY>
                             </portionmark>
                             <text>U.S. Foreign Mission</text>
                        </subtitle>
                        <locations>
                             <country CCODE="GRC"/>
                        </locations>
                        <subjects>
                             <code/>
                        </subjects>
                   </descriptive>
              </metadata>
              <apsummary>
                   <unknown/>
              </apsummary>
              <amplification>
                   <para>
                        <portionmark>
                             <US-SECURITY>
                                  <US-CLASS CLASS="UNCLASSIFIED"/>
                             </US-SECURITY>
                        </portionmark>
                        <text>No information available.</text>
                   </para>
              </amplification>
         </ap>
         <US_EMBASSY>
              <ap>
                   <metadata>
                        <administrative>
                             <identifiers/>
                             <publisher>
                                  <organization agency="MCIA"/>
                             </publisher>
                             <dates/>
                        </administrative>
                        <descriptive>
                             <security/>
                             <title>
                                  <portionmark/>
                                  <text/>
                             </title>
                             <subtitle>
                                  <portionmark>
                                       <US-SECURITY>
                                            <US-CLASS CLASS="UNCLASSIFIED"/>
                                       </US-SECURITY>
                                  </portionmark>
                                  <text>U.S. Embassy</text>
                             </subtitle>
                             <locations>
                                  <country CCODE="GRC"/>
                             </locations>
                             <subjects>
                                  <code/>
                             </subjects>
                        </descriptive>
                   </metadata>
                   <apsummary>
                        <summary>
                             <para>
                                  <portionmark>
                                       <US-SECURITY>
                                            <US-CLASS CLASS="UNCLASSIFIED"/>
                                       </US-SECURITY>
                                  </portionmark>
                                  <text>The U.S. Ambassador is Thomas M.T. Niles and the                     Embassy is located
    at 91 Vasilissis Sophias Boulevard, 10160 Athens; telephone                     [30] (1) 721-2951,
    8401; fax [30] (1) 645-6282. The mailing address is PSC 108,                     Athens; APO
    AE 09842. The Consulate General is in Thessaloniki at the Plateia                     Commercial
    Center, 43 Tsimiski Street, 7th floor; telephone [30] (31)                     242-905.</text>
                             </para>
                             <media>
                                  <portionmark>
                                       <US-SECURITY>
                                            <US-CLASS CLASS="UNCLASSIFIED"/>
                                       </US-SECURITY>
                                  </portionmark>
                                  <graphic file="http://198.83.203.22/public/Graphics/Embassy.jpg" exhibit_id="U.S. Embassy" hplace="center" vplace="none"/>
                                  <title>
                                       <portionmark>
                                            <US-SECURITY>
                                                 <US-CLASS CLASS="UNCLASSIFIED"/>
                                            </US-SECURITY>
                                       </portionmark>
                                       <text>U.S. Embassy</text>
                                  </title>
                             </media>
                             <para>
                                  <portionmark>
                                       <US-SECURITY>
                                            <US-CLASS CLASS="UNCLASSIFIED"/>
                                       </US-SECURITY>
                                  </portionmark>
                                  <text>Chief of Mission: Ambassador                     Thomas M.T. Niles</text>
                             </para>
                             <para>
                                  <portionmark>
                                       <US-SECURITY>
                                            <US-CLASS CLASS="UNCLASSIFIED"/>
                                       </US-SECURITY>
                                  </portionmark>
                                  <text>Local Address: 91 Vasilissis Sophias                     Boulevard, 10160 Athens</text>
                             </para>
                             <para>
                                  <portionmark>
                                       <US-SECURITY>
                                            <US-CLASS CLASS="UNCLASSIFIED"/>
                                       </US-SECURITY>
                                  </portionmark>
                                  <text>Mailing Address: PSC 108, Athens; APO AE                     09842</text>
                             </para>
                             <para>
                                  <portionmark>
                                       <US-SECURITY>
                                            <US-CLASS CLASS="UNCLASSIFIED"/>
                                       </US-SECURITY>
                                  </portionmark>
                                  <text>Embassy Telephone: [30] (1) 721-2951,                     8401</text>
                             </para>
                             <para>
                                  <portionmark>
                                       <US-SECURITY>
                                            <US-CLASS CLASS="UNCLASSIFIED"/>
                                       </US-SECURITY>
                                  </portionmark>
                                  <text>FAX: [30] (1) 645-6282</text>
                             </para>
                             <para>
                                  <portionmark>
                                       <US-SECURITY>
                                            <US-CLASS CLASS="UNCLASSIFIED"/>
                                       </US-SECURITY>
                                  </portionmark>
                                  <text>Consulate: Thessaloniki</text>
                             </para>
                             <para>
                                  <portionmark>
                                       <US-SECURITY>
                                            <US-CLASS CLASS="UNCLASSIFIED"/>
                                       </US-SECURITY>
                                  </portionmark>
                                  <text>Consulate Address: Plateia Commercial                     Center, 43 Tsimiski Street,
    7th floor </text>
                             </para>
                             <para>
                                  <portionmark>
                                       <US-SECURITY>
                                            <US-CLASS CLASS="UNCLASSIFIED"/>
                                       </US-SECURITY>
                                  </portionmark>
                                  <text>Consulate Telephone:                     [30] (31) 242-905</text>
                             </para>
                        </summary>
                   </apsummary>
              </ap>
         </US_EMBASSY>
         <FOREIGN_CONSULATE>
              <ap>
                   <metadata>
                        <administrative>
                             <identifiers/>
                             <publisher>
                                  <organization agency="AFMIC"/>
                             </publisher>
                             <dates/>
                        </administrative>
                        <descriptive>
                             <security/>
                             <title>
                                  <portionmark/>
                                  <text/>
                             </title>
                             <subtitle>
                                  <portionmark>
                                       <US-SECURITY>
                                            <US-CLASS CLASS="UNCLASSIFIED"/>
                                       </US-SECURITY>
                                  </portionmark>
                                  <text>Foreign Consulate</text>
                             </subtitle>
                             <locations>
                                  <country CCODE="GRC"/>
                             </locations>
                             <subjects>
                                  <code/>
                             </subjects>
                        </descriptive>
                   </metadata>
                   <apsummary>
                        <unknown/>
                   </apsummary>
                   <amplification>
                        <para>
                             <portionmark>
                                  <US-SECURITY>
                                       <US-CLASS CLASS="UNCLASSIFIED"/>
                                  </US-SECURITY>
                             </portionmark>
                             <text>No information available.</text>
                        </para>
                   </amplification>
              </ap>
         </FOREIGN_CONSULATE>
         <FOREIGN_MISSION>
              <ap>
                   <metadata>
                        <administrative>
                             <identifiers/>
                             <publisher>
                                  <organization agency="CIA"/>
                             </publisher>
                             <dates/>
                        </administrative>
                        <descriptive>
                             <security/>
                             <title>
                                  <portionmark/>
                                  <text/>
                             </title>
                             <subtitle>
                                  <portionmark>
                                       <US-SECURITY>
                                            <US-CLASS CLASS="UNCLASSIFIED"/>
                                       </US-SECURITY>
                                  </portionmark>
                                  <text>Foreign Mission</text>
                             </subtitle>
                             <locations>
                                  <country CCODE="GRC"/>
                             </locations>
                             <subjects>
                                  <code/>
                             </subjects>
                        </descriptive>
                   </metadata>
                   <apsummary>
                        <summary>
                             <para>
                                  <portionmark>
                                       <US-SECURITY>
                                            <US-CLASS CLASS="UNCLASSIFIED"/>
                                       </US-SECURITY>
                                  </portionmark>
                                  <text>There is no information available.</text>
                             </para>
                        </summary>
                   </apsummary>
              </ap>
         </FOREIGN_MISSION>
         <US_CONSULATE>
              <ap>
                   <metadata>
                        <administrative>
                             <identifiers/>
                             <publisher>
                                  <organization agency="MCIA"/>
                             </publisher>
                             <dates/>
                        </administrative>
                        <descriptive>
                             <security/>
                             <title>
                                  <portionmark/>
                                  <text/>
                             </title>
                             <subtitle>
                                  <portionmark>
                                       <US-SECURITY>
                                            <US-CLASS CLASS="UNCLASSIFIED"/>
                                       </US-SECURITY>
                                  </portionmark>
                                  <text>U.S. Consulate</text>
                             </subtitle>
                             <locations>
                                  <country CCODE="GRC"/>
                             </locations>
                             <subjects>
                                  <code/>
                             </subjects>
                        </descriptive>
                   </metadata>
                   <apsummary>
                        <summary>
                             <para>
                                  <portionmark>
                                       <US-SECURITY>
                                            <US-CLASS CLASS="UNCLASSIFIED"/>
                                       </US-SECURITY>
                                  </portionmark>
                                  <text>There is no information available.</text>
                             </para>
                        </summary>
                   </apsummary>
              </ap>
         </US_CONSULATE>
         <TRAVEL_ADVISORIES>
              <ap>
                   <metadata>
                        <administrative>
                             <identifiers/>
                             <publisher>
                                  <organization agency="JICTRANS"/>
                             </publisher>
                             <dates/>
                        </administrative>
                        <descriptive>
                             <security/>
                             <title>
                                  <portionmark/>
                                  <text/>
                             </title>
                             <subtitle>
                                  <portionmark>
                                       <US-SECURITY>
                                            <US-CLASS CLASS="UNCLASSIFIED"/>
                                       </US-SECURITY>
                                  </portionmark>
                                  <text>Travel Advisories</text>
                             </subtitle>
                             <locations>
                                  <country CCODE="GRC"/>
                             </locations>
                             <subjects>
                                  <code/>
                             </subjects>
                        </descriptive>
                   </metadata>
                   <apsummary>
                        <summary>
                             <para>
                                  <portionmark>
                                       <US-SECURITY>
                                            <US-CLASS CLASS="UNCLASSIFIED"/>
                                       </US-SECURITY>
                                  </portionmark>
                                  <text>There is no information available.</text>
                             </para>
                        </summary>
                   </apsummary>
              </ap>
         </TRAVEL_ADVISORIES>
         <ENTRY_REQUIREMENTS>
              <ap>
                   <metadata>
                        <administrative>
                             <identifiers/>
                             <publisher>
                                  <organization agency="MCIA"/>
                             </publisher>
                             <dates/>
                        </administrative>
                        <descriptive>
                             <security/>
                             <title>
                                  <portionmark/>
                                  <text/>
                             </title>
                             <subtitle>
                                  <portionmark>
                                       <US-SECURITY>
                                            <US-CLASS CLASS="UNCLASSIFIED"/>
                                       </US-SECURITY>
                                  </portionmark>
                                  <text>Entry Requirements</text>
                             </subtitle>
                             <locations>
                                  <country CCODE="GRC"/>
                             </locations>
                             <subjects>
                                  <code/>
                             </subjects>
                        </descriptive>
                   </metadata>
                   <apsummary>
                        <summary>
                             <para>
                                  <portionmark>
                                       <US-SECURITY>
                                            <US-CLASS CLASS="UNCLASSIFIED"/>
                                       </US-SECURITY>
                                  </portionmark>
                                  <text>A passport is required for tourist or business stays                     of up to 3
    months. An AIDS test is required for performing artists and students                     on
    Greek scholarships; U.S. test results are not accepted.</text>
                             </para>
                        </summary>
                   </apsummary>
                   <analysis>
                        <para>
                             <portionmark>
                                  <US-SECURITY>
                                       <US-CLASS CLASS="UNCLASSIFIED"/>
                                  </US-SECURITY>
                             </portionmark>
                             <text>Visas are not necessary but a passport is required                     for tourist or
    business stays of up to 3 months. An AIDS test is required for                     performing
    artists and students on Greek scholarships; U.S. test results are                     not
    accepted. </text>
                        </para>
                   </analysis>
              </ap>
              <VACCINATIONS>
                   <ap>
                        <metadata>
                             <administrative>
                                  <identifiers/>
                                  <publisher>
                                       <organization agency="AFMIC"/>
                                  </publisher>
                                  <dates/>
                             </administrative>
                             <descriptive>
                                  <security/>
                                  <title>
                                       <portionmark/>
                                       <text/>
                                  </title>
                                  <subtitle>
                                       <portionmark>
                                            <US-SECURITY>
                                                 <US-CLASS CLASS="UNCLASSIFIED"/>
                                            </US-SECURITY>
                                       </portionmark>
                                       <text>Vaccinations</text>
                                  </subtitle>
                                  <locations>
                                       <country CCODE="GRC"/>
                                  </locations>
                                  <subjects>
                                       <code/>
                                  </subjects>
                             </descriptive>
                        </metadata>
                        <apsummary>
                             <summary>
                                  <para>
                                       <portionmark>
                                            <US-SECURITY>
                                                 <US-CLASS CLASS="UNCLASSIFIED"/>
                                            </US-SECURITY>
                                       </portionmark>
                                       <text>Immunization against hepatitis A and B and typhoid                     fever is recommended.
    For other entry questions, contact the Greek Embassy in                     Washington,
    D.C., telephone (202) 939-5800; Greek consulates in other U.S.                     cities;
    Greek embassies and consulates around the world; or visit Website                     http://www.greekembassy.org
    . </text>
                                  </para>
                             </summary>
                        </apsummary>
                        <analysis>
                             <para>
                                  <portionmark>
                                       <US-SECURITY>
                                            <US-CLASS CLASS="UNCLASSIFIED"/>
                                       </US-SECURITY>
                                  </portionmark>
                                  <text>Immunization against hepatitis A and B and typhoid                     fever is recommended.
    For other entry questions, travelers should contact the                     Embassy of Greece
    at 2221 Massachusetts Avenue NW, Washington DC 20008,                     telephone (202)
    939-5800; Greek consulates in Atlanta, Boston, Chicago,                     Houston, Los
    Angeles, New Orleans, New York, and San Francisco; or Greek                     embassies
    and consulates around the world. Additional information is available                     
    at website: http://www.greekembassy.org.</text>
                             </para>
                        </analysis>
                   </ap>
              </VACCINATIONS>
              <CUSTOMS_RESTRICTIONS>
                   <ap>
                        <metadata>
                             <administrative>
                                  <identifiers/>
                                  <publisher>
                                       <organization agency="MCIA"/>
                                  </publisher>
                                  <dates/>
                             </administrative>
                             <descriptive>
                                  <security/>
                                  <title>
                                       <portionmark/>
                                       <text/>
                                  </title>
                                  <subtitle>
                                       <portionmark>
                                            <US-SECURITY>
                                                 <US-CLASS CLASS="UNCLASSIFIED"/>
                                            </US-SECURITY>
                                       </portionmark>
                                       <text>Customs Restrictions</text>
                                  </subtitle>
                                  <locations>
                                       <country CCODE="GRC"/>
                                  </locations>
                                  <subjects>
                                       <code/>
                                  </subjects>
                             </descriptive>
                        </metadata>
                        <apsummary>
                             <summary>
                                  <para>
                                       <portionmark>
                                            <US-SECURITY>
                                                 <US-CLASS CLASS="UNCLASSIFIED"/>
                                            </US-SECURITY>
                                       </portionmark>
                                       <text>There are duty-free limits on tobacco, alcohol over                     44 proof,
    wine, perfume, eau de cologne, and gifts; there are no limits on                     duty-paid
    goods, for personal use, from European Union (EU) countries. Plants                     
    with soil, pistols, and rifles may not be brought into the country; shotguns
                        must be registered upon arrival. Prescription drugs must have a letter
    from                     prescribing doctor and be declared upon entry. Medications containing
    codeine                     are illegal; exporting artifacts or antiquities without permission
    is also                     illegal.</text>
                                  </para>
                             </summary>
                        </apsummary>
                        <analysis>
                             <para>
                                  <portionmark>
                                       <US-SECURITY>
                                            <US-CLASS CLASS="UNCLASSIFIED"/>
                                       </US-SECURITY>
                                  </portionmark>
                                  <text>Duty-free limits are 200 cigarettes, 50 cigars, 100                     cigarillos,
    or 250 grams of tobacco; 1 liter of alcohol over 44 proof or 2                     liters
    of wine; 50 grams of perfume and 250 milliliters of eau de cologne, and      
              gifts of total value less than Dr25,000. There are no limits on duty-paid
    goods                     from European Union (EU) countries, provided they are solely for
    personal use.                     Importing plants with soil is forbidden. Pistols and rifles
    may not be brought                     into the country; shotguns must be registered upon
    arrival. Prescription drugs                     must be accompanied with a letter from the
    prescribing doctor and be declared                     upon entry. Medications containing
    codeine are illegal and possessors face                     fines and imprisonment. Exporting
    artifacts or antiquities without the Athens                     Archaeological Service&#x2019;s
    permission is illegal and vigorously prosecuted.                     </text>
                             </para>
                        </analysis>
                   </ap>
              </CUSTOMS_RESTRICTIONS>
              <AVIATION_SAFETY_OVERSIGHT>
                   <ap>
                        <metadata>
                             <administrative>
                                  <identifiers/>
                                  <publisher>
                                       <organization agency="JICTRANS"/>
                                  </publisher>
                                  <dates/>
                             </administrative>
                             <descriptive>
                                  <security/>
                                  <title>
                                       <portionmark/>
                                       <text/>
                                  </title>
                                  <subtitle>
                                       <portionmark>
                                            <US-SECURITY>
                                                 <US-CLASS CLASS="UNCLASSIFIED"/>
                                            </US-SECURITY>
                                       </portionmark>
                                       <text>Aviation Safety Oversight</text>
                                  </subtitle>
                                  <locations>
                                       <country CCODE="GRC"/>
                                  </locations>
                                  <subjects>
                                       <code/>
                                  </subjects>
                             </descriptive>
                        </metadata>
                        <apsummary>
                             <summary>
                                  <para>
                                       <portionmark>
                                            <US-SECURITY>
                                                 <US-CLASS CLASS="UNCLASSIFIED"/>
                                            </US-SECURITY>
                                       </portionmark>
                                       <text>The U.S. Federal Aviation Administration has given                     Greek Airways,
    the national air carrier, a safety rating of 2, which is                     conditionally
    unsatisfactory. For further information, contact the U.S.                     Department
    of Transportation at 1-800-322-7873 or visit Website                     http://www.faa.gov/avr/iasa/index.htm
    . For information regarding U.S. DoD policy on specific carriers, contact
    DoD at 1&#x2013;618&#x2013;256&#x2013;4801.</text>
                                  </para>
                             </summary>
                        </apsummary>
                        <analysis>
                             <para>
                                  <portionmark>
                                       <US-SECURITY>
                                            <US-CLASS CLASS="UNCLASSIFIED"/>
                                       </US-SECURITY>
                                  </portionmark>
                                  <text>The U.S. Federal Aviation Administration has given                the national
    air carrier, Greek Airways, a safety rating of 2, which is                     conditionally
    unsatisfactory. For further information travelers may contact the                     U.S.
    Department of Transportation at 1-800-322-7873, or visit the FAA internet
                        website at http://www.faa.gov/avr/iasa/index.htm . The U.S. Department
    of Defense assesses some carriers for suitability as official provides of
    air services. For information regarding Do<?Pub _newline?>D policy on specific
    carriers, travelers may contact DoD at 1&#x2013;618&#x2013;256&#x2013;4801.</text>
                             </para>
                        </analysis>
                   </ap>
              </AVIATION_SAFETY_OVERSIGHT>
         </ENTRY_REQUIREMENTS>
    </US_FOREIGN_MISSION>

  • Trying to move a graphics object using buttons.

    Hello, im fairly new to GUI's. Anyway I have 1 class which makes my main JFrame, then I have another 2 classes, one to draw a lil square graphics component (which iwanna move around) which is placed in the center of my main frame and then another class to draw a Buttonpanel with my buttons on which is placed at the bottom of my main frame.
    I have then made an event handling class which implements ActionListner, I am confused at how I can get the graphics object moving, and where I need to place the updateGUI() method which the actionPerformed method calls from inside the event handling class.
    I am aware you can repaint() graphics and assume this would be used, does anyone have a good example of something simular being done or could post any help or code to aid me, thanks!

    Yeah.. here's an example of custom painting on a JPanel with a box. I used a mouse as it was easier for me to setup than a nice button panel on the side.
    Anyways... it should make it pretty clear how to get everything setup, just add a button panel on the side. and use it to move the box instead of the mouse.
    -Js
    import java.awt.Color;
    import java.awt.Graphics;
    import java.awt.event.MouseEvent;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.event.MouseInputAdapter;
    public class MoveBoxAroundExample extends JFrame
         private final static int SQUARE_EDGE_LENGTH = 40;
         private JPanel panel;
         private int xPos;
         private int yPos;
         public MoveBoxAroundExample()
              this.setSize(500,500);
              this.setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE);
              this.setContentPane(getPanel());
              xPos = 250;
              yPos = 250;
              this.setVisible(true);     
         private JPanel getPanel()
              if(panel == null)
                   panel = new JPanel()
                        public void paintComponent(Graphics g)
                             super.paintComponent(g);
                             g.setColor(Color.RED);
                             g.fillRect(xPos-(SQUARE_EDGE_LENGTH/2), yPos-(SQUARE_EDGE_LENGTH/2), SQUARE_EDGE_LENGTH, SQUARE_EDGE_LENGTH);
                   MouseInputAdapter mia = new MouseInputAdapter()
                        public void mousePressed(MouseEvent e)
                            xPos = e.getX();
                            yPos = e.getY();
                            panel.repaint();
                        public void mouseDragged(MouseEvent e)
                            xPos = e.getX();
                            yPos = e.getY();
                            panel.repaint();
                   panel.addMouseListener(mia);
                   panel.addMouseMotionListener(mia);
              return panel;
         public static void main(String args[])
              new MoveBoxAroundExample();
    }

  • Help in drawing graphics.

    Hi friends,
    I'm newbie in drawing graphics with Java, and I need some help in a specific part of my program.
    What I want to do is to draw a waveform of a sound file. That waveform is built based on the amplitude of each sound sample. So I have a big vector full of those amplitudes. Now what I need to do is plot each point on the screen. The x coordinate of the point will be its time position in the time axis. The y coordinate of the point will be the amplitude value. Ok... Now I have a lot of doubts...
    1 - can someone give me a simple example on how to plot points in a java app? I know I have to extend a JPainel class, but I don't know much about those paint, and repaint methods. It's all weird to me. I already searched through the tutorial and the web, but I couldn't see a simple, good example. Can someone hand me this?
    2 - Once I know how to draw those graphics, I need to find a way to put a button, or anything like that, in my app, so the user can press that button to see to next part of the waveform, since the wave is BIG, and doesn't fit entirely on the screen. Is this button idea ok? Can I use some sort of SCROLL on it, would it be better?
    Well... I'm trying to learn it all. ANY help will be appreciated, ANY good link, little hint, first step, anything.
    Thanks for all, in advance.
    Leonardo
    (Brazil)

    This will lead you, in this sample you have a panel and a button,
    every click will fill a vector with random 700 points and draw them on the panel,
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    public class Wave extends Frame implements ActionListener
         WPanel   pan    = new WPanel();
         Vector   points = new Vector();
         Button   go     = new Button("Go");
         Panel    cont   = new Panel();
    public Wave()
         super();
         setBounds(6,6,700,400);     
         addWindowListener(new WindowAdapter()
        {     public void windowClosing(WindowEvent ev)
                   dispose();     
                   System.exit(0);
         add("Center",pan);
         go.addActionListener(this);
         cont.add(go);
         add("South",cont);
         setVisible(true);
    public void actionPerformed(ActionEvent a)
         points.removeAllElements();
         for (int j=0; j < 700; j++)
              int y = (int)(Math.random()*350);
              points.add(new Point(j,y+1));
         pan.draw(points);
    public class WPanel extends Panel
         Vector   points;
    public WPanel()
         setBackground(Color.pink);
    public void draw(Vector points)
         this.points = points;
         repaint();
    public void paint(Graphics g)
         super.paint(g);
         if (points == null) return;
         for (int j=1; j < points.size(); j++)
              Point p1 = (Point)points.get(j-1);
              Point p2 = (Point)points.get(j);
              g.drawLine(p1.x,p1.y,p2.x,p2.y);
    public static void main (String[] args)
         new Wave();  
    Noah

  • Draw a line using mouse

    Hello there:
    I'm trying to draw a line using mouse pointer: My code is:
    public class DrawLine extends JFrame implements MouseListener, MouseMotionListener
        int x0, y0, x1, y1;  
        public DrawLine()
             addMouseListener(this);
             addMouseMotionListener(this);
        public void mouseDragged(MouseEvent e)
             x1 = e.getX();
             y1 = e.getY();
             repaint();
        public void mouseMoved(MouseEvent e) { }
        public void mouseClicked(MouseEvent e){ }
        public void mouseEntered(MouseEvent e) { }
        public void mouseExited (MouseEvent e) { }
        public void mousePressed(MouseEvent e)
              x0 = e.getX();
              y0 = e.getY();           
        public void mouseReleased(MouseEvent e)
              x1 = e.getX();
              y1 = e.getY();
       public void paint(Graphics g)
                 g.setColor(Color.BLACK);
              g.drawLine(x0, y0, x1, y1);
        public static void main(String[] argv)
             DrawLine dr=new DrawLine("Test");
             dr.setVisible(true);
             dr.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }when mouse is dragged, multiple lines are being drawn....
    could you else please tell me what should I've to do???
    thanks n regards...
    Dev

    You can implement the listeners on any class, even one that (implicitly) extends Object. What matters is that the listener is added to the component that needs to use it.
    That said, why do you want to extend JFrame? Are you adding functionality to the JFrame to justify extending the JFC class? Note that extending JFrame allows the users of your class to access the functionality of a JFrame, is that really indicated here?
    one class that extends JFrame, and one can draw a line on JLabel, embedded within JFrame!So you still have to override paintComponent of the JLabel, which implies using an anonymous inner class.
    Starting with the example already posted, that would be:
    import java.awt.Color;
    import java.awt.Dimension;
    import java.awt.Graphics;
    import java.awt.event.MouseEvent;
    import java.awt.event.MouseListener;
    import java.awt.event.MouseMotionListener;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.SwingUtilities;
    public class DrawLineTest
        implements MouseListener, MouseMotionListener {
      JLabel label;
      int x0, y0, x1, y1;
      private void makeUI() {
        JFrame frame = new JFrame("DrawLineTest");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        label = new JLabel("FFFF") {
          public void paintComponent(Graphics g) {
            super.paintComponent(g);
            g.setColor(Color.BLACK);
            g.drawLine(x0, y0, x1, y1);
        label.setPreferredSize(new Dimension(500, 500));
        label.addMouseListener(this);
        label.addMouseMotionListener(this);
        frame.add(label);
        frame.pack();
        frame.setVisible(true);
      public static void main(String[] args) {
        SwingUtilities.invokeLater(new Runnable() {
          public void run() {
            new DrawLineTest().makeUI();
      public void mousePressed(MouseEvent e) {
        x0 = e.getX();
        y0 = e.getY();      
      public void mouseReleased(MouseEvent e) {
        x1 = e.getX();
        y1 = e.getY();
      public void mouseDragged(MouseEvent e) {
        x1 = e.getX();
        y1 = e.getY();
        label.repaint();
      public void mouseMoved(MouseEvent e) { }
      public void mouseClicked(MouseEvent e){ }
      public void mouseEntered(MouseEvent e) { }
      public void mouseExited (MouseEvent e) { }
    }Better spend more time with the tutorials, there's a separate section on writing event listeners.
    db

  • How to draw a line using JSP?

    Does anyone know how to draw a line using a JSP? Any help is much appreciated.
    Regards,
    Navin Pathuru.

    Graphics classes are useless in JSP files; you can only output HTML tags to the client browser.
    You should be able to give just about any presentation look that you need with HTML and CSS. Have you played with styles? Here's a simple example that works in IE 5+ and Netscape 4.7:
    <HTML>
    <HEAD>
    <STYLE>
    .box {
    border-style:solid;
    border-color:black;
    border-right-width: 1px;
    border-top-width: 1px;
    border-left-width: 1px;
    border-bottom-width: 1px;
    .line {
    border-right-width: 1px;
    border-top-width: 0px;
    border-left-width: 0px;
    border-bottom-width: 0px;
    border-style: solid;
    border-color: red;
    width:1pt;
    height:100%;
    </STYLE>
    </HEAD>
    <BODY>
    <TABLE CELLPADDING=1 CELLSPACING=0 WIDTH=100>
    <TR><TD ALIGN=CENTER><SPAN CLASS="box">Field One</SPAN></TD></TR>
    <TR HEIGHT=50><TD ALIGN=CENTER><SPAN CLASS="line">�</SPAN></TD></TR>
    <TR><TD ALIGN=CENTER><SPAN CLASS="box">Field Two</SPAN></TD></TR>
    <TR HEIGHT=50><TD ALIGN=CENTER WIDTH=50%><SPAN CLASS="line">�</SPAN></TD></TR>
    <TR><TD ALIGN=CENTER><SPAN CLASS="box">Field Three</SPAN></TD></TR>
    </TABLE>
    </BODY>
    </HTML>
    Have fun!

  • Draw graphics on Image and Save it

    hi!,
    Can anyone help me how to draw graphics(Line, rectangle.ect) on an Image and save it. I need to do the following steps.
    1. Get the Image from the local file system
    2. Based on the parameters i receive for graphics(Ex: rectangle).
    -I have to draw a rectangle on the Image.
    3. Save the Image again to the file system
    I would appreciate if any one has any ideas or sample code I can start with.
    Thanks!!!

    Here's an example using the javax.imageio package.
    import java.awt.Color;
    import java.awt.Graphics2D;
    import java.awt.Rectangle;
    import java.awt.image.BufferedImage;
    import java.io.File;
    import java.io.IOException;
    import javax.imageio.ImageIO;
    public class DrawOnImage {
        public static void main(String[] args) {
            try {
                BufferedImage buffer = ImageIO.read(new File(args[0]));
                Graphics2D g2d = buffer.createGraphics();
                Rectangle rect = new Rectangle(10, 10, 100, 100);
                g2d.setPaint(Color.RED);
                g2d.draw(rect);
                ImageIO.write(buffer, "JPG", new File(args[1]));
            } catch (IOException e) {
                e.printStackTrace();
    }

  • How to use swf file for Spark Skin

    Hi all
    I have little confuse about how to use swf file with Spark Skin,
    in Flex3 , i use Flex Skin Design Extension for Flash to deal with skin ,
    so basically , I just create a swf file and import to the project , then everything is ok
    but , seem that not working in flex4 , spark skin.
    1` I can't find the Flex Skin Design for the FlashCs4
    2` I try to use FlashCs3 version to import the skin art to the project , but seemed not working.
    3` I Google and check the Flex4 Help , seemed Spak skin need the Skin-Class , which I don't know how to use that with swf file
        what I have searched is how to use FXG , or some jpg file in that skin class, none of them are use swf file.
    so , is there any way that let user use the swf file to deal with the skin?
           is the Flex Skin Design can use in Flex4?
    Thanks

    Hello,
    I'm new to Flex, but have come to it from Flash Pro.  I'd like to know the same thing.  I think I found the answer here:
    http://www.flashallys.com/blog/spark-button-skinning-with-flash-symbols/
    However my question is now: Is this a good approach to use?
    99% of the googling I've done tells me to skin components with fxg files.  I've tried that by creating graphics and exporting from flash, but using swfs containing lots of graphics is much faster so I'd rather use that.
    The other thing I've done is to create custom components using these helpful tutorials:
    Creating component in flash:
    http://www.webkitchen.be/2008/12/12/video-tutorial-make-flex-components-with-flash-cs4/
    Dealing with Resizing with method overrides for your flash component:
    http://www.psyked.co.uk/flex/creating-flex-components-the-easy-way-for-flash-ide-converts. htm
    This allows me the flexibility of Flash Pro design with the layout, transistions, data binding etc from Flex.
    So my question is: Is this approach (skinning spark components with swfs, and using custom swc components made in flash) a bad idea for any reason?  E.g. does it create slow mobile apps?
    Cheers
    Chris

  • Filename for flat file using J2EE FILE FTP Receiver adapter

    Hi there,
    I am struggling to do the following:
    I have a J2EE File receiver that sends a file with a specific name to a FTP destination. I define the target filename in my graphical mapping using certain criteria and a incremental number. In my adapter I use variable substitution to select that value in the payload as the filename. Up to this point everything works fine.
    The problem is that I convert the payload to a flat structure using xslt before writing it out and because of that the adapter cannot find my value as defined in the variable I use for the name.
    Now, obviously if I move the xslt module after the CallAdapter module, the file won't be converted to a flat structure.
    Can anyone give me advice on how I can do the flat conversion <u>and</u> the specific filename from the payload?
    Thanks in advance,
    Johan

    Hi,
    Instead of using variable substitution, use adapter specific identifiers to set the file name in mapping.
    Ref:/people/michal.krawczyk2/blog/2005/11/10/xi-the-same-filename-from-a-sender-to-a-receiver-file-adapter--sp14
    Regards,
    Jai Shankar

  • I receive the error: Unable to load block component C:\Program Files\Hyperception\VABINF\KeyRcv.dll

    I have two Major issues with our Infinity Project computers,
    We have one entire lab that is getting this error... "Unable to load
    block component C:\Program Files\Hyperception\VABINF\KeyRcv.dll. 
    Please verify that the component exists and any dependencies it may
    have are satisfied."  It is also producing this error with
    NumEntry.dll.  Both files exist.  I am not sure what
    dependencies these files may have.  Ideas?
    We have several systems that are giving the following error on one of
    our labs... "You have exceeded the number of block functions allowed by
    VAB for Infinity; contact Hyperception regarding upgrades."  From
    what The professor here at UTA told me when I first took on this
    project, this was a problem that we had on the previous boards and that
    someone at Hyperception was able to help us resolve this problem.
    Can you help out with these issues?  The first one I need an answer today if possible. 
    Thanks,

    We have seen this type of problem on some computers (we do not know why as of yet).The problem with missing blocks is very likely being caused by file permissions, and can be seen when non-administrators are using VAB software. To resolve this: 1. login as ADMINISTRATOR 2. run the command line script from a DOS prompt as shown below: cacls "C:\Program FIles\Hyperception\VABINF" /T /E /G Everyone:F It will scroll through the name of every file in the provided directory, and all subdirectories. This should reset every file, and allow the USER to access all files in VAB software. This should correct the problem. Regards,Steve

  • When I have video clips on my timeline, they do not play in the monitor screen. I hear the sound track but can not see the image. To test if my new files are somehow the problem, I went back and used video files that I used successfully a year ago, and th

    When I have video clips on my timeline, they do not play in the monitor screen. I hear the sound track but can not see the image. To test if my new files are somehow the problem, I went back and used video files that I used successfully a year ago, and they no longer play in the monitor window. I hear the sound track, but do not see any video. Have I changed some setting that controls video playback in the monitor window?

    Randy Ruttger
    Thanks for the follow up.
    Missing in this equation were the version of Premiere Elements that you were using and the computer operating system on which it was running. But...
    The deed is done. But.....Until now and after you went ahead and moved to version 12, we now learn what version of Premiere Elements you were using. We still do not know the computer operating system involved.
    You just said Premiere Elements 10. Premiere Elements 10 is hit by a serious known display issue if the computer uses a NVIDIA GeForce video card/graphics card. In this issue, the only remedy is to roll back the driver version to about May 2013. The description of the problem and how to do the roll back are described in one of the Announcements at the top of this forum. What video card/graphics card does your computer use?
    On another front, Adobe will be releasing a new version of Premiere Elements any day now. No one but Adobe knows the feature set for the new version. That type of information is announced at the moment of release of the new version.
    So the remedy to the problem that you presented in this thread could have been...
    1. Rolling back the NVIDIA GeForce driver version to about May 2013 if possible (Windows 8 or 8.1 64 bit, may not be possible)
    2. Move to another version of Premiere Elements (which you did)
    I offer the above for consideration so that you can review your decisions. We are pleased to learn that Premiere Elements 12/12.1 works for you.
    Please do not hesitate to ask questions and ask for clarifications, but remember that the answers are in the details.
    Best wishes,
    ATR

  • Error while reading raw file created in previous task using raw file destination

    I am reading a flat file and creating an raw file using raw file destination.  path of the raw file is in a variable.  now I am reading the raw file using the rawfile source component. I am able to execute if the .raw file is available.  But
    when we deploy into the production the .raw will be created runtime, so the package is getting failed while evualting the variable which hold the path of the variable.  since the .raw is not available i am not able to proceed further. it's in ssis 2008
    r2
    Error at Load Data [Raw File Source [401]]: File "c:\test123.raw" cannot be opened for reading. Error may occur when there are no privileges or the file is not found. Exact cause is reported in previous error message.
    Error at Load Data [SSIS.Pipeline]: component "Raw File Source" (401) failed validation and returned error code 0x80004005.
    Error at Load Data [SSIS.Pipeline]: One or more component failed validation.
    Error at Load Data : There were errors during task validation.

    I am also using a raw file destination using a variable.
    I have set DelayValidation = true on both the DataFlow task and even the Sequence Container.
    I get the same error when I run the entire ssis package, however
    when I run the individual container or individual task it runs without an error.
    Also, something interesting is the error is not the same path as the variable name.
    Warning: The system cannot find the file specified.
    Error: File "C:\Users\MyName\AppData\Local\Temp\GUIDNumber\\RawFileName" cannot be opened for reading. Error may occur when there are no privileges or the file is not found. Exact cause is reported in previous error message.
    The variable is "C:\Temp\ProjectName\RawFileName"
    I have other RawFile sources in this same project, but only this one file is giving me grief.
    Any other suggestions?  Is this a bug?
    Have you set an expression for connection string property of raw file? Is it based on variable/expression or configuration? If yes, check the value of variable/ expression or configuraton item at runtime by putting a breakpoint in the pre execute event of task
    and make sure path value its getting is correct. It may be that path is getting a different value at runtime due to expression/configuration set for it.
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • Just converted a PDF document to Word, none of the graphics from the PDF file show up in the Word document?

    Just converted a PDF document to Word, none of the graphics from the PDF file show up in the Word document?
    What do I need to do to bring the graphics and exhibits from the PDF file to the Word file?

    Hi jackp52432917,
    How was that PDF file created? Please see  Will Adobe ExportPDF convert both text and form... | Adobe Community
    It could be that the PDF file you're converting was created using a third-party application, and it doesn't contain all the information necessary to ensure a clean conversion. Have you had similar troubles converting other PDF files?
    Best,
    Sara

Maybe you are looking for