Java returning the reference of the current class.

Hi,
I want to write a method in Java to return the reference of the current class in a static manner i.e, without instantiating the class. Please help as to how to go about it.
Thanks.

Come on, at least point out where the guy is wrong.
user563329 wrote:
I want to write a method in Java to return the reference of the current class in a static manner i.e, without instantiating the class.There is no concept of a "current class" but I guess you meant "the class where the code is defined that the current thread is running now".
However, that means that class (code) has been instantiated so your question makes no sense.
If you want the class of the "current running code" use Object#getClass().
You can reference a class without instantiating it but it will still be loaded. For example:
public class TestInit {
    public static void main(String[] args) {
        System.out.println(Init.class.getSimpleName());
class Init {
    static { System.out.println("Init init"); }
// running it with java -verbose:class show Init is loaded but the static initializer is not run
// loading lots of class ending with
[Loaded TestInit from file:/C:/Projects/Dump2/Output/]
[Loaded java.lang.Void from shared objects file]
[Loaded Init from file:/C:/Projects/Dump2/Output/]
Init
[Loaded java.lang.Shutdown from shared objects file]
[Loaded java.lang.Shutdown$Lock from shared objects file]

Similar Messages

  • How can I return the current Date in Java?

    I am new to Java, and basically I want to know how I can return the current date as a variable, so for example, I have declared the following date variable
    private java.util.Date currentDate;How can I return the current date, do I have to write a method? To be more specific, I need to write a setMethod, that simply returns the current Date in Java.
    Please point me in the right direction.
    Thanks,

    If all you want is a date for printing or displaying, the easiest way is to use Date as shown below. If you need something more complex, look at the Calendar API.
    import java.util.Date;
    class DateEx
         public static void main(String args[])
              Date now = new Date();
              System.out.println(now);          
    }

  • How to get the current class name in static method?

    Hi,
    I'd like to get the current class name in a static method. This class is intended to be extended. So I would expect that the subclass need not to override this method and at the runtime, the method can get the subclass name.
    getClass() doesn't work, because it is not a static method.
    I would suggest Java to make getClass() static. It makes sense.
    But in the mean time, does anybody give an idea to work around it?
    Thank you,
    Bill

    Why not create an instance in a static method and use getClass() of the instance?
    public class Test {
       public static Class getClassName() {
          return new Test().getClass();

  • как вернуть текущий ключ how to return the current key

    подскажите как вернуть текущий ключ виндовс.так как диска востановления нет
    tell me how to return the current key vindovs.tak as repairing disk no

    Hi Xolostjak,
    Welcome to the HP Community, I hope you enjoy your experience! To help you get the most out of the HP Forums I would like to direct your attention to the HP Forums Guide First Time Here? Learn How to Post and More.
    It sounds like you are looking to to restore your original version of Windows because the Recovery Disk wasn't working. Is that correct? Since this is an English forum can you please respond back in English.
    I will be happy to help but I need some more information. I will need to know what your operating system is? What is the product number for your notebook?
    Thank you,
    Please click “Accept as Solution ” if you feel my post solved your issue.
    Click the “Kudos Thumbs Up" on the right to say “Thanks” for helping!
    Thank you,
    BHK6
    I work on behalf of HP

  • How to get the name of the current class...

    I'm writing a method for a superclass, to be used by all dervied classes. In the method, I want to be able to find out what class is running, and then use the instanceof operation on it. How do I do this? Something like:
    String className = this.getClass().getName();
    Class c = Class.forName(className);
    if (form instanceof c)
         System.out.println(" Yes");The compiler is telling me "the type named c is not defined." What am I doing wrong? Is there a better way to do this? I think there should be because the forName method loads the class, but all I want is the name in a form I can use the instanceof operation with.

    The instanceof operator takes an actual class name, not a reference to a Class. Sounds weird but perhaps an example would be more appropriate:
    if(obj instanceof MyClass.class)
    not
    Class c = Class.forName("MyClass");
    if(obj instanceof c)Fortunately Class provides methods that do pretty much the same as the instanceof operator:
    Class c = Class.forName("MyClass");
    if(c.instanceOf(obj))
    ...Hope this helps.

  • Looking for a function that returns the currently opened document type

    Dear SAP gurus
    I have a user exit for transaction VA02. In VA02, when I click on button (Item details-configuration),
    it launches a URL in a browser. I am asked to add to the URL, values like Document Type, Document Number
    and Line Item Number.
    I can get Document Number and Line Item Number from the presently opened Sales Document by using the standard Function 'CUCB_GET_OWNER_OF_CFG'.
    However, I am not able get the value of Document Type. Is there any function that will give me
    the value of the Document type of the present document that is open.
    Any feedback/Suggestion will be highly appreciated.
    Thanks
    Ram

    If you're in a VA02 user exit, the document type should be in VBAK-AUART, if I remember the field name correctly.  I would think that ANYWHERE in VA02, that field will be available to you.
    If you want the text of the document type, forward navigate from vbak-auart data element to the domain and look at the values...there'll be a config (T) table (and you may need to add T to the end to get the associated text table) that describes the document type in your system's language,  like:
    E OR   Order
    or something like that...  Sorry, in my installation, we don't use the logistics modules, so I'm writing from memory.

  • Is there a way to figure out what the current thread is?

    I've got the following snippet of code:
    // create a new thread. If the current thread is not this new thread, return
    Thread CountDownThread = new Thread("CountDownThread");
    CountDownThread.start();
    if (/*CURRENT THREAD*/.getName() != CountDownThread.getName()) {
         System.out.println ("I'm not CountDownThread. I'm leaving.");
         return;
    // current thread should be new thread. Therefore start the countdown
    CurrTime = InitTime;
    while(CurrTime.charAt(0) != '-') {      // go until current time is negative
         CurrTime = C.countDown();       // returns the current time based on the difference between the initial and elapsed time
         setText(CurrTime);                   // display current time in JLabel
    C.reset();
    setText(C.getCurrTime());What I'm trying to do is get a clock (C) to count down and display the time remaining in a JLabel (this snippet is taken from a method within that very JLabel which I'm extending from javax.swing.JLabel). While it's counting down, I'd like for the program to go off and do other things. Therefore, I'm trying to create a new thread that carries out the task of counting down while the original/main thread moves on to do other things.
    Please have a look at the above code and tell me if I'm on the right track. The one thing I don't know how to do is figure out how to tell which thread the current thread is. I'm assuming that both the new thread and original/main one will execute the if statement, the new one after it returns from start() (which I haven't defined). The original/main one will detect that it is not the new thread and return, whereas the new thread will and go on to the while loop. In the while loop, it will count down the clock until it reaches 0, after which point it will reset it and die.
    If I'm on the right track, all I need to know is how to detect which thread is currently executing. If I'm not on the right track, what would be the best way to do this?

    What? No! No Thread terminates on the return of start(). Those two events are unrelated!Uh... I think you misunderstood what I said.
    I didn't say that CountDownThread terminates upon returning from start() (which is what it sounds like you interpreted from me); I said that the thread that CountDownThread creates terminates once CountDownThread returns from start() (i.e. like any other local variable/object). This, of course, assumes that CountDownThread has a Runnable object on which to call its run() method (am I right?), in which case my code above doesn't create a new thread at all (i.e. CountDownThread.start() is executed within the main/original thread) - am I right?
    No, run() doesn't call start()! That would be stupid.Again, you misunderstood. I shouldn't need to explain this one. A simple reference to an ordinary dictionary on the words 'former' and 'latter' should suffice :)
    Anyway, all joking aside, I have now improved my code and it works! Here's what it looks like:
    ClockJLabel.java
    package MazeMania.clock;
    public class ClockJLabel extends javax.swing.JLabel {
    private Clock C;
    private ClockJLabelsRunnable CJLR;
    public ClockJLabel() {
      C = new Clock();
      CJLR = new ClockJLabelsRunnable();
      setText(C.getCurrTime()); // should be 00:00:00:00
      setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
      // need to figure out how to set the size so that it sticks
      setForeground(new java.awt.Color(255, 0, 0));
      setBackground(new java.awt.Color(0, 0, 0));
      setOpaque(true);
    // starts the clock counting up indefinitely from 0
    public void start() {
      (new Thread(new Runnable() {
        public void run() {
         while(true) setText(C.getElapsedTime());
       })).start();
      //System.out.println("Started clock...");
    // starts the clock counting down from an initial time and runs this count down in a separate thread
    public void countDown(String InitTime) {
      // initialize the clock
      try {C.initClock(InitTime);}
      catch(java.text.ParseException PE) {
       System.out.println(PE.getMessage());
      // initialize JLabel's display
      setText(C.getCurrTime());
      // prepare Runnable and give it to new Thread. New Thread starts count down.
      CJLR.task = CJLR.COUNTDOWN;
      CJLR.CJL = this;
      Thread CountDownThread = new Thread(CJLR);
      CountDownThread.start();
    public Clock getClock() {
      return C;
    }ClockJLabelsRunnable
    package MazeMania.clock;
    import java.lang.Runnable;
    class ClockJLabelsRunnable implements Runnable {
    public static int COUNTDOWN = 1;
    public static int COUNTUP = 2;
    // NOTE: this Runnable doesn't test for the proper setting of these variables
    public int task = 0;
    public ClockJLabel CJL = null;
    public void run() {
      Clock C = CJL.getClock();
      while(C.countDown().charAt(0) != '-') {CJL.setText(C.getCurrTime());}
      C.reset();
      CJL.setText(C.getCurrTime());

  • How to use the Rectangle class to draw an image and center it in a JPanel

    I sent an earlier post on how to center an image in a JPanel using the Rectangle class. I was asked to send an executable code which will show the malfunction. The code below is an executable code and a small part of a very big project. To simplifiy things, it is just a JFrame and a JPanel with an open dialog. Once executed the JFrame and the FileDialog will open. You can then navigate to a .gif or a .jpg picture and open it. What I want is for the picture to be centered in the middle of the JPanel and not the upper left corner. It is also important to stress that, I am usinig the Rectangle class to draw the Image. The region of interest is where the rectangle is created. In the constructor of the CenterRect class, I initialize the Rectangle class. Then I use paintComponent in the CenterRect class to draw the Image. The other classes are just support classes. The MyImage class is an extended image class which also has a draw() method. Any assistance in getting the Rectangle to show at the center of the JPanel without affecting the size and shape of the image will be greatly appreciated.
    I have divided the code into three parts. They are all supposed to be on one file in order to execute.
    import java.awt.*;
    import java.awt.image.*;
    import javax.swing.*;
    public class CenterRect extends JPanel {
        public static Rectangle srcRect;
        Insets insets = null;
        Image image;
        MyImage imp;
        private double magnification;
        private int dstWidth, dstHeight;
        public CenterRect(MyImage imp){
            insets = getInsets();
            this.imp = imp;
            int width = imp.getWidth();
            int height = imp.getHeight();
            ImagePanel.init();
            srcRect = new Rectangle(0,0, width, height);
            srcRect.setLocation(0,0);
            setDrawingSize(width, height);
            magnification = 1.0;
        public void setDrawingSize(int width, int height) {
            dstWidth = width;
            dstHeight = height;
            setSize(dstWidth, dstHeight);
        public void paintComponent(Graphics g) {
            Image img = imp.getImage();
         try {
                if (img!=null)
                    g.drawImage(img,0,0, (int)(srcRect.width*magnification), (int)(srcRect.height*magnification),
              srcRect.x, srcRect.y, srcRect.x+srcRect.width, srcRect.y+srcRect.height, null);
            catch(OutOfMemoryError e) {e.printStackTrace();}
        public static void main(String args[]) {
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    new Opener().openImage();
    class Opener{
        private String dir;
        private String name;
        private static String defaultDirectory;
        JFrame parent;
        public Opener() {
            initComponents();
         public void initComponents(){
            parent = new JFrame();
            parent.setContentPane(ImagePanel.panel);
            parent.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
            parent.setExtendedState(JFrame.MAXIMIZED_BOTH);
            parent.setVisible(true);
        public void openDialog(String title, String path){
            if (path==null || path.equals("")) {
                FileDialog fd = new FileDialog(parent, title);
                defaultDirectory = "dir.image";
                if (defaultDirectory!=null)
                    fd.setDirectory(defaultDirectory);
                fd.setVisible(true);
                name = fd.getFile();
                if (name!=null) {
                    dir = fd.getDirectory();
                    defaultDirectory = dir;
                fd.dispose();
                if (parent==null)
                    return;
            } else {
                int i = path.lastIndexOf('/');
                if (i==-1)
                    i = path.lastIndexOf('\\');
                if (i>0) {
                    dir = path.substring(0, i+1);
                    name = path.substring(i+1);
                } else {
                    dir = "";
                    name = path;
        public MyImage openImage(String directory, String name) {
            MyImage imp = openJpegOrGif(dir, name);
            return imp;
        public void openImage() {
            openDialog("Open...", "");
            String directory = dir;
            String name = this.name;
            if (name==null)
                return;
            MyImage imp = openImage(directory, name);
            if (imp!=null) imp.show();
        MyImage openJpegOrGif(String dir, String name) {
                MyImage imp = null;
                Image img = Toolkit.getDefaultToolkit().getImage(dir+name);
                if (img!=null) {
                    imp = new MyImage(name, img);
                    FileInfo fi = new FileInfo();
                    fi.fileFormat = fi.GIF_OR_JPG;
                    fi.fileName = name;
                    fi.directory = dir;
                    imp.setFileInfo(fi);
                return imp;
    }

    This is the second part. It is a continuation of the first part. They are all supposed to be on one file.
    class MyImage implements ImageObserver{
        private int imageUpdateY, imageUpdateW,width,height;
        private boolean imageLoaded;
        private static int currentID = -1;
        private int ID;
        private static Component comp;
        protected ImageProcessor ip;
        private String title;
        protected Image img;
        private static int xbase = -1;
        private static int ybase,xloc,yloc;
        private static int count = 0;
        private static final int XINC = 8;
        private static final int YINC = 12;
        private int originalScale = 1;
        private FileInfo fileInfo;
        ImagePanel win;
        /** Constructs an ImagePlus from an AWT Image. The first argument
         * will be used as the title of the window that displays the image. */
        public MyImage(String title, Image img) {
            this.title = title;
             ID = --currentID;
            if (img!=null)
                setImage(img);
        public boolean imageUpdate(Image img, int flags, int x, int y, int w, int h) {
             imageUpdateY = y;
             imageUpdateW = w;
             imageLoaded = (flags & (ALLBITS|FRAMEBITS|ABORT)) != 0;
         return !imageLoaded;
        public int getWidth() {
             return width;
        public int getHeight() {
             return height;
        /** Replaces the ImageProcessor, if any, with the one specified.
         * Set 'title' to null to leave the image title unchanged. */
        public void setProcessor(String title, ImageProcessor ip) {
            if (title!=null) this.title = title;
            this.ip = ip;
            img = ip.createImage();
            boolean newSize = width!=ip.getWidth() || height!=ip.getHeight();
         width = ip.getWidth();
         height = ip.getHeight();
         if (win!=null && newSize) {
                win = new ImagePanel(this);
        public void draw(){
            CenterRect ic = null;
            win = new ImagePanel(this);
            if (win!=null){
                win.addIC(this);
                win.getCanvas().repaint();
                ic = win .getCanvas();
                win.panel.add(ic);
                int width = win.imp.getWidth();
                int height = win.imp.getHeight();
                Point ijLoc = new Point(10,32);
                if (xbase==-1) {
                    xbase = 5;
                    ybase = ijLoc.y;
                    xloc = xbase;
                    yloc = ybase;
                if ((xloc+width)>ijLoc.x && yloc<(ybase+20))
                    yloc = ybase+20;
                    int x = xloc;
                    int y = yloc;
                    xloc += XINC;
                    yloc += YINC;
                    Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
                    count++;
                    if (count%6==0) {
                        xloc = xbase;
                        yloc = ybase;
                    int scale = 1;
                    while (xbase+XINC*4+width/scale>screen.width || ybase+YINC*4+height/scale>screen.height)
                        if (scale>1) {
                   originalScale = scale;
                   ic.setDrawingSize(width/scale, height/scale);
        /** Returns the current AWT image. */
        public Image getImage() {
            if (img==null && ip!=null)
                img = ip.createImage();
            return img;
        /** Replaces the AWT image, if any, with the one specified. */
        public void setImage(Image img) {
            waitForImage(img);
            this.img = img;
            JPanel panel = ImagePanel.panel;
            width = img.getWidth(panel);
            height = img.getHeight(panel);
            ip = null;
        /** Opens a window to display this image and clears the status bar. */
        public void show() {
            show("");
        /** Opens a window to display this image and displays
         * 'statusMessage' in the status bar. */
        public void show(String statusMessage) {
            if (img==null && ip!=null){
                img = ip.createImage();
            if ((img!=null) && (width>=0) && (height>=0)) {
                win = new ImagePanel(this);
                draw();
        private void waitForImage(Image img) {
        if (comp==null) {
            comp = ImagePanel.panel;
            if (comp==null)
                comp = new JPanel();
        imageLoaded = false;
        if (!comp.prepareImage(img, this)) {
            double progress;
            while (!imageLoaded) {
                if (imageUpdateW>1) {
                    progress = (double)imageUpdateY/imageUpdateW;
                    if (!(progress<1.0)) {
                        progress = 1.0 - (progress-1.0);
                        if (progress<0.0) progress = 0.9;
    public void setFileInfo(FileInfo fi) {
        fi.pixels = null;
        fileInfo = fi;
    }

  • Reflection: attributes from the base class

    Is there a way to get the attributes from the base class of a derived class via reflection? I only found methods to get the attributes from the derived class.
    Example:
    class A
    int a = 4;
    class B extends A
    int b = 5;
    Object unknown = new B();
    Code/Idea to get all attributes from baseclass A using unknown (here: a=4)?

    Thank you all for your hints. The mistake I make, was to use the baseclass, and not the derived class for getting the attributes. By using an extra parameter of type class I got all attributes in their context.
       private StringBuffer getDump(Object obj, Class cl)
             dmp.append(cl.getName() + " {\n");
             Field[] attribute = cl.getDeclaredFields();             <--- only the fields of the current class
             for (int j = 0; j < attribute.length; j++)
                attribute[j].setAccessible(true);
                try
                   if (attribute[j].getType().isPrimitive() || attribute[j].getType() == String.class)
                      dmp.append(attribute[j].getName() + "=" + attribute[j].get(obj) + "\n");
                   else
                      if (((attribute[j].getModifiers() & Modifier.STATIC) != Modifier.STATIC) &&
                          (attribute[j].getType().getName().startsWith("java.lang") == false) &&
                          ((attribute[j].getModifiers() & Modifier.FINAL) != Modifier.FINAL))
                         dmp.append(getDump(attribute[j].get(obj), attribute[j].get(obj).getClass())); <- recursive call
                catch (IllegalAccessException ex)
                   ex.printStackTrace();
             dmp.append("}");
          return dmp;
       }

  • How to interpret the current day of the month

    I am a rookie in java and am trying to play with the Calendar class.
    The DATE static field of this class says it returns "Field number for get and set indicating the day of the month."
    So, Calendar.DATE has to return the current day of the month.
    Today is 7th of january. So, it should return 7. But, I am getting a value of 5.
    I am very much confused. I fell that my interpretation os wrong.
    Please help.............
    Thanks in advance.

    You must NOT confuse the value of the constant Calendar.DATE (5) and how you can use that constant to retrieve the current day of the month.
            Calendar cal = Calendar.getInstance(); // Gets the current date
            int dayOfMonth = cal.get(Calendar.DATE); // Gets he current day of the month from the current date
                                                     // (Using the Calendar.DATE constant as method parameter).
            System.out.println("Calendar.DATE = " + Calendar.DATE); // Prints the constant
            System.out.println("dayOfMonth = " + dayOfMonth); // Prints the current day of month

  • Executable JAR file: Could not find the main class.

    Hello,
    I have a problem with making an executable JAR file.
    I have written a JAVA program that consists of five different classes of which User.java is the main class and I have saved a text document with Main-Class: User and a blank line after that.
    If I try:
    jar cmf MainClass.txt User.jar User.class Beheerder.class Operator.class Manager.class MaakVisueelSchema.class
    it makes a executable jar file which actually works! :)
    But when the Operator class trys to open the MaakVisueelSchema class the screen stays blank.
    I can run MaakVisueelSchema with java MaakVisueelSchema.
    So I tried to make an executable JAR that consists only of MaakVisueelSchema, the same way as I did for User:
    Main-Class: MaakVisueelSchema
    jar cmf MainClass.txt MaakVisueelSchema.jar MaakVisueelSchema.class
    Then I get the error message:
    Could not find the main class. Program will exit.
    from the Java Virtual Machine Launcher.
    The big difference between MaakVisueelSchema and the other classes is that MaakVisueelSchema contains a PaintComponent method and an ComponentListener. Is it possible that one of those creates the error?
    Can anyone help me with this problem?
    Thanks in advance!
    Bye!

    Yes,
    I tried:
    jar xvf MaakVisueelSchema.jar
    and it returns:
    META-INF/
    META-INF/MANIFEST.MF
    MaakVisueelSchema.classN/G. You need to manually create a manifest file in a text editor, have it point to your main class, and enter it in your jar command as an argument.

  • Correcting a bug in the JRE classes

    I have run across a bug in the class java.text.DecimalFormat
    I am using JSE 1.3.1_04, Windows XP professional o.s.
    The bug resides in the following method:
    public StringBuffer format(double number, StringBuffer
    result, FieldPosition fieldPosition)
    The following line of code within the abovementioned
    method will produce a "hotspot divide by zero error",
    if the variable named "number" contains a value of zero.
    boolean isNegative = (number < 0.0) || (number == 0.0 &&
    1/number < 0.0);
    I would like to repair this bug "in place" (actually change the line of code in error), and return the fixed class to the java.text package. How can I do this? I have extracted the source from the src.jar file, made the change, and now I need to replace the older version of this class.
    BTW, I have submitted a bug report, however, I cannot wait for the fix.

    Anyways, here is my somewhat "hacked" version of DecimalFormat.java to bypass the problem. Just make sure the following program resides in a directory that precedes the "rt.jar" file in the classpath.
    import java.text.FieldPosition;
    * A convenenience class to override the default implementation of DecimalFormat.
    * This is purely a "workaround" to avoid the "divide by zero" error that is occasionally
    * issued by the HotSpot  compiler.  See #format(double value) method for details
    * When (and if) there is a problem resolution in a future release, this program should be disabled
    * @author Stuart Leonard
    * @version 1.0
    * @since 09/08/2002
    class DecimalFormat
        private java.text.DecimalFormat decfmt;
        private String dft = "";
        private static final char       PATTERN_DIGIT              = '#';
         * The public constructor for this class.  Accepts a pattern to be used
         * by a java.text.DecimalFormat object
         * @param fmt The pattern to be used
        public DecimalFormat(String fmt)
            decfmt = new java.text.DecimalFormat(fmt);
            // check to see if last position of pattern is zero
            // if so, initialize a "zero balance" default pattern.
            if (fmt != null && fmt.length() > 0)
                StringBuffer strbuf = new StringBuffer(fmt);
                int endPos = strbuf.length()-1;
                if (strbuf.charAt(endPos) == '0')
                    int begPos = endPos;
                    for (int i = endPos; i>0; i--)
                        char chr = strbuf.charAt(i);
                        if (chr == PATTERN_DIGIT)
                            begPos = i+1;
                            break;
                    dft = strbuf.substring(begPos, endPos+1);
         * An overridden implementation of #java.text.NumberFormat.format(double)
         * If value is zero, then initialize return value with a blank suppressed
         * "zero balance" value, as specified by the original format pattern.
         * @param value The incoming double value to be formatted by a string pattern
         * @return The incoming value represented as a string pattern
        public String format (double value)
            String formatted = dft;
            if (value != 0)
                formatted = decfmt.format(value);
            return formatted;   
         * An overridden implementation of #java.text.DecimalFormat.format(double, StringBuffer, FieldPosition)
         * If value is zero, then initialize return value with a blank suppressed
         * "zero balance" value, as specified by the original format pattern.
         * Formats a double to produce a string.
         * @param number    The double to format
         * @param toAppendTo    where the text is to be appended
         * @param fieldPosition    On input: an alignment field, if desired.
         * On output: the offsets of the alignment field.
         * @return The value passed in as the result parameter
         * @see java.text.FieldPosition
        public StringBuffer format(double number, StringBuffer result,
                                   FieldPosition fieldPosition)
            StringBuffer strbuf = new StringBuffer();
            if (number != 0)
                strbuf = decfmt.format(number, result, fieldPosition);
            else   
                strbuf.append(dft);
            return strbuf;   
         * The default implementation of #java.text.NumberFormat.format(long)
         * This exists ONLY because of the "divide by zero" error that
         * is being issued by #java.text.DecimalFormat.format(double, String Buffer, FieldPosition)
         * @param value The incoming value to be formatted by a string pattern
         * @return The incoming value represented as a string pattern
        public String format (long value)
              return decfmt.format(value);
         * The default implementation of #java.text.DecimalFormat.format(long, StringBuffer, FieldPosition)
         * This exists ONLY because of the "divide by zero" error that
         * is being issued by #java.text.DecimalFormat.format(double, String Buffer, FieldPosition)
         * Format a long to produce a string.
         * @param number    The long to format
         * @param toAppendTo    where the text is to be appended
         * @param fieldPosition    On input: an alignment field, if desired.
         * On output: the offsets of the alignment field.
         * @return The value passed in as the result parameter
         * @see java.text.FieldPosition
        public StringBuffer format(long number, StringBuffer result,
                                   FieldPosition fieldPosition)
            return decfmt.format(number, result, fieldPosition);

  • What is "the current package"?

    In the java tute it says:
    "For your convenience, the Java runtime system automatically imports two entire packages:
    The java.langpackage
    The current package by default "
    What does it mean by the current package?

    All of the classes in the package that your own class resides in are automatically available to your code. So, if your class sit in
    package com.mycompany.mypackageThen every class that also sits in there will automatically be visible.

  • Coding - returning the number of characters in a text box.

    I am in the process of creating a cell phone simulation/animation in Edge Animate CC for use in a Captivate course. Basically, when a user clicks on number buttons on the virtual keypad, it displays the numbers in a text box , just like an actual cell phone would display the phone number on the screen as a caller is dialing. So, the user would click seven buttons and a seven-digit phone number appears on the virtual phone screen.  This part of my animation works great and all seven digits appear, but I would like to modify the code so that a hyphen appears after the third button clicked. This way, the output better resembles an actual phone number instead of just a string of seven digits.
    Here is an example of the code I currently have assigned to the #2 button on the virtual keypad:
    var text = sym.$("PhoneNum").html();
    text = text + 2;
    sym.$("PhoneNum").html(text);
    PhoneNum is the name of my text box on the stage where the digits appear as each keypad button is clicked.
    In order to incorporate the hyphen after the third button clicked, I need to somehow return the current number of characters in the PhoneNum text box, then create an if/else scenario that applies the hyphen after the third button clicked.
    Does anyone know how I can use either JavaScript or jQuery to return the number of characters currently in the PhoneNum text box?

    No problem!
    Basically the thing to remember is that unless you are needing to pass html to the object, you can use text() instead. text() also gives you the raw text without any html formatting (so you can assume what .html() would return)

  • InfoPath 2013: How to find the current file name?

    Hello,
    Is there any way to find the file name in the rule formulas when an existing xml file in a sharepoint form library is being edited in InfoPath? I am looking for a function that returns the current file name that is being edited.
    Thank you,

    Hi,
    According to your post, my understanding is that you want to get the current file name in the InfoPath form.
    Here is a similar thread for you to take a look at:
    http://social.technet.microsoft.com/Forums/en-US/a24f01d5-744c-4b75-b30d-3295311ab054/how-do-i-find-the-file-name-of-the-currently-open-infopath-form?forum=sharepointcustomizationlegacy
    Best Regards
    Dennis Guo
    TechNet Community Support

Maybe you are looking for

  • IDVD disk image

    If I create a slide slow of family photographs in iDVD and then save that slide show as a disk image can I just burn that disk image to a DVD in the Finder and have it play on my consumer DVD player that I use with my TV or do I have to burn the slid

  • Empty columns in the table that is populated with a dimension operator

    Hello, i use a dimension operator to populate a dimension. This dimension has a hierarchie with 3 levels. The mapping works but the columns that are located in higher levels aren't populated if the deepest level of the dimension is filled. The column

  • Spry Tabbed Pages Keep Shifting

    I have built a page using the Spry Tabbed Panels. I have one set inside of another. The problem is when you click a main tab and then a secondary tab and then roll over the main tabs again the width changes on the secondary tab. I have no idea why it

  • File and Making Directories on Mac

    I hope I put this question in the right place. I recently found out it is possible make directories using from the File class (.mkdir()), and I've been trying to use it in my program on my Mac, but it doesn't want to make the folder. I don't know why

  • I need recovery disks

    Hi, had problems with my laptop running bad and all kinds of problems. I decided to re-install the software back to the factory setup when I purchased the laptop. I have a new set of recovery disks I got from HP back then and I had never used them. I