Problems creating my own JTextField

i'm trying to write my own textfield that will get a string of the following format: 1-4 digits, "/", 2 digits.
so I wrote a new class, but it doesn't work at all.
help, please.
package union.General;
import javax.swing.*;
import javax.swing.text.*;
import union.Entities.UnionCase.*;
public class JOfficeCaseIdField
extends JTextField {
public JOfficeCaseIdField() {
setText(" / ");
protected Document createDefaultModel() {
return new JOfficeCaseIdDocument();
protected class JOfficeCaseIdDocument extends PlainDocument {
public void insertString(int offs, String str, AttributeSet a) throws
BadLocationException {
char[] source = str.toCharArray();
char[] result = new char[7];
int j = 0;
for (j=0; j<result.length; j++) {
result[j] = ' ';
j=0;
for (int i = 0; i < source.length && j<result.length; i++) {
if (offs + j == 4) {
j++;
if (Character.isDigit(source))
result[j++] = source[i];
else {
//invalid character '/' is done by this document and the user should only enter digits
result[4] = '/';
super.insertString(offs, new String(result, 0, j), a);

how bout this, why doesn't this work well?
static final private int DASH_PLACE_FROM_END = 3;
static final private int MAX_STRING = 7;
static final private char DASH_CHAR = '/';
static final private String DASH_STRING = new String(new char[] {DASH_CHAR}); //the string "/"
protected class JOfficeCaseIdDocument extends PlainDocument {
public void insertString(int offs, String str, AttributeSet a) throws
BadLocationException {
char[] source = str.toCharArray();
char[] target = new char[str.length()];
int finalLength = 0;
for (int i=0; i<source.length; i++) {
if (Character.isDigit(source)) {
target[finalLength++] = source[i];
String mainString = new String(target,0,finalLength);
String oldText = getText(0,getLength());
String newInsertString;
this.remove(0,getLength());
newInsertString = oldText;
String firstString = "";
String lastString = "";
if (offs > 0 ) {
firstString = newInsertString.substring(0,offs);
if (offs<newInsertString.length()) {
lastString = newInsertString.substring(offs,newInsertString.length());
newInsertString =
firstString +
mainString +
lastString;
newInsertString.replaceAll(DASH_STRING,"");
if (newInsertString.length() >= DASH_PLACE_FROM_END) {
newInsertString =
newInsertString.substring(0,newInsertString.length()-DASH_PLACE_FROM_END) +
DASH_STRING +
newInsertString.substring(newInsertString.length()-DASH_PLACE_FROM_END+1,
newInsertString.length()-1);
super.insertString(0, newInsertString, a);

Similar Messages

  • How can i create my own component

    hello all,
    how can i create my own componet,
    say for example i want to create my own JTextField.
    give me links, or give me a examples
    thanks
    daya

    http://www.onjava.com/pub/a/onjava/2004/08/11/desktop.html

  • Problem with creating my own class...

    Hi all,
    Purpose with this program:
    I want to create my own class StringThing which take a string parameter and transform the content toUpperCase().
    I have created a simple class StringThing which look like this:
    class StringThing {
    public String upperize (String u) {
    u.toUpperCase();
    return u;
    }And my class where I use the StringThing looks like this:
    import java.io.*;
    class UseStringThing{
    public static void main (String arg[]) throws Exception {
    BufferedReader keyboard = new BufferedReader(
    new InputStreamReader(System.in));
    String s,p;
    System.out.prinln("write a sentence!");
    s=keyboard.readLine();
    StringThing thing = new StringThing();
    p=thing.upperize(s);
    System.out.println(p);
    }Am I not supposed to transform my string parameter in my class by using for instance toUpperCase()? Or is there some fundamental rule or piece of code which I forgot?
    Thanks in advance,
    /Beginner-T-who-ripps-his-hear-over-this-small-problem

    Strings cannot be modified. What this line does:
    u.toUpperCase();
    is to create a new String object. toUpperCase() returns the newly created string and you are ignoring the returned value. What you want to do is:
    return u.toUpperCase();
    or
    u = u.toUpperCase();

  • Problem with PropertyChangeListener and JTextField

    I'm having a problem with PropertyChangeListener and JTextField.
    I can not seem to get the propertychange event to fire.
    Anyone have any idea why the code below doesn't work?
    * NewJFrame.java
    * Created on May 15, 2005, 4:21 PM
    import java.beans.*;
    import javax.swing.*;
    * @author wolfgray
    public class NewJFrame extends javax.swing.JFrame
    implements PropertyChangeListener {
    /** Creates new form NewJFrame */
    public NewJFrame() {
    initComponents();
    jTextField1.addPropertyChangeListener( this );
    public void propertyChange(PropertyChangeEvent e) {
    System.out.println(e);
    /** This method is called from within the constructor to
    * initialize the form.
    * WARNING: Do NOT modify this code. The content of this method is
    * always regenerated by the Form Editor.
    private void initComponents() {
    jTextField1 = new javax.swing.JTextField();
    jScrollPane1 = new javax.swing.JScrollPane();
    jFormattedTextField1 = new javax.swing.JFormattedTextField();
    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    jTextField1.setText("jTextField1");
    getContentPane().add(jTextField1, java.awt.BorderLayout.NORTH);
    jFormattedTextField1.setText("jFormattedTextField1");
    jScrollPane1.setViewportView(jFormattedTextField1);
    getContentPane().add(jScrollPane1, java.awt.BorderLayout.CENTER);
    pack();
    * @param args the command line arguments
    public static void main(String args[]) {
    java.awt.EventQueue.invokeLater(new Runnable() {
    public void run() {
    new NewJFrame().setVisible(true);
    // Variables declaration - do not modify
    private javax.swing.JFormattedTextField jFormattedTextField1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextField jTextField1;
    // End of variables declaration
    }

    If you want to listen to changes in the textfield's contents you should use a DocumentListener and not a PropertyChangeListener:
    http://java.sun.com/docs/books/tutorial/uiswing/events/documentlistener.html
    And please use [co[/i]de]  tags when you are posting code (press the code button above the message window).

  • Is this the start... Verizon is blocking Google Wallet which is very nice, and you probably don't know they are creating their own Verizon Wallet

    I have been with this company for over 10 years and frankly I always overlooked one thing wasn't to keen on and that was some of the services Verizon offered on their website which many of the account related services they have as apps so you can view from your phone are good and useful.  I have been an Android user since the first Moto Droid to the Incredible and Inc2, then I though I was gonna go iphone, until I was able to use one for a month.  Don't get me wrong it wasn't bad it was my brothers 4G on another network when he upgraded to the 4GS.  Anyway no real problems other than Android just has more to offer so I went with the Nexus Galaxy and stayed with Verizon, after I was flipping a coin to go to Sprint.  Anyway the reason I am leaving Verizon is due to their attempt to create apps to try to compete with googles apps and Verizon charges...  you can find most for free from the droid market(which is the Play store now) such as Navigation.  The free Google Nav is awesome, I also have google voice(free)  so I get text messages emailed to me and vmails emailed and texted to me as well as being able to listen straight from phone by pushing play by the missed call.  Verizon continutes to create these apps that also cost money and aren't near as good.  I actually feel bad for the people who think the VZ nav is in fact the google nav.  Now they are blocking a new service of Google's called Google Wallet.  It's free and really cool, but Verizon blocks you from installing it or using it and Verizon is spending over a 100,000,000 dollars to create their own Wallet APP  that i'm sure won't be free.  So it's not that one app as to why I am leaving, its a number of things that as an experienced user and add the fact that  I work in the tech industry, in sales that I Verizon taking advantage of customers, and I don't work that way or like it.   Okay you go buy a verizon phone, it will have the VZ Nav right there on the home screen, however there will be no google Nav, and for newbies they usually think this is the navigation everyone talks about.  You have to go download the Google Maps which is a turn by turn navigation always up to date and is awesome.  I watch my kid driving down the road at all times for free.   My point is now that their blocking Google Wallet because they are creating there own wallet, which won't be as good, and probably cost money to even spend money meaning they will charge for it.  What is the next brilliant thing that Google comes out with  that you can intergrate into your Google services.    So what is the point of trying to compete with Google on apps, I mean the Verizon wallet?  Why it makes no sense.  Why block an app thus not giving you the luxery.  They have their reasons of course such as security, and other reasons that it could cause problems but, hey if you dare to spend the outrageous amount of money to activate your hostspot to connect your computer wirelessly in a park.  75% of the people who do this are going to be on an unsecured network that anyone can connect to even with security turned on.  So they say there worried about security on the wallet app, because someone may cold get access to your small amount that most people keep on the google wallet but the wireless hotspot is putting much more that money out there. it's putting personal things and files on your computer out there.  I just dont' get why they can't provide their songs and ring tones and apps that allow you to see you data usage and leave the apps for the Google market.  For you who don't know please download google maps and you will have an awesome navivation.  Also google talk, voice, chat, and there apps on the google market for free such as a punch clock for time.  I saw one for over $14 on the verison app store.  So stick to what you are good at ,and don't block apps that other companies aren't blocking including at&T now, and they were in on the $100,000,000 to create this app along with Tmoblie and Verizon.  I use an android because of the capapbilites that google gives you, and the apps that they offer for free or no money.  Go look in the Verizon apps and see how much you will pay.  Most that cost money come preinstalled on your phone so all you have to do is use it and you start getting charged.  This is a 3 year decision making.  I don't like that people can easily get charged for services without even knowing just because the app was installed and they used it once.  Just stay with what your good at and let the android users rightly use the google apps.  After all Google Saved your business if you really want to think about it.  If you didn't have the android OS, how many sales would you be getting?  Where would your company be.  This app was developed by Google which means it ties into everything else such as making online payments with the google card.  Blocking APPS developed by the developer of the Operating System that single handedly changed  the game, and has Made  you as a company far better off than you would have ever been had they not developed android.  Not a good Idea.  Bite the hand that feeds you.

    I have been with this company for over 10 years and frankly I always overlooked one thing wasn't to keen on and that was some of the services Verizon offered on their website which many of the account related services they have as apps so you can view from your phone are good and useful.  I have been an Android user since the first Moto Droid to the Incredible and Inc2, then I though I was gonna go iphone, until I was able to use one for a month.  Don't get me wrong it wasn't bad it was my brothers 4G on another network when he upgraded to the 4GS.  Anyway no real problems other than Android just has more to offer so I went with the Nexus Galaxy and stayed with Verizon, after I was flipping a coin to go to Sprint.  Anyway the reason I am leaving Verizon is due to their attempt to create apps to try to compete with googles apps and Verizon charges...  you can find most for free from the droid market(which is the Play store now) such as Navigation.  The free Google Nav is awesome, I also have google voice(free)  so I get text messages emailed to me and vmails emailed and texted to me as well as being able to listen straight from phone by pushing play by the missed call.  Verizon continutes to create these apps that also cost money and aren't near as good.  I actually feel bad for the people who think the VZ nav is in fact the google nav.  Now they are blocking a new service of Google's called Google Wallet.  It's free and really cool, but Verizon blocks you from installing it or using it and Verizon is spending over a 100,000,000 dollars to create their own Wallet APP  that i'm sure won't be free.  So it's not that one app as to why I am leaving, its a number of things that as an experienced user and add the fact that  I work in the tech industry, in sales that I Verizon taking advantage of customers, and I don't work that way or like it.   Okay you go buy a verizon phone, it will have the VZ Nav right there on the home screen, however there will be no google Nav, and for newbies they usually think this is the navigation everyone talks about.  You have to go download the Google Maps which is a turn by turn navigation always up to date and is awesome.  I watch my kid driving down the road at all times for free.   My point is now that their blocking Google Wallet because they are creating there own wallet, which won't be as good, and probably cost money to even spend money meaning they will charge for it.  What is the next brilliant thing that Google comes out with  that you can intergrate into your Google services.    So what is the point of trying to compete with Google on apps, I mean the Verizon wallet?  Why it makes no sense.  Why block an app thus not giving you the luxery.  They have their reasons of course such as security, and other reasons that it could cause problems but, hey if you dare to spend the outrageous amount of money to activate your hostspot to connect your computer wirelessly in a park.  75% of the people who do this are going to be on an unsecured network that anyone can connect to even with security turned on.  So they say there worried about security on the wallet app, because someone may cold get access to your small amount that most people keep on the google wallet but the wireless hotspot is putting much more that money out there. it's putting personal things and files on your computer out there.  I just dont' get why they can't provide their songs and ring tones and apps that allow you to see you data usage and leave the apps for the Google market.  For you who don't know please download google maps and you will have an awesome navivation.  Also google talk, voice, chat, and there apps on the google market for free such as a punch clock for time.  I saw one for over $14 on the verison app store.  So stick to what you are good at ,and don't block apps that other companies aren't blocking including at&T now, and they were in on the $100,000,000 to create this app along with Tmoblie and Verizon.  I use an android because of the capapbilites that google gives you, and the apps that they offer for free or no money.  Go look in the Verizon apps and see how much you will pay.  Most that cost money come preinstalled on your phone so all you have to do is use it and you start getting charged.  This is a 3 year decision making.  I don't like that people can easily get charged for services without even knowing just because the app was installed and they used it once.  Just stay with what your good at and let the android users rightly use the google apps.  After all Google Saved your business if you really want to think about it.  If you didn't have the android OS, how many sales would you be getting?  Where would your company be.  This app was developed by Google which means it ties into everything else such as making online payments with the google card.  Blocking APPS developed by the developer of the Operating System that single handedly changed  the game, and has Made  you as a company far better off than you would have ever been had they not developed android.  Not a good Idea.  Bite the hand that feeds you.

  • How to create my own Apple ID and delete the old Apple ID .

    Hello please can anyone help me I recently brought the imac 27 is x maverick desktop. I had brought this imac from someone who no longer wanted it. My problem is I have managed to log on with my Apple ID . But when I go into my purchases of my apps it's saying its empty and I don't know how I create the imac to my Apple ID . I do have the old information of the person I brought it off the id and password but I don't know how to delete the old and create my own please if anyone can help and advice I would be really grateful thanks for your time and advice.

    I have multiple Apple IDs. Is there a way for me to merge them into a single Apple ID?
    Apple IDs cannot be merged. You should use your preferred Apple ID from now on, but you can still access your purchased items such as music, movies, or software using your other Apple IDs.
    From Here   http://support.apple.com/kb/HE37

  • How do I create my own eBook?

    I have many documents from school that I'd like to scan, convert to PDFs and then compile together into one PDF file. The problem is that whenever I scan a document, I can't compress it down enough without sacrificing quality, so I can't have a small PDF file. I have a few eBooks, and, looking at their properties, somehow the creators of those eBooks were able to compress their PDFs down enough without sacrificing any quality to the documents whatsoever. Here's an example:
    one eBook that I have is 696 pages, the filesize is 4,159,863 bytes, and it looks like it was simply scanned and put together, because the quality of the eBook matches the book that it came from (which I happen to own). True, the images in the eBook are black and white (some of the images in the book are in colour), but there is no noticeable depreciation in their quality. Whoever created it was using the application PScript5.dll version 5.2, the PDF producer Acrobat Distiller 6.0.1 (Windows), the PDF version is 1.5 (Acrobat 6.x), and was NOT optimized for fast web view. How did the author get the page size so small (kb wise) yet retain quality? If one were to do the math: 4,159,863 bytes divided by 696 pages equals 5976.81, then divided by 1000 equals 5.97681. Almost 6 kb per page? How is that possible?
    The smallest I could compress scanned images was about 20 kb, and the quality was terrible. In fact, the only way I could shrink them to that size was to scan them in Black and white (1 bit), and then distill them as much as I dared. The vast majority of documents that I'm scanning are black and white text with very little in the way of graphics.
    Here are the programs that I have at my disposal:
    Jasc Paint Shop Pro 8 and HP Director (for scanning with my HP PSC 1210 all-in-one printer, which has OCR technology)
    Microsoft Word 2000 (9.0.2720)
    Adobe Acrobat 5.0.5 (10/26/01) (yes, it has paper capture)
    Acrobat Distiller 5.0.5.2001101100
    It is driving me absolutely crazy that I cannot figure this out. Even creating my own job option in Distiller and adjusting the settings didn't help.
    It should be possible, with the programs that I have, to get the results I want. For those of you who believe I should upgrade to something beyond Adobe Acrobat 5, here's another example for you:
    There used to be a link on www.iartonline.ca (which no longer exists) to a PDF that is 13 pages long, created with the application Microsoft Word 8.0, the PDF producer is Acrobat Distiller 4.0 for Windows, the PDF version is 1.2 (Acrobat 3.x) and has a file size of 79,719 bytes. In contrast, I scanned two school documents (using OCR) into Microsoft Word, corrected any errors, and converted it to an Adobe PDF from there. The resulting size (for TWO PAGES) was 25 kb.
    So, in conclusion, it HAS to be possible for me to scan my documents, retain their quality while compressing their size, and compiling them into single file PDFs.
    I apologize for the lengthy explanation (this is why I couldn't ask the question on WikiAnswers), but hopefully this will save others interested in answering from asking irrelevant (to me) questions.
    Thank you for your time.

    I don't understand why this question hasn't been answered yet. Am I not explaining it in clear enough terms or in plain enough English?
    Since it seems to be such a big question to answer, I'll break it down:
    Once I have scanned an image, how do I convert that image into a small PDF?
    An example of what I mean: if I scan one sheet of paper...let's say it's a sheet of band music, meaning some text & mostly graphics in black and white...what settings would I use to convert that scanned image (that 'scanned image' could be in bitmap, jpg or just about any other kind of image file format) into a small PDF file? By 'small', I mean 20 kb or less (1 sheet of black and white text & graphics is DEFINITELY capable of being compressed down to that size with little to no loss of visual quality). I've messed around with various settings in Acrobat Distiller 5 AND 6, and the resulting PDFs have been WAY too big (100, 200, some even 400 kb). I've even done a scan of a sheet of band music, saved it as a jpg (82 kb), tried to open that jpg file in Acrobat 5, and received the message, "insufficient data for an image". Absolutely impossible, but it happened anyway. I've been able to open jpg files in Acrobat that were HALF that size and been able to save them as PDFs (of course, the quality was almost completely gone by that point).
    It's 2010. There are people out there who have been able to scan & save images as small PDFs (under 100 kb per sheet while retaining the quality of the scanned image) since at LEAST 2001. I fully believe that it's possible with the programs I have to accomplish such a goal, but I've exhausted almost every possible combination I can think of when it comes to scanning and Distiller settings.
    Once again, here's what I have at my disposal...
    An HP PSC 1210 All-in-one printer (has OCR technology)
    Adobe Acrobat 5.0.5
    Distiller 5 and Distiller 6
    HP Director (a program for scanning and setting scanning parameters)
    Jasc Paint shop pro 8 (also for scanning)
    There's definitely someone out there who knows how to do this. Mods?

  • UWL Help - How can i create my own task within the Enterprise Portal

    Dear all,
    I am currently working with UWL .
    I have tried the customization and those stuffs associated with UWL , and it is working properly.
    My current issue is , how can create my own task within the Portal ( not using Ad Hoc  Workflow , which is present in Portal) ?.
    If i can create my own task within portal by API or using another method , then How can i add that task link within the drop down box that is present in the Collaboration launch pad and Mytask Workset.?
    Is there any API regarding  UWL (which is useful for creation of custom tasks in Portal using Developer Studio by means of Portal Application Creation) ?
    How can i add that custom task in the drop down ?.
    I have tried the customization of existing UWL.
    I shall be grateful to those who can help me to solve this issue with links regarding the  solution of my problem's.
    with regards
    Kishor Gopinathan

    Hi Kishore,
    I am trying to do the same thing. When i am creating Collaboration Task, it has standard templates in the dropdown like "Single Step" and "Multi-Step" etc., If i want to create my own Custom Task Template and display in that dropdown, how can i do that? Your help is really appreciated.
    Thanks
    Vijay

  • Create your own graphics using Project ROME!

    Hi Romans,
    Ever want to add your own logo or graphic to your creations? Maybe you want to design a brand logo for your business or a festive turkey for your Thanksgiving cards and invitations.
    Learn more about creating vector graphics using Project ROME. Here are two tutorials on vector graphics: http://bit.ly/95QpFl and http://bit.ly/cKYfG8. And, one interesting thing to note, you can even create your own custom shapes using the paint brush tool.
    Let us know if you've enjoyed creating vector graphics in Project ROME, and if you had any trouble. We'd like to shape Project ROME with you in mind for the future!
    Thanks,
    Sarah
    Sarah
    Forum Moderator

    Romans,
    Thanks for the praise! Did you have a chance to create your own graphic after watching this video? Please do and let us know your thoughts on this feature. Was it easy after the tutorial? Were there any problems you incountered?
    Thanks again,
    Sarah
    Sarah
    Forum Moderator

  • Problem in Change own data service

    Hi ,
                I am facing problem in Change own data service. I am getting following error while opening the service.
    com.sap.tc.webdynpro.services.exceptions.WDRuntimeException: failed to create or init instance of model 'com.sap.xss.hr.cod.model.CodModel' in scope APPLICATION_SCOPE with instanceId 'null'
    Do I need to configure this service through SPRO under Personal Mangement -> Employee Self Service ->
    Server Specific Settings -> Adress Book -> Who's Who.
    Am I missing any configurational step on R3 side ?
    Kindly provide some solution.
    Thanks in advance
    Abhay

    Hi Abhay,
    You need to upgrade the EA_HR component to SP22. Alo make sure that SAP_HR and EA_HR components are in sync.
    SAP Note: 1081261
    Also refer thread: **Very Urgent**Do i need to upgrade SP level of EA-HR components
    Regards
    Deb

  • Problem creating login page in portal webapplication

    Hi all,
    I have been working with ADF for quite some years. Now, I have found webcenter portal on my path.
    I'm telling you this is square one all over again.......trying to figure out why the most simple things do not work like they should. like this one
    I'm on a project that has to build a new portal application. when you start it, you should be taken to a page where you have to log in.
    This is the only public page in the portal app. after logging in, you will see the start page of the portal app. From here you can go to other pages through a menu tree on the left side of the page (=within the page template).
    Anyway, I seem to no even get this to work........
    I have made two pages. a loginPage and a landingPage. I know you get a login.jspx and a home.jspx for free, but I want to make my own since I had problems attaching my custom pagetemplate. Some other thing that doesn't work........
    Anyway, I have made these two pages within the faces-config.xml I have tied the login_success action to my landingPage and the logout_success to the loginPage. I have also altered the login.html to redirect to my loginPage.jspx instead of the login.jspx On the loginPage Ideally, I would like to drag a login taskflow with a page-fragment where I have two inputfields and a button, which are connected to the o_w_s_l_LoginBackingBean. But that is for later, since it doesn't even work when I have put those two inputfields and button directly on my loginPage.jspx
    I have tried several different configurations using both the pages.xml file and the jazn-data.xml, but to no avail.
    What am I doing wrong? in the pages.xml, what should be the one with home as it's id? should both the loginPage and the landingPage be in there?
    Even when I manage to get the loginPage first at startup, the button (who's action is pointing to the doLogin of the o_w_s_l_LoginBackingBean) does nothing. Also nothing in the logs.
    Can anyone please tell me how I can get this to work?
    thanks a lot in advance.....

    Hi fisherman,
    custom login page can be created and it can be used in your custom template by simply creating your own login class :o_w_s_l_LoginBackingBean instead of using the default one.
    otherwise the second type of solution is :
    create a subform and write the following type of code in your jspx/jsff page.
    <af:subform id="sub_id">
    <af:panelFormLayout id="pt_pfl1" >
    <af:panelGroupLayout id="pgl1" layout="vertical" >
    <table>
    <tr>
    <td width="50%">
    <af:activeOutputText value="username"
    id="aot199"/>
    </td>
    </tr>
    <tr>
    <td width="50%">
    <af:inputText id="pt_it1" simple="true"
    value="#{o_w_s_l_LoginBackingBean.userName}"
    />
    </td>
    </tr><tr>
    <td width="50%">
    <af:activeOutputText value="password"
    id="aot198"/>
    </td>
    </tr>
    <tr>
    <td width="50%">
    <af:inputText id="pt_it2" simple="true"
    value="#{o_w_s_l_LoginBackingBean.password}"
    columns="30" secret="true"
    />
    </td>
    </tr>
    </table>
    </af:panelGroupLayout>
    </af:panelFormLayout>
    <af:spacer width="3" height="3" id="pt_s2"/>
    <af:panelGroupLayout id="pt_pgl14" layout="horizontal" halign="end" >
    <af:commandButton id="pt_logincb"
    action="#{o_w_s_l_LoginBackingBean.doLogin}"
    >
    </af:commandButton>
    this is a sample code,may be some errors are present.but it should work definity if you mention the login success page in faces-config.xml.
    Hope ,it will help you.
    Regards,
    Hoque

  • Create my own Component ???

    When I try to create my own component, I have alway the problem that the components do not resize with setBounds() or something similar. My Component is always shown at the position 4/23 (which depends on the Microsoft Windows Frame-Border-Size with title) and the size of my component is always the full size of the owner-frame.
    import java.awt.*;
    import java.awt.event.*;
    public class MyComponent extends Component implements MouseListener
        public MyComponent()
            setBounds(30, 30, 64, 64);      //this line was ignored
            setBackground(Color.white);
        public void paint(Graphics g)
            g.setColor(Color.black);
            g.drawRect(0, 0, 64, 64);
    // Mouselistener interface implementation
        public void mouseClicked(MouseEvent e) {}
        public void mouseEntered(MouseEvent e) {}
        public void mouseExited(MouseEvent e) {}
        public void mousePressed(MouseEvent e) {}
        public void mouseReleased(MouseEvent e) {}
    import java.awt.*;
    import java.awt.event.*;
    class Test extends Frame
        public Test()
            addWindowListener(new WindowAdapter()
                    public void windowClosing(WindowEvent e)
                        dispose();
                        System.exit(0);
            MyComponent m = new MyComponent();
            m.setBounds(60, 60, 128, 128);       //this line was ignored, too
            add(m);
        public static void main(String args[])
            Test mainFrame = new Test();
            mainFrame.setSize(400, 400);
            mainFrame.setTitle("Test");
            mainFrame.setVisible(true);

    Well, I believe the setBounds method is used when using Absolute Positioning. See the Swing tutorial on "Using Layout Managers":
    http://java.sun.com/docs/books/tutorial/uiswing/layout/index.html
    I don't use Frames but I know the default LayoutManager for a JFrame is the BorderLayout. By default any component added to a BorderLayout is placed in the CENTER of the layout and will resize to fill the available size of its container. Again, this information is contained in the above link.

  • Reflection problem: Creating Objects

    The Reflection Tutorial mentions this line "Fortunately, with the reflection API you can create an object whose class is unknown until runtime" but the examples given are hardcoding the classnames!!!
    Here is the example given
    class SampleNoArg {
    public static void main(String[] args) {
    Rectangle r = (Rectangle) createObject("java.awt.Rectangle");
    System.out.println(r.toString());
    static Object createObject(String className) {
    Object object = null;
    try {
    Class classDefinition = Class.forName(className);
    object = classDefinition.newInstance();
    } catch (InstantiationException e) {
    System.out.println(e);
    } catch (IllegalAccessException e) {
    System.out.println(e);
    } catch (ClassNotFoundException e) {
    System.out.println(e);
    return object;
    now how do i create a object at runtime without 'really' knowing what its class is. The following will definitely not work and am providing it as additional help in making others understand my problem.
    String cName = c.getName(); // fully-qualified name
    Object o = c.newInstance();
    if ( ( (cName)o).compareTo(...) ) {...}
    // where it is assumed that c is a Class i got previously, and that the class implements the Comparable interface.
    So anybody has any idea on how to do this? Thanks in advance.

    If you're talking specifically about comparing Objects that may or may not implement comparable, I suggest you create your own Comparator implementation that will work with any of the objects you are expecting to create.
    If you are talking about executing methods on general objects, there are two cases:
    1. Your object implements a known interface. In this case, you can check for this, using instanceof, and cast the object in order to call the required method.
    2. Your object should have a known method. In this case, use Class.getDeclaredMethod to retrieve a Method instance, and then execute that.
    RObin

  • Problems Creating PDFs

    A lot of problems creating PDFs come from using the wrong printer to create the PDF or underlying printfile.
    You should use Adobe's Distiller printer instance to create a PDF. This comprises the latest Adobe Postscript printer for your operating system plus the Distiller PPD.
    Don't use an HP printer to create your PDF. PostScript, or otherwise.
    Don't use a Xerox printer to create your PDF. PostScript or otherwise.
    See #1.
    Note: If you are outputting to a service bureau, you might want to use something other than the Distiller printer instance. However, if you encounter problems with your particular PDFs, try using the official method with the Distiller printer to see whether any problems are limited just to your setup. If problems persist, you might have to create your PostScript output using one printer driver and the PDF using Adobe's Distiller printer instance.
    Common problems include:
    Black and white, or greyscale, PDFs created from color FrameMaker books and documents.
    Distiller terminating the PDF creation process early, thus no PDF is created.
    Troubleshooting:
    For lack-of-color problems, first check you don't have Spot as Black set in the Frame Print dialog.
    Update the printer you are using to the latest Adobe PostScript printer driver version.
    Uninstall the printer you are using to create PDFs and to reinstall the latest version from scratch.

    FAQ: Creating PDF Files from FrameMaker Documents -- Why you should not use "save as PDF"! -- Windows & MacOS Only!
    Dov Isaacs - 07:02pm Dec 6, 2001 Pacific
    An issue that has come up over and over again on several FrameMaker and Acrobat/PDF email lists as well on the corresponding Adobe User-to-User forums is that of creation of PDF files. FrameMaker 5.5.6 and 6 have what looks like a convenient feature that is supposed to allow you to create PDF files via simply saving the document as a PDF file. I have gone on record as advising end-users not to use this approach for reliable creation of PDF files from FrameMaker documents under Windows and MacOS with FrameMaker 6 and earlier. Why do I most vociferously offer this advice and why doesn't the problem get fixed? And how SHOULD you create PDF files from FrameMaker?
    GOOD NEWS
    I will start with the good news. The "next major version" of FrameMaker will indeed have "save as PDF" re-implemented in a manner that it will be as reliable as printing to the "Acrobat Distiller" printer instance under Windows or the "Create Adobe PDF" desktop printer under MacOS. I am personally working with the FrameMaker development organization to make sure this really happens and is fully and properly tested and debugged! Furthermore, this next major revision of FrameMaker, unlike FrameMaker 6, will come with a Distiller installer that will properly install the "Acrobat Distiller" printer instance under Windows and the "Create Adobe PDF" desktop printer on the Macintosh (of course assuring that the latest PostScript driver is also automatically and correctly installed).
    DON'T USE "SAVE AS PDF"
    But what's wrong with "save as PDF" as currently implemented?
    The following are some of the SYMPTOMS reported over the last few years by FrameMaker users that were traced back to use of "save as PDF" under FrameMaker:
    (1) No PDF file is produced at all, possibly with a log file showing not-readily apparent PostScript errors during distillation.
    (2) The PDF file "loses" color in images. All or some images (raster, bitmap images, NOT vector artwork) appear in the PDF file in grayscale.
    (3) The resultant PDF file is on the wrong paper size, i.e., the document's logical page size does not match the output page size as seen in Acrobat or Acrobat Reader.
    (4) Some or all text in the resultant PDF file is blotchy looking or overly bold.
    (5) Some or all text in the resultant PDF file cannot be searched or indexed.
    (6) Some or all text in the resultant PDF file appears in Courier or in some other substitution font.
    (7) Interword or intercharacter spacing is a bit irregular in the resultant PDF file.
    (8) Content is missing in the margin areas of the page, i.e. you cannot do full-page bleeds.
    (9) Some or all page content is missing (other than margin areas).
    (10) Relatively inefficient PDF is generated.
    If this list by itself isn't enough for you, please note that some of these symptoms are very subtle and may escape attention when the PDF is first viewed or printed. Oftimes, it is when one attempts to manipulate the PDF file in Acrobat or repurpose its content or even view or print on a system other than the one on which the PDF file was created, that some of these symptoms make themselves obnoxiously visible (or invisible in some cases I won't make any bad jokes here about graphic examples!).
    It is important to understand that FrameMaker does NOT have its own native ability to create PDF. Any and all PDF created from FrameMaker documents is actually done by creating PostScript via the PostScript driver and having the Acrobat Distiller create PDF from that PostScript. The only exception to this is creation of PDF via the Acrobat PDFWriter driver, which is likewise not recommended (see below).
    In order for "save as PDF" to work correctly, FrameMaker must do the equivalent of calling Printer Setup and selecting the "Acrobat Distiller" printer instance under Windows or the "Create Adobe PDF" desktop printer under MacOS followed by setting the driver's options correctly for paper size, page range, etc., followed by sending the proper commands to the driver to create PostScript.
    Contrary to popular belief, PostScript as generated by the Windows and MacOS PostScript drivers is VERY device-dependent. The information in the PPD file associated with a printer driver instance provides critical parameters for generation of PostScript including:
    Whether the printer supports color (Acrobat Distiller does)
    What PostScript language level is supported (Acrobat Distiller 4.x and Acrobat Distiller 5.x are both PostScript language level 3)
    Whether native TrueType support is available (Acrobat supports native TrueType as Type 42 fonts)
    Available binary communications (Acrobat Distiller supports pure binary and ASCII, but NOT TCP, TBCP, or PJL)
    Resident fonts (Acrobat Distiller doesn't really have resident fonts)
    Available paper sizes and custom paper size availability (Acrobat Distiller supports a wide range of predefined sizes and continually variable "custom" sizes up to 200" by 200")
    Margins / printable areas (for PDF and the Acrobat Distiller, there are no margins in which imaging is not permitted)
    Device resolution (Acrobat Distiller can be set to any value from 72 to 4000 dpi; as a convenience, the Acrobat Distiller PPD provides a series of values for use by the driver. Since there is no inherent "resolution" of a PDF file, this parameter is used only for purposes of allowing PostScript programs that query for such a value to be satisfied and for the driver to be able to communicate this value to the operating system and/or application as required.)
    Paper handling (totally irrelevant to Acrobat Distiller if input or output tray selection via "setpagedevice" is found in the PostScript stream, it is ignored by Acrobat Distiller)
    Thus, if the wrong printer driver instance is selected (i.e., it isn't associated with the Acrobat Distiller PPD file) or that driver instance is improperly configured, improper PostScript will result and one or more of the symptoms described above can occur. As currently implemented, FrameMaker depending upon version will not necessarily choose the correct printer driver instance and/or correctly parameterize the print job via driver setup options. In fact, FrameMaker 5,5,6 might even try to generate PDF via calling a PCL driver, FAX driver, or even a non-PostScript inkjet printer!
    DON'T USE PDFWRITER
    The Acrobat PDFWriter is a relic of older versions of Acrobat. In fact, it is no longer installed by default in the "easy install" or the "typical install" of Acrobat 5. It hasn't really be updated since Acrobat 3 and only supports PDF 1.2. It is a GDI (Windows) / QuickDraw (MacOS) driver that directly generates PDF without any intermediary PostScript. Since it is not a PostScript printer driver, applications cannot pass through EPS graphics and/or PDFMark information (used for a wide variety of purposes by FrameMaker). For EPS graphics, most applications will send the low resolution TIFF (or PICT) EPS header in lieu of the PostScript text, if they send anything at all, to the driver. Forget about links, structure, or any other PDF "goodies." Expect that PDFWriter will fully "bite the dust" in the next major version of Acrobat.
    SO HOW DO I GENERATE PDF FILES FROM FRAMEMAKER 6 & EARLIER?
    The ONLY method that is really reliable for producing PDF files with FrameMaker 6 and earlier requires the generation of PostScript via a properly set printer driver instance associated with the Acrobat Distiller PPD and distillation of the resultant PostScript by Acrobat Distiller.
    Case 1: FrameMaker and the Full Acrobat 4.05 or Acrobat 5.0x Products
    PDF file from a "chapter" -- print directly to the Acrobat Distiller printer instance (Windows) or the Create Adobe PDF desktop printer (MacOS) already installed by Acrobat. If you check the "Acrobat data" option, then make sure to UNcheck the "print to file" option that gets set at the same time. As a result, the driver will automatically send the generated PostScript to the Distiller for you and delete the intermediate PostScript when done.
    PDF file from a "book" -- print directly to the Acrobat Distiller printer instance with the "print to file" option checked (Windows) or the Virtual Printer desktop printer (MacOS) associated with the Distiller PPD (see details below under Case 2/MacOS). You will need to manually process the resultant PostScript file through the Distiller (or use a "watched folder" arrangement).
    In both the above sub-cases, the default driver options generally will be OK, but check on paper size and communication protocol (Use pure binary, not ASCII, for optimal performance AND no CTRL-D characters under Windows. Make sure to set Level 3 only and Binary under MacOS. Font inclusion "All" for Acrobat 4.05 and "None" for Acrobat 5 under MacOS.). With Acrobat 4.05, make sure you preset the Distiller to use the joboptions you want. With Acrobat 5, you can set this on a job-by-job basis via the driver printer setup interface (or print dialog on MacOS).
    Case 2: FrameMaker 6 and the Bundled Acrobat 4.05 Distiller
    Windows -- Create a new printer driver instance using the latest version of the Adobe Universal PostScript Driver Installer, downloadable from Adobe's web site AND the Acrobat Distiller PPD file (located in the XTRAS subdirectory of the Distiller directory). This driver instance should be set to print to the local port named "FILE:". Name this driver instance as "Acrobat Distiller". The default driver options generally will be OK, but check on paper size and communication protocol (use pure binary, not ASCII, for optimal performance AND no CTRL-D characters). Make sure you preset the Distiller to use the joboptions you want. Print directly to this Acrobat Distiller printer instance. Make sure that the "print to file" option is checked. You will need to manually process the resultant PostScript file through the Distiller (or use a "watched folder" arrangement).
    MacOS -- Install the latest version of AdobePS 8.7.x, downloadable from Adobe's web site. In FrameMaker, go to Page Setup and select the "Virtual Printer" and go to the "Virtual Printer" window pane. Select the Acrobat Distiller PPD file (located in the XTRAS subfolder of the Distiller folder). Print directly to the "Virtual Printer" (Make sure to set Level 3 only, Binary, and font inclusion "All".). Make sure you preset the Distiller to use the joboptions you want. You will need to manually process the resultant PostScript file through the Distiller (or use a "watched folder" arrangement).
    Case 3: Acrobat 3
    Acrobat 3 is not officially supported for the latest OS versions and I personally would no longer recommend its use for generation of PDF files given that Acrobat 5.0.5 is the current version of Acrobat.
    - Dov

  • Can´t create my own icons/ folder is missing

    Hello everybody,
    The manual of logic express i read somehing about creating my own icons to use them in logic express.
    The Problem is that teh folder /Library/Application Support/Logic/Logic Resources/Icons does not exist. This is the place where the icons have to be put in.
    So I just created one but it doesn´t work. All Icons are 128*128 *.png files with alpha channel.
    I really want to use this fantastic option to put all my synths as icon in logic express.
    Please help me !!!!
    Thanks.
    Greetings from Germany,
    David

    Glad I found this, as I've been trying to figure this out too.
    Back when I had the Logic 6 Big Box I remember putting icons in the Emagic equivalent of the resources folder. I'll try this out, but I hope that they fix it so that we can put icons in the user folder. I like only having to drag and drop a home directory to backup. This creates more steps.
    Edit: Oh, found the fix from another thread. The manual is wrong. You should put your icons in ~/Library/Application Support/Logic/Images/Icons. If the folder isn't there, create it. You should be pleasantly suprised.

Maybe you are looking for