Experiment with the API classes

How can I experiment with the API code and see How they work?
I heard that java code is availabe to download
*1 After downloading, what is the way to compile, run, change the code and see How it works?*

Download the JDK.
It comes with the libraries, a runtime environment, and various tools, including a compiler.
It also comes with the source code for the libraries, but if you're planning on changing it to see how it works, I'd advise against it. That might help you learn how one might implement the library, but it won't teach you how to use the library, and at this point learning how to use it is probably a better choice for you.

Similar Messages

  • Please help with the URL class

    Hello,
    I am trying to write a Java app that will take a url and download it.
    I believe you can do this with the URL class but I don't understand how to. For example, if the http url location points to a picture file, how would I code the app to retrieve this picture and save it to a specified directory?
    Also, is there a way that my java app could open another program, let's say Microsoft Internet Explorer?
    Please be as specific as possible, thanks!

    You'll see below an example to download a file
    private static String copyFile (String url, String nomFichier){
         // construction du fichier de sortie
         File outputFile = new File(repertoire + "\\fichiers\\" + nomFichier);
         // si le fichier existe d�j�, il ne sert � rien de le t�l�charger !
    if (outputFile.exists())
         return "fichiers/" + nomFichier;
              try {     
         HttpURLConnection connect = (HttpURLConnection)new URL(url).openConnection();
    boolean connected = false;
    while (!connected){
    try {
    connect.connect();
    connected = true;
         catch (java.io.IOException e1) { System.out.print("...Tentative de connection"); }     
    DataInputStream reader = new DataInputStream(
    connect.getInputStream());
         FileOutputStream out = new FileOutputStream(outputFile);
         int length = 1024;
         byte[] buf = new byte[length];
         int offset = 0;
         long offsetCourant = 0;
         int nb=0;
         while ((nb=reader.read(buf,offset,length))!= -1) {
              out.write(buf,0,nb);
         out.close();
         catch (java.net.MalformedURLException e) { System.out.println("pb d'url"); }
         catch (java.io.IOException e1) { System.out.println(e1.getMessage()); }
         return "fichiers/" + nomFichier;
    }

  • [svn] 1168: compiler: renaming the API classes

    Revision: 1168
    Author: [email protected]
    Date: 2008-04-09 14:30:32 -0700 (Wed, 09 Apr 2008)
    Log Message:
    compiler: renaming the API classes
    * flex2.compiler.asdoc:API to AsDocAPI
    * flex2.compiler.swc:API to SwcAPI
    * flex2.compiler:API to CompilerAPI
    * flex2.linker:API to LinkerAPI
    * flex2.tools:API to WebTierAPI
    Bugs: n/a
    QA: Yes, we should probably run the suite on this; though we could also wait for the Compiler classes to get renamed
    Doc: No
    Modified Paths:
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/Source.java
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/SourcePath.java
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/SymbolTable.java
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/as3/Compiler.java
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/as3/SignatureExtension.java
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/as3/binding/TypeAnalyzer.java
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/as3/genext/GenerativeClassInfo.ja va
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/mxml/Compiler.java
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/mxml/ImplementationCompiler.java
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/mxml/MxmlLogAdapter.java
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/swc/Swc.java
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler_en.properties
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler_ja.properties
    flex/sdk/trunk/modules/compiler/src/java/flex2/linker_en.properties
    flex/sdk/trunk/modules/compiler/src/java/flex2/linker_ja.properties
    flex/sdk/trunk/modules/compiler/src/java/flex2/tools/ASDoc.java
    flex/sdk/trunk/modules/compiler/src/java/flex2/tools/ASDocConfiguration.java
    flex/sdk/trunk/modules/compiler/src/java/flex2/tools/CommandLineConfiguration.java
    flex/sdk/trunk/modules/compiler/src/java/flex2/tools/Compc.java
    flex/sdk/trunk/modules/compiler/src/java/flex2/tools/CompcPreLink.java
    flex/sdk/trunk/modules/compiler/src/java/flex2/tools/DigestTool.java
    flex/sdk/trunk/modules/compiler/src/java/flex2/tools/Fcsh.java
    flex/sdk/trunk/modules/compiler/src/java/flex2/tools/Mxmlc.java
    flex/sdk/trunk/modules/compiler/src/java/flex2/tools/Optimizer.java
    flex/sdk/trunk/modules/compiler/src/java/flex2/tools/oem/Application.java
    flex/sdk/trunk/modules/compiler/src/java/flex2/tools/oem/Library.java
    flex/sdk/trunk/modules/compiler/src/java/flex2/tools/oem/Toolkit.java
    flex/sdk/trunk/modules/compiler/src/java/flex2/tools/oem/internal/ApplicationCompilerConf iguration.java
    flex/sdk/trunk/modules/compiler/src/java/flex2/tools/oem/internal/LibraryCompiler.java
    flex/sdk/trunk/modules/compiler/src/java/flex2/tools/oem/internal/OEMUtil.java
    Added Paths:
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/CompilerAPI.java
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/asdoc/AsDocAPI.java
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/swc/SwcAPI.java
    flex/sdk/trunk/modules/compiler/src/java/flex2/linker/LinkerAPI.java
    flex/sdk/trunk/modules/compiler/src/java/flex2/tools/WebTierAPI.java
    Removed Paths:
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/API.java
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/asdoc/API.java
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/swc/API.java
    flex/sdk/trunk/modules/compiler/src/java/flex2/linker/API.java
    flex/sdk/trunk/modules/compiler/src/java/flex2/tools/API.java

    What is your classpath set to? If you can't find some classes, check there, rather than the path. You might want to include JAVA_HOME/lib/tools.jar and J2EE_HOME/lib/j2ee.jar for starters.
    For example, to compile myclass.jave: javac -cp .;%J2EE_HOME/lib/j2ee.jar;%JAVA_HOME/lib/tools.jar myclass.java
    Hope this helps,
    Rob

  • HOWTO: Use the Spring data access methods together with the WebRowSet class

    With the WebRowSet class I can easily iterate over a ResultSet and produce some XML using the code below.
    Class.forName("oracle.jdbc.driver.OracleDriver");
    Connection connection
    = DriverManager.getConnection("");
    Statement statement = connection.createStatement();
    ResultSet resultSet = statement.executeQuery("SELECT SYSDATE FROM DUAL");
    WebRowSet webRowSet = new WebRowSetImpl();
    webRowSet.populate(resultSet);
    statement.close();
    connection.close();
    webRowSet.writeXml(new FileOutputStream("C:\\SYSDATE.xml"));
    So, how would I use the simplified Spring methods to do the same thing? The WebRowSet.populate method only supports a ResultSet object. The Spring framework only returns an SqlRowSet object that is not easily cast to the ResultSet, etc.
    Thanks for your help.
    Edited by: mrmeth0d on Jan 3, 2008 2:02 PM

    So, how would I use the simplified Spring methods to do the same thing? The WebRowSet.populate method only supports a ResultSet object. The Spring framework only returns an SqlRowSet object that is not easily cast to the ResultSet, etc.
    Cast Spring's SqlRowSet to ResultSet? Impossible. It's an interface that does not extend java.sql.ResultSet.
    javax.sql.WebRowSet is an interface that extends java.sql.ResultSet.
    Spring does have a concrete class ResultSetWrappingSqlRowSet whose constructor can take a java.sql.ResultSet.
    So I think your solution is to instantiate a new ResultSetWrappingSqlRowSet, passing it your javax.sql.rowset.WebRowSet, and return that wherever Spring wants to return a SqlRowSet.
    %

  • Necessity of definin periodic work schedules with the counting classe - Reg

    Hi every one,
                                While customizing attendances and absences we have to define the periodic work schedule with the counting classes. And this counting classes are used in the counting rule. Can anyone please tel me what is the need of defining periodic work schedules with the counting classes.
    With Regards,
    Jagadeesh

    if there are multiple PWS in an organisation and if the client requires the absences to be counted in different manner depending on the PWS. this counting class can be used.
    use the appropriate check box in counting rule.

  • Source code doesn't seem to line up with the compiled classes in ECLIPSE

    I am trying to write a Tomcat servlet to parse an incoming message, however when I parse the message to get the parts out of it I get a a parse error that doesn't really tell me a lot.
    I have downloaded the source code for the Java Mail API 1.3.2 and attached it to the jar file in Eclipse.
    However when I debug the code and step through it I get two problems. 1) I get a warning that I can't see the local variables (not really a great problem). 2) The lines in the source code do not line up with where the stack says I am.
    I have checked the dates on the various classes and the source of the API and they seem to line up.
    I did try to recompile the classes just as an experiment but I am runing JDK_1.4.2_06 and the source seems to be set up for 1.5 and I have some missing classes. I can't switch to 1.5 because there are some other servlets running on this server that won't work on 1.5.
    Can anyone give me a clue how I can at least get the the correct line number.
    Thanks
    Brynn

    Has anyone any ideas on this please?

  • Can not filter the data with the extended class

    Hi,
    I have a quick question about PortableObject format. I have created a class which extends PortableObject interface and implemented serializer methods as well. I have updated it in the pof-config.xml file as well. If I insert the objects of this type of object in the cache, they get inserted properly and I can filter the values based on the getters defined in the class. Everything works fine here.
    Now, I am trying to extend the existing class that I have. We have our custom API which we have built for our domain objects. I need to store these objects in the cache. So, naturally I need to implement PortableObject interface to do that. So, instead of creating a new class with new set of getters and setters and local fields, I am extending our domain class to create a new class which implements PortableObject interface. Instead of defining the local fields and getters and setters i am reusing the ones provided by my existing class. Now, I can insert the objects of the new class to the cache. But I can not filter the values for the objects of this new class.
    Let me show you what exactly I am trying to achieve by giving a small example:
    Domain Class:
    class Person
    private String person_name;
    *public String getPerson_name() {return person_name;}*
    *public String setPerson_name(person_name) {this.person_name = person_name;}*
    The new class implementing PortableObject interface:
    class ExtPerson extends Person implements PortableObject
    public static final PERSON_NAME = 0;
    *public void readExternal(PofReader reader) throws IOException{*
    setPerson_name(reader.readString(PERSON_NAME));
    *public void writeExternal(PofWriter writer) throws IOException{*
    writer.writeString(PERSON_NAME, getPerson_name());
    *// And HashCode, Equals and ToString methods, all implemented using the getter from the Person class*
    So, if I create a new class ExtPerson without extending the Person class and write all the methods, store the objects in the cache and perform the following query, I get the size printed
    System.out.println((cache.entrySet(new EqualsFilter("getPerson_name","ABC"))).size());
    But if I use the extended class and insert the values into the cache and if I use the same query to filter, I get 0 printed on the console.
    System.out.println((cache.entrySet(new EqualsFilter("getPerson_name","ABC"))).size());
    So, can anyone tell what exactly is causing this?
    Thanks!

    Well, just a quick question. It seems that I can not get ContainsAnyFilter or ContainsAllFilter working.
    EqualsFilter is actually working properly.
    I am preparing a Set of Strings and passing it to ContainsAnyFilter or ContainsAllFilter and it is returning me 0 records.
    E.g.:
    Set<String> setStr = new HashSet<String>();
    setStr.add("ABC");
    setStr.add("DEF");
    System.out.println((cache2.entrySet(new ContainsAnyFilter("getPerson_name", setStr))).size());
    I get 0 in my output
    If I try this:
    System.out.println((cache.entrySet(new EqualsFilter("getPerson_name","ABC"))).size());
    System.out.println((cache.entrySet(new EqualsFilter("getPerson_name","DEF"))).size());
    I get 1 for each of the query.
    If I club all these EqualsFilter in a Filter[] array and create an AnyFilter or AllFilter and pass it to the query, it works fine.
    List<Object> lst = new ArrayList<Object>();
              lst.add("ABC");
              lst.add("DEF");
    Filter[] filter = new Filter[lst.size()];
         for(int i=0;i<lst.size();i++)
              filter[i] = new EqualsFilter("getPerson_name",lst.get(i).toString());
    AnyFilter fil = new AnyFilter(filter);
    System.out.println((cache4.entrySet(fil)).size());
    I get the desired result here, which is 2.
    Am I missing something here?

  • How to combine a content search with an attribute search with the API

    Hi
    I have been working with searches in Content Services using the API and I have successfully set up the search over the contents of a document and inside of the Category attributes of the document.
    My problem comes when I try to combine this 2 kinds of search, that is when I want to find all the documents that cointain the text "test" and at the same time contain other text into their category attributes.
    What I do is to build 2 SearchExpression's one for the content search and the other for the attributes search and then joining them in a third SearchExpression object using the FdkConstants.OPERATOR_AND. When I search using only the first or the second SearchExpression everything works fine. But when I do the search using the third SearchExpression an ORACLE.FDK.ParameterError:ORACLE.FDK.InvalidSearchExpression
    exception id raised.
    The code I'm using is like this:
    private SearchExpression getMainSE(String contentQuery, CategoryInfo catInfo)
         SearchExpression contentSE = null;
         SearchExpression catSE = null;
         SearchExpression mainSE = null;
         if(contentQuery != null)
              contentSE = this.setupSE4Contents(contentQuery);
         if(catInfo != null)
              catSE = this.setupSE4Category(catInfo);
         if(contentSE != null && catSE != null)
              mainSE = new SearchExpression();
              mainSE.setLeftOperand(FdkConstants.OPERATOR_AND);
              mainSE.setLeftOperand(catSE);
              mainSE.setRightOperand(contentSE);
         else
              mainSE = contentSE != null ? contentSE : catSE;
         return mainSE;
    CategoryInfo is one class made by my own that contains the categoryId of the document and a List of the attributes where I want to search. mainSE is the SearchExpression that is returned.The portion of code that appears to be having problems is this:
    if(contentSE != null && catSE != null)
         mainSE = new SearchExpression();
         mainSE.setLeftOperand(FdkConstants.OPERATOR_AND);
         mainSE.setLeftOperand(catSE);
         mainSE.setRightOperand(contentSE);
    And finally I only execute the search using the mainSE returned by the function:
    // Define search options
    NamedValue[] nv = WsUtility.newNamedValueArray(new Object[][] {
         { Options.FOLDER_RESTRICTION,
              folder != null ? new Long(folder.getId()) : null },
         { Options.SEARCH_VERSION_HISTORY, Boolean.TRUE } });
         SearchExpression mainSE = this.getMainSE(contentQuery, catInfo);
         try
              // Search documents
              NamedValue[] result = sem.search(mainSE, nv, null);
              // etc....
    Is this the correct way to combine a content search with an attribute search???
    I know that this is possible since I have seen that it can be done in the Collaboration Suite UI.
    I hope yoy can help me...
    Thanks in advance

    Not sure if this is a typo (while pasting code on the forum) or is the cause of the problem you describe.
    Shouldn't mainSE.setLeftOperand(FdkConstants.AND) be replaced by mainSE.setOperator(FdkConstants.AND) ?
    Ravikiran

  • What is the user scope when created with the API?

    I noticed that users created with the Adobe Connect API for my meeting/account are always listed in the Administration -> Users and Groups area.  Which probably means that a user's login is only valid for my meetings.  So if they wanted to register or join a meeting controlled by someone else, they would have to re-register or be re-created by that admin.  Is this correct?
    I'm trying to confirm this so that I know how to register a user on my website.  It would be ideal if my website would register the user and also log the user in without the user having to enter a separate password (my website would generate and store the password).  If the API creates a user only for my meetings then this is not a problem.  The user will just always have to go through my website to get to the meeting.  However, if the user created by my Adobe API account can be used to access/register in another person's meetings on Adobe then this approach is not so good because the user would need to know their password.

    yea, guest registration is not an option as I need to restrict access to the meeting.
    My main concern is that another Connect account holder can change the user's password.  If this ever happens, my website would have an old password and would be broken because it wouldn't be able to log the user into their meeting.  This may be a rare case, but the website will be charging for these meetings/webinars.  If the user can't get in at the time of the meeting....  i'll have a lot more problems.
    I guess I'll just need to provide a way for the user to change or enter their own password. 
    Thanks for the info!

  • More trouble with the robot class (takin a screencapture)

    I have created a small label which can have a transaprent background, and through the help of people on this forum, I am tryin to make it more robust. My latest task involves adding a component listener, and changing the background image when the parent component is moved.
    Unfortunately, the background image is not being changed, but I dont know why. When I slow things down with a debugger, it seems that all of my x and y coordinates are correct, but the background image remains the same.
    If you give it a shot, you will be able to see what I mean:
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.image.BufferedImage;
    public class LabelTest extends JWindow {
         static int x=300, y=300;
         public static void main(String[] args) {
              JFrame frame = new JFrame();
              frame.setPreferredSize(new Dimension(300,400));
              final LabelTest l = new LabelTest(frame, new Point(500,500), "My long string 222333111444555");
              l.setFont(new Font("Tahoma", Font.BOLD, 14));
              frame.addComponentListener(new ComponentAdapter() {
                   public void componentMoved(ComponentEvent e) {
                        x+=5;
                        y+=5;
                        l.setLocation(x,y);
              frame.pack();
              frame.setVisible(true);
              l.setVisible(true);
         private BubbleLabel bubble;
         public LabelTest(JFrame owner, Point startingPoint, String text) {
              super(owner);
              setupBubble(startingPoint, text);
         public LabelTest(JDialog owner, Point startingPoint, String text) {
              super(owner);
              setupBubble(startingPoint, text);
         private void setupBubble(Point startingPoint, String text) {
              bubble = new BubbleLabel(startingPoint, text);
              this.setLocation(startingPoint);
              this.setLayout(new BorderLayout());
              this.add(bubble, BorderLayout.CENTER);
              this.pack();
         public void setFont(Font f) {
              bubble.setFont(f);
              this.pack();
         public void setLocation(int x, int y) {
              super.setLocation(x,y);
              bubble.updatePoint(x, y);
         public class BubbleLabel extends JLabel {
              private String myText;
            private BufferedImage image;
              private Point point;
              private Robot robot;
              public BubbleLabel(Point p, String text) {
                   this.point = p;
                   this.myText = text;
                   try {
                        robot = new Robot();
                   catch(AWTException e) {
                        e.printStackTrace();
                   setupImage();
              public void updatePoint(int x, int y) {
                   this.point = new Point(x,y);
                   setupImage();
              private void setupImage() {
                   if(point ==  null) {
                        return;
                   try {
                        Dimension d = getPreferredSize();
                        image = robot.createScreenCapture(new Rectangle(point.x, point.y, d.width, d.height));
                   catch(Exception e){
                        e.printStackTrace();
              public void setFont(Font f) {
                   super.setFont(f);
                   setupImage();
              public void paint(Graphics g) {
                   Graphics2D g2 = (Graphics2D)g;
                   g2.drawImage(image,0,0,this);
                   //draw the labels
                   Font f = getFont();
                   if(f != null) {
                        FontMetrics fm = getFontMetrics(getFont());
                        g2.setColor(Color.GREEN);
                        g2.drawString(myText, 15, 25 + fm.getHeight()/2 - fm.getMaxDescent());
              public Dimension getPreferredSize() {
                   Font f = getFont();
                   if(f != null) {
                        FontMetrics fm = getFontMetrics(getFont());
                        int hieght = fm.getHeight();
                        int width = 0;
                        width = fm.stringWidth(myText);
                        System.err.println(width + 15);
                        return new Dimension(width + 15, hieght + fm.getHeight()*2);
                   else {
                        return new Dimension(200, 200);
              public Dimension getMinimumSize() { return new Dimension(200, 200); }
    }

    Hi camickr,
    I didn't ignore your suggestions, I just didn't completely understand them (I actually asked about them in my previous thread, but didn't get a response). Looking back at that thread, I realize that I read some of the code wrong. Where it saide desktopImage != null I saw desktopImage == null in the paintComponent() method. Now that I have reread it, I understand what you were getting at. However, that still doesn't solve the problem of the background changing. i.e. a screen behind my application is minimized.
    As for your suggestions:
    a) Right you are, I should be using paintComponent. I normally don't make this mistake, but I have been playing with so many different variations of this code, in different classes, that things have gotten quite mixed up. You also have to understand, that the code I posted is much smaller than the code I am working with, in order to be able to identify exactly what problem I am having, and not give you guys the burden of sorting through a lot of unrelevant code.
    b) right you are again. I started with the JLabel, because I was going to use some of the class's properties, but as my code has progressed, I have steered away from that approach. However, for my puproses I don't see the downside of using it. I want to get my core functionality working, and then clean the code up.
    c) see first paragraph
    d) I haven't looked into it, but I am not so sure this would work for my purposes. I use the graphics package to draw a border around the text (I cant use the border classes because this is not a uniform border). I suppose this is more reason to use a JComponent than a JLabel.
    e) The is no real logic to my component listener. I wrote it to show the problem I am having. I just increased the pixels by 5 for each call, because that was the simplest way to show that the background image was not being 1) created correctly or 2) painted correctly. As I said before, I want to solve the core issues first, then clean up the code so it actually behaves in a manner that makes sense.
    I don't know why the code didn't execute for you. Are you just not seing the text at 500,500? It should say: "My long string 222333111444555" in Green, with a transparent background (i.e. the screenshot of the background image.
    Thanks for your suggestions. I appreciate your help!

  • First Time With The URL Class

    Okay, I've been exploring the various classes available in Java, in the hope of building a web-indexer (more as an exercise in Java than anything useful). However, I've been snagged fairly early on, in that I can't even call the class constructor...
    Here's what I've got so far, for the class (called WebDoc):
    import java.net.URL;
    public class WebDoc {
        WebDoc( URL myURL) {
            System.out.println("This method works");
    }and for the test program:
    import WebDoc.*;
    public class WebIndexerTest1 {
        public static void main(String[] args) {
            WebDoc myDoc = new WebDoc("http://www.dcs.shef.ac.uk/~martin/test1.htm");
    }The WebDoc class has compile successfully, and is in the WebDocClass folder, in the correct place.
    At the moment, it throws the error:
    WebIndexerTest1.java [5:1] cannot access WebDocClass.WebDoc
    bad class file: C:\Documents and Settings\Joseph Lloyd\My Documents\Uni\OOPing\WebIndexer\WebDocClass\WebDoc.class
    class file contains wrong class: WebDoc
    Please remove or make sure it appears in the correct subdirectory of the classpath.
            WebDoc myDoc = new WebDoc("http://www.dcs.shef.ac.uk/~martin/test1.htm");
            ^
    1 errorwhich I assume means it can't find the WebDoc class. I can't see why not though. Can anyone help me out with this? I'm pretty sure it's something fairly obvious, but unfortunately not to me...

    Cheers for the input, especially about packages. It's been quite a bit since I last touched Java, and I've forgotten most of the syntax.
    After looking over the code, it's now modified to the following, but still throws up the original error that prompted me to start messing about with importing (for some reason). The WebDoc code is identical to before, but the test program has changed:
    import java.net.URL;
    public class WebIndexerTest1 {
        public static void main(String[] args) {
            String myString = "http://www.dcs.shef.ac.uk/~martin/test1.htm";
            URL myURL = new URL(myString);
            WebDoc myDoc = new WebDoc(myURL);
    }However, it still throws the following error, and I have, after perusing the documentation and help files, no idea on how to deal with it (I assume I should have some kind of exception handler there, but I don't see why the URL class is throwing the exception in the first place...):
    WebIndexerTest1.java [6:1] unreported exception java.net.MalformedURLException; must be caught or declared to be thrown
            URL myURL = new URL(myString);
                        ^
    1 error
    Errors compiling WebIndexerTest1. Any further help would be greatly appreciated, as this has been winding me up all day, and I apologise in advance if I'm displaying excessive stupidity in not noticing glaring errors...
    Cheers

  • Porblem with the FCConverter class

    Sorry guys about the last thread. I was so sleep deprived that day. Right now I AM LEARNING THE BASICS because this is an intro to java type corse.
    My problem:
    Classes: Temperature.java & FCConverter.java
    Purpose of program: To convert fareighheight to celcius and vice versa
    Problem: I don't have any clue on what to do to make the FCConverter to work. IU have messed around with this for hours and have not yet had any sucess.
    Note: This is an applet so I will supply the HTML source.
    The source code:
    File: TestTemperature.html
    <HTML>
    <HEAD>
    <TITLE>Test</TITLE>
    </HEAD>
    <BODY>
    <APPLET CODE="Temperature.class" WIDTH="200" HEIGHT="50"
    ALT="Test class failed">
    Java is disabled
    </APPLET>
    </BODY>
    </HTML>
    File: Temperature.java
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.text.DecimalFormat;
    public class Temperature extends JApplet
    implements ActionListener
    private JTextField displayF, displayC;
    private static DecimalFormat displayFormat = new DecimalFormat("0.0");
    public void init()
    Container c = getContentPane();
    c.setBackground(Color.white);
    c.setLayout(new GridLayout(2, 2, 10, 0));
    c.add(new JLabel(" Fahrenheit:"));
    c.add(new JLabel(" Celsius:"));
    displayF = new JTextField(6);
    displayF.setBackground(Color.yellow);
    displayF.addActionListener(this);
    c.add(displayF);
    displayC = new JTextField(6);
    displayC.setBackground(Color.yellow);
    displayC.addActionListener(this);
    c.add(displayC);
    public void actionPerformed(ActionEvent e)
    String s;
    double degrees;
    FCConverter fc = new FCConverter();
    if ((JTextField)e.getSource() == displayF)
    s = displayF.getText().trim();
    degrees = Double.parseDouble(s);
    fc.setFahrenheit(degrees);
    degrees = fc.getCelsius();
    displayC.setText(displayFormat.format(degrees));
    else
    s = displayC.getText().trim();
    degrees = Double.parseDouble(s);
    fc.setCelsius(degrees);
    degrees = fc.getFahrenheit();
    displayF.setText(displayFormat.format(degrees));
    File: FCConverter.java
    public class FCConverter
    public FCConverter()
    String s;
    double degrees;
    return (5/9); // s-32;
    I know temperature's source code is fine because it was supplied by our textbook but we have to write the FCConverter class and I'm am completely stuck on this.
    Can anybody point me in the right direction? Just tell me what methods I need and tell me where they need to be. I think I'll be able to figure the rest out, but this is the part where I'm completely stuck. Thanks for your time.
    __________________

    bbritta
    I think when you give somebody the answer it is
    typically applied without further thought. No
    learning takes place. You might've noticed it on the
    other thread, where you posted the code yet OP asked
    you to describe the algorithm too.
    In the end everyone looses out - OP does not learn,
    you forego the pleasure of teaching (as opposed to
    telling) and the rest of us get to read yet more
    questions that have the same error at their core.
    I hope that doesn't come across as moralizing. I
    respect your right to do as you please and will not
    raise this topic again. :-)I guess my teaching method needs a little work. I guess I start by assuming that if someone is asking a question they want to learn something.
    You might notice that in both cases I gave enough of the answer to help if they wanted to figure out what was going on, but not enough to simply solve the problem for them. It seems I'm just being too oblique.
    No offense taken. Feel free to comment on my posts.

  • Help with the Date class

    I have researched the documentation for this class, and find three constructors. One that is deprecated, one that creates a null Date object, and one that requires an explicit parameter-- a long integer which represents the amount of time in milliseconds that has passed since some day in 1970.
    I have imported the java utility with this bit of code,
    import java.util.*;For some reason, however, I am unable to construct a proper date object. I have passed it all different kinds of integers, but to no avail. Can anyone help me understand the documentation a little better so I can figure out what parameter it wants?

    I have researched the documentation for this class, and find three constructors.I find six.
    One that is deprecated,Four that are deprecated.
    one that creates a null Date object,No it doesn't. Would it make sense for a constructor to create a null?
    and one that requires an explicit parameter-- a long integer which represents the amount of time in milliseconds that has passed since some day in 1970.Yup, that's right.
    The Date constructor that doesn't take a parameter
    Allocates a Date object and initializes it so that it represents the time at which it was allocated, measured to the nearest millisecond.
    Not null.
    Instead of java.util.Date, it is usually appropriate to use java.util.Calendar and its concrete subclass java.util.GregorianCalendar.
    The static method Calendar.getInstance()
    Gets a calendar using the default time zone and locale. The Calendar returned is based on the current time in the default time zone with the default locale.
    See the documentation for other methods which allow you to manipulate the Date represented by the instance of Calendar.
    luck, db

  • Making a complex button with the Tween class...not sure why this isn't working.

    Hi all,
    I'm trying to make a button which scales up on rollover and
    scales down on rollout and I wanted to use the Tween class to do it
    because I'm going to be making a bunch of these buttons and I want
    the code to be as efficient as possible.
    So right now I have a circle in a movie clip, and here's what
    I have on the first frame of that circle's actions layer:
    import mx.transitions.Tween;
    import mx.transitions.easing.*;
    function grow(who) {
    var tw:Tween = new Tween(who, "_xscale", Strong.easeOut,
    100, 400, 1, true);
    var tw2:Tween = new Tween(who, "_yscale", Strong.easeOut,
    100, 400, 1, true);
    function shrink(who) {
    var tw3:Tween = new Tween(who, "_xscale", Strong.easeOut,
    400, 100, 1, true);
    var tw4:Tween = new Tween(who, "_yscale", Strong.easeOut,
    400, 100, 1, true);
    this.onEnterFrame = function() {
    trace(rewind);
    if (rewind == true) {
    shrink(this);
    this.onRollOver = function() {
    rewind = false;
    grow(this);
    this.onRollOut = function() {
    rewind = true;
    The circle scales up just fine but when I rollout it doesn't
    scale back down. I did a trace to see if my tween was being called
    and sure enough it was. So I did another trace to see if the
    _xscale or _yscale was changing and they both were going down to
    around 290 on rollOut although there's no noticeable difference in
    the size of the button, it just looks like it's sitting there.
    I was also wondering if importing the whole class library
    will add very much to my file size?
    Also, since I'm going to have a lot of these buttons on the
    stage at the same time (these buttons will be like markers all over
    a map so there'll probably be around 50+) would it be a bad idea to
    have that many onEnterFrame checks running simultaneously? Is that
    going to slow the user's CPU way down?

    Thanks for the suggestions guys.
    I tried your code and got the rollOut to work but the button
    blinks rapidly if the user rolls out and then rolls back in
    quickly. Here is a link to the swf:
    http://www.stationarynotes.com/studioI/buttonTest.swf
    It also has to reach a complete stop the first time the
    button expands or else it won't run the shrink function on rollOut.
    I put all of my code on the first frame of the movie clip's
    actions layer so here's what mine looks like:
    import mx.transitions.Tween;
    import mx.transitions.easing.*;
    function grow(who) {
    var tw:Tween = new Tween(who, "_xscale", Strong.easeOut,
    100, 400, 1, true);
    var tw2:Tween = new Tween(who, "_yscale", Strong.easeOut,
    100, 400, 1, true);
    tw.onMotionFinished=function():Void{
    who.onRollOut = function() {
    shrink(who);
    function shrink(who) {
    var tw3:Tween = new Tween(who, "_xscale", Strong.easeOut,
    400, 100, 1, true);
    var tw4:Tween = new Tween(who, "_yscale", Strong.easeOut,
    400, 100, 1, true);
    this.onRollOver = function() {
    grow(this);

  • I need help with the https class please.

    Hello, i need add an authentication field in my GET request using HTTPS to authenticate users. I put the authentication field using the setRequestProperty method, but it doesn't appear when i print all properties using the getRequestProperties method. I wrote the following code:
    try{
    URL url = new URL ("https://my_url..");
    URLConnection conexion;
    conexion = url.openConnection();
    conexion.setRequestProperty("Authorization",my_urlEncoder_string);
    conexion.setRequestProperty("Host",my_loginServer);
    HttpsURLConnection httpsConexion = (HttpsURLConnection) conexion;
    httpsConexion.setRequestMethod("GET");
    System.out.println("All properties\r\n: " + httpsConexion.getRequestProperties());
    }catch ....
    when i run the program it show the following text:
    All properties: {Host=[my_loginServer]}
    Only the Host field is added to my HttpsURLConnection. The authentication field doesnt appear in standar output. How can i add to my HttpsURLConnection an Authentication field?
    thanks

    I have moved this to the main Dreamweaver forum, as the other forum is intended to deal with the Getting Started video tutorial.
    The best way to get help with layout problems is to upload the files to a website and post the URL in the forum. Someone can then look at the code, and identify the problem. Judging from your description, it sounds as though the Document window is narrow, which would result in the final menu tab dropping down to the next row. Try turning on Live view or previewing the page in a browser. Design view gives only an approximate idea of the final layout. Live view renders the page as it should look in a browser.

Maybe you are looking for