Swing labels and file input

Okay, let's see if i can explain this in one go...
I have a file reader class as below:
package chineseanimals;
import java.io.*;
public class AnimalFileReader {
    public AnimalFileReader (String filename) {
         try{
FileReader fr = new FileReader(filename);
BufferedReader br = new BufferedReader(fr);
String s;
while((s = br.readLine()) != null) {
System.out.println(s);
fr.close();
      catch (Exception e)
        {   System.err.println("File input error");
}This is called up through:
AnimalFileReader animalFile = new AnimalFileReader(animal.toString().toLowerCase() + ".txt");
finalAnimal = animalFile.toString();
  public String getFinalAnimal() {
        return finalAnimal;
    }(Part of the Chineseanimals class .getAnimalFile method)
Which altogether is ran by this:
private void getAnimalsActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
    String year = tempYear.getSelectedItem().toString(); //tempYear is obtained through a JComboBox
    Chineseanimals getAnimals = new Chineseanimals(year);/* year is convertee into an animal for use in the animal.toString().toLowerCase() above*/
    getAnimals.getAnimalFile();
    resultsLabel.setText(getAnimals.getFinalAnimal());
}It prints the file no problem, in the NetBeans output box. However, at the Swing label i get:
chineseanimals.AnimalFileReader@c1cd1fHopefully that all makes some sort of sense. Ultimately i want to get it so that the resultLabel (which is a swing jLabel) displays the contents of the file read at (animal.toString().toLowerCase() + ".txt").
Where am i going wrong?

I'm going to assume your questions were rhetorical (mainly because i can't be bothered to answer them) and designed to point me in the right direction as well as make me think i was able to find my own answer.
Which i did, (completely by myself, that is).

Similar Messages

  • Swing Labels and IE 5.0

    Has anyone had any problem with IE 5.0 and using Swing Labels
    and Buttons. My labels keep getting cut off using IE5.
    For example : I have a JLabel with text = "Customer Name". It
    looks fine in Jdeveloper. When I deploy it to IE5.0, I
    get "Custom..." with the rest being cut off.
    Any Ideas ?
    Thanks in advance
    Greg
    null

    To see what's going on in the virtual machine you can check "enable java console" in the internet options>advanced. Then you can bring up the console in the view menu (I think). See if the virtual machine throws a NoSuchMethodError. If it does, it's all microsofts fault, as usual. (IE5 uses java 1.1.4, can you believe it?!)

  • Getting parameters from text and file input tag. .  canyou help me ?

    Hello!
    Is there anyway of getting parameters from an
    text field input in a form like :
    <form name="signinForm" method="post" action="uploadFile.jsp" enctype="multipart/form-data" >Actually I would like to insert the parameters and make the upload of an file
    on the same form. It is something likethis :
    Form.jsp
    <form name="signinForm" method="post" action="uploadFile.jsp" enctype="multipart/form-data" >   
    <input type="text" id="name" name="signinName" />
    <input name="signinFile" id="fileUp" type="file" />   
    <input type="submit" id="submit_btn" name="signinSubmit"/>uploadingFile.jsp
    <%@ page import="java.io.*,javax.servlet.http.HttpServletRequest,javax.servlet.ServletInputStream" %>
    <%@ page import="java.io.FileWriter,java.io.IOException" %>
    <%
    .//upload the file
    String email = request.getParameter("signinName").trim(); //this line is bringing me an NullPointerException
    %>Thanks in advance for any suggestion!!
    All the best!

    You cannot use the HttpServletRequest object to retrieve parameters from a multipart form. You'll have to use a package that can parse such a form. I suggest Apache commons FileUpload.
    http://jakarta.apache.org/commons/fileupload/
    Using this package you can get both the file upload and any other parameters.

  • Windows 7 and file input

    With the following code, it throws an error while trying to instantiate the scanner because apparently the file doesn't exist. I've tried putting the file in multiple places and using both absolute and relative paths. I am assuming the issue is with Windows 7. Any ideas?
            File file = null;
            Scanner scan = null;
            try{
                //JOptionPane.showMessageDialog(null,File.exists("C:\\Users\\stephen\\Documents\\javaprojects\\file.txt")); //also tried it with / and just file.txt
                file = new File("file.txt");
                JOptionPane.showMessageDialog(null,file.exists());
                scan = new Scanner(file);
            catch (Exception ex){JOptionPane.showMessageDialog(null,"Error while opening file"); System.exit(0);}

    stephensk8s wrote:
    If by user.dir you mean the directory that the program is in, then yes, I have it in there and have tried to access it from there.No, I mean user.dir which can be obtained from System properties. Based on your answer to my question, I am willing to bet you any amount that the error is neither Java's nor Windows 7.
    edit: if you place this in your code:
    System.out.println(System.getProperty("user.dir"));and place the file in this directory, will your program now work?
    Edited by: Encephalopathic on Oct 16, 2009 5:57 PM

  • What file(s) keep Bridge labels and ratings

    Using Bridge CS4  3.0.0.464, and have lost some of the labls and ratings I had given images. I was unable to regain them
    from .xmp files, or cache files, so had to get them from backed up folders of those images, though all the image files themselves
    were still fine. Would be nice to know as these help me keep track of things if I'd ever lose them again. Thank you.

    Dear all,
    I read this post and hope to clarify the design and ask some questions:
    Issue 1:
    How to access folder 'user/app data/Roaming/adobe/bridge' that Curt Y mentioned:
    Please note on Windows 7 or Vista, the folder 'AppData' is hiden by default, you can either show hiden files, folders and drives out by changing the OS folder options, or you can directly input the path '[CurrentUser]/AppData/Roaming/Adobe/Bridge CS5/' to enter the folder directly.
    Issue 2:
    Where the Labels and Ratings are stored.
    For all the XMP-supported files (e.g: include almost all the Camera Raw files, Images file, PDF, Illustrator files, InDesign files, video, audio, etc. An easy way in Bridge to know whether a file is XMP-supported file or not is to show out a property named 'Supports XMP' in metadata panel by checking on the item in Bridge Preferences -> Metadata -> File Properties -> Supports XMP), the Labels and Ratings are stored in the files themselves, or the file's sidecar file (for Camera Raw files, usually it is the .xmp file with same name of the raw file)
    For all the XMP-unsupported files (e.g: folders, .txt, .doc, .xls, etc...), the Labels and Ratings are stored in the hiden file named .BridgeLabelsAndRatings which located in the same folder with the XMP-unsupported files you labeled/rated.
    As I know, the file's labels and Ratings info won't be stored in the folder '[CurrentUser]/AppData/Roaming/Adobe/Bridge CS5/'.
    Issue 3:
    Labels and Ratings lost issue
    If you copy/move files inside Bridge, either XMP-supported files or XMP-unsupported file shouldn't lost their label/rating info.
    If you copy/move files outside Bridge, e.g, to copy or move them in Finder or Explorer:
    - XMP-supported files: Camera Raw files which have sidercar file
       will lost label/rating info because Finder/Explorer don't know their sidecar file should be bandled with the camera raw files.
    - XMP-supported files: other files which don't have sidercar file
       Shouldn't lost label/rating info because the metadata has been store in the files themselves.
    - XMP-unsupported files.
       Will lost label/rating info because Finder/Explorer don't know the label/rating info is stored in the hidden file .BridgeLabelsAndRatings and won't copy/move the file together.
    Questions:
    Peterimmn mentioned the label/rating lost when he saved a file, .
    - What application do you use to save the file?
    - What kind of files are you saved?
    - Are the files located on local disk?
    Thanks,
    Melissa
    Bridge QE

  • Auto Label and or Automoving LR files to Subfolder when Editing in Photoshop

    LR is great, but after using it for a while i miss a few things very much indeed and other colleagues back me up on this.
    It would be great to give the user an option to add a label to a photo when editing in Photoshop or other external application
    And also give the user an option to make a standard subfolder for the edited file.
    "Example"
    I import all raw files into a dated folder ex. 2007-09-20.
    Then i rate the files i like and filter them.
    Then i do the raw editing and then i finally open them into photoshop CS3.
    Here it would be great that the edited file automatically gets a yellow label and/or is put into a subfolder of 2007-09-20. This subfolder i typically would name FINAL.
    I know this would be troublesome due to the Stacking feature in LR, which is nice but i don't use it. So my requested features should only be enabled if i choose not to Stack my files.

    That's how it goes.

  • Photoshop CS3 font size of "label" and "description" of printed file

    How do you change and manage the font size of the "label" and "description" ( "file" > "file info" > "description")that you can opt to have printed above and below your photo?
    After typing in the "description" via "file info", you click on "print" and check off the "label" and "description" options.
    I'm using a Dell PC and an Epson CX3810.
    My instructor says that he's not been able to find out how to manage the font option.
    Thanks

    As a messy workaround you could put a simple string indicator ("classic Controls") on every tab over the page labels and change the text style/size etc. to your liking. Trouble is - the bound of the string indicator resizes while increasing the size of the text. As "size to text" doesn't work here maybe you can get the appropriate size from somewhere else. Document Bounds is not it, as I just found out. Possibly you should just use a free label, but I don't know whether their text is settable at runtime and their background can be altered.
    However - I think, you get the idea. Maybe it's worth 30 min testing...
    Attachments:
    changeStringtextSize.vi ‏22 KB

  • Can SQL*PLUS deal with 'flat ASCII files' (input ) in UNIX ? and how?

    Can SQL*PLUS deal with 'flat ASCII files' (input ) in UNIX ? and how?

    No, but PL/SQL can. Look at utl_file.
    John Alexander www.summitsoftwaredesign.com

  • Controlling the space between label and Input field in SELECT-OPTION

    Hi ,
    I am using WDR_SELECT_OPTIONS as a used component in order to dynamically generate the Select option in my WD Component.
    Can any one tell me if there is a way to control the spacing between Label and Input field?  This is because rest of the UI elements are in one particular order but for this dynamically generated UI.
    Please help me.
    Thanks,
    Kavitha

    Hi Kavitha,
    The label is required for accessibility reasons. It's not possible to remove it and to use your own label from outside the component to point to it. Labels cannot point to targets across views (and hence acress component) boundaries.
    Best regards,
    Thomas

  • Automator: Apply Color Label and Copy to Folder

    I'm trying my hand at Automator, and I need help with one of my workflows (⇪). Basically, it's a service (accessible via right-click) that will apply a color label on an image file, and then copy that image file to a corresponding folder with the same color label. My current version works fine, except for the fact that I had to create seven versions to accommodate all seven colors.
    Is there any way to turn the color into a variable? I want the workflow to prompt me for a color, and then use that choice to run a search for the appropriate folder. I'd rather not hard code the color choice into separate services that all do the same thing.
    Also, the service currently assumes that it will run fast enough before I can deselect the target file. I'm sure it's possible that the folder search could lag out while I select another file, and the service will ultimately copy the newly selected item, rather than the initial target. Is there a way to ensure the service acts on whatever was selected when it was first triggered?
    I don't know AppleScript beyond copying-and-pasting other people's codes, so that limits my automation quite a bit. I don't know how to prompt for a label index choice and then feed the result into a find function. I also don't know how to record the file path of the selected item, and then feed that into the copy function at the end to ensure it doesn't copy the wrong file.

    Typically a list of items is passed to a workflow, so you will usually (depending on what you are doing with the items) need to step through the items in that list. If there is only one destination folder with the target label, you can just search for it, otherwise you will need to specify the destination in some other way.
    The following Service workflow example assumes that there is only one destination folder that has a given label color. It gets the label index of one of the input items and finds a folder with the same index at a specified base location (to limit the search range).
    1) Input items are automatically passed to an application or service, otherwise another action to get FInder Items can be used
    2) *Label Finder Items* (show the action when the workflow runs)
    3) *Run AppleScript* (paste the following script)
    <pre style="
    font-family: Monaco, 'Courier New', Courier, monospace;
    font-size: 10px;
    font-weight: normal;
    margin: 0px;
    padding: 5px;
    border: 1px solid #000000;
    width: 720px; height: 340px;
    color: #000000;
    background-color: #DAFFB6;
    overflow: auto;"
    title="this text can be pasted into an Automator 'Run AppleScript' action">
    on run {input, parameters} -- copy to a labelled folder
    This action is designed to follow a "Label Finder Items" action.  It will get the
    first folder of the base folder that has the same label and copy the input items
    to that folder.
    input: a list of Finder items received from a "Label Finder Items" action
    output: a list of Finder items to be passed on to a following action
    set output to {}
    set skippedItems to {} -- this will be a list of skipped items (errors)
    set baseFolder to (((path to pictures folder) as text) & "Shelley:Mary:") as alias -- a place to start looking for the destination folder
    tell application "Finder"
    set theLabel to label index of (the first item of the input) -- just pick one, they should all be the same
    get folders of (entire contents of baseFolder) whose label index is theLabel -- include subfolders
    -- get folders of  baseFolder whose label index is theLabel -- no subfolders
    if the result is not {} then
    set theDestination to the first item of the result
    else -- no folder
    error number -128 -- cancel
    end if
    end tell
    repeat with anItem in the input -- step through each item in the input
    try
    tell application "Finder" to duplicate anItem to theDestination
    set the end of the output to (the result as alias)
    on error number errorNumber -- name already exists, etc
    set errorNumber to "  (" & (errorNumber as text) & ")"
    -- any additional error handling code here
    set the end of skippedItems to (anItem as text) & errorNumber
    end try
    end repeat
    showSkippedAlert for skippedItems
    return the output -- pass the result(s) to the next action
    end run
    to showSkippedAlert for skippedItems
    show an alert dialog for any items skipped, with the option to cancel the rest of the workflow
    parameters - skippedItems [list]: the items skipped
    returns nothing
    if skippedItems is not {} then
    set {alertText, theCount} to {"Error with AppleScript action", count skippedItems}
    if theCount is greater than 1 then
    set theMessage to (theCount as text) & space & " items were skipped:"
    else
    set theMessage to "1 item was skipped:"
    end if
    set {tempTID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, return}
    set {skippedItems, AppleScript's text item delimiters} to {skippedItems as text, tempTID}
    if button returned of (display alert alertText message (theMessage & return & skippedItems) alternate button "Cancel" default button "OK") is "Cancel" then error number -128
    end if
    return
    end showSkippedAlert
    </pre>

  • Gui labels and buttons not showing...

    I am using Java to create a gui and so far I have everything working.
    But there is a section of code thats not working out and Ill post the whole file here (not very big) to let you guys see whats going on. The issue lies in the action listner where I state "if a text feild is empty, display the option pane, else show the following" and its not showing the labels and buttons.
    Help?
    package student.information.search;
    import javax.swing.JFrame;
    import java.awt.GridBagLayout;
    import javax.swing.WindowConstants;
    import java.awt.Rectangle;
    import javax.swing.JLabel;
    import javax.swing.JOptionPane;
    import javax.swing.JPanel;
    import java.awt.ActiveEvent;
    import java.awt.Frame;
    import java.awt.GridBagConstraints;
    import java.awt.Insets;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.JTextField;
    import javax.swing.JButton;
    import student.information.readonly.ReadOnlyStudentForm;
    public class StudentSearch extends Frame implements ActionListener
       JTextField textField = new JTextField();
       JFrame frame = new JFrame();
       JPanel contentPane = (JPanel) frame.getContentPane();
       GridBagLayout gridBagLayout = new GridBagLayout();
        public StudentSearch()
            gridBagLayout.columnWidths = new int[]{20, 0, 12, 137, 17};
            gridBagLayout.rowHeights = new int[]{26, 0, 6, 0, 20};
            gridBagLayout.columnWeights = new double[]{1, 0, 0, 0, 0};
            gridBagLayout.rowWeights = new double[]{0, 0, 0, 0, 1};
            contentPane.setLayout(gridBagLayout);
            JButton button = new JButton();
            button.setText("Search");
            button.addActionListener(this);
            contentPane.add(button, new GridBagConstraints(3, 3, 1, 1, 0.0, 0.0, 13, 0, new Insets(0, 0, 0, 0), 0, 0));
            textField.setColumns(8);
            contentPane.add(textField, new GridBagConstraints(3, 1, 1, 1, 0.0, 0.0, 768, 2, new Insets(0, 0, 0, 0), 0, 0));
            JLabel label = new JLabel();
            label.setText("Student Seach");
            contentPane.add(label, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, 256, 0, new Insets(0, 0, 0, 0), 0, 0));
            frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
            frame.setTitle("Student Search");
            frame.setBounds(new Rectangle(500, 0, 500, 320));
            frame.setVisible(true);
       public void actionPerformed( ActionEvent arg0)
            if (textField.getText().equals(""))
              JOptionPane.showConfirmDialog(null, "Please enter a value in the search feild", "Error", JOptionPane.OK_CANCEL_OPTION); 
            else
               //Show the text fields here and the user information. 
                 *  While there are students for this search, change the text fields to Name, Last Name and ID and have a button called
                 *  View that when clicked allows for you to view all that students information.
                JLabel firstName = new JLabel();
                firstName.setText("Label");
                contentPane.add(firstName, new GridBagConstraints(5, 5, 1, 1, 0.0, 0.0, 768, 0, new Insets(0, 0, 0, 0), 0, 0));
                JLabel lastName = new JLabel();
                lastName.setText("Label");
                contentPane.add(lastName, new GridBagConstraints(3, 5, 1, 1, 0.0, 0.0, 256, 0, new Insets(0, 0, 0, 0), 0, 0));
                JLabel studentID = new JLabel();
                studentID.setText("Label");
                contentPane.add(studentID, new GridBagConstraints(1, 5, 1, 1, 0.0, 0.0, 256, 0, new Insets(0, 0, 0, 0), 0, 0));
                JButton viewStudentInformation = new JButton();
                viewStudentInformation.setText("Search");
                viewStudentInformation.addActionListener(new ActionListener()
                        public void actionPerformed(ActionEvent e)
                               //For viewing individual student information
                                new ReadOnlyStudentForm();
                contentPane.add(viewStudentInformation, new GridBagConstraints(7, 3, 1, 1, 0.0, 0.0, 13, 0, new Insets(0, 0, 0, 0), 0, 0));
    }

    In general when adding or removing components for a visible GUI you need to use:
    panel.add(...);
    panel.revalidate();
    panel.repaint();

  • Where i Put my swing application jar file in jboss

    Hi experts...
    I develope swing application and convert it into jar file....I know jnlp deployment using tomcat..In tomcat i
    put my appcation.jar in webapps/root folder...This is not similar in jboss..I dont know where i put my applcation.jar in jboss.If any body know the idea please let me know..

    Hi
    You have to put your jar file in
    server/default/deploy
    Regards
    M Fazal Ur Rehman

  • Transfering Bridge (and files) between computers

    I will soon be switching over to a new computer, which means overhauling my files and unfortunately Bridge. I know that my labels and keywords will transfer since they are attached to the files themselves in the metadata, but what about my collections? I have smart collections which would rebuild themselves once I re-constructed them on the new computer, but I also have some manually built collections that I don't fully remember the criteria for dragging certain pictures in them. I am not sure how to transfer either type of collection beyond having both computers open Bridge and manually reconstruct them. Since I am 1:1 transfering my files for the most part (i.e. keeping the same folder hierarchy), the new computer will have the same relative paths which might work to my advantage or might make no difference whatsoever. Any ideas on exporting/importing collections and other features of Bridge that may not be readily transferable or that are not stored in the metadata?

    You might want to explore the concept of "build and export cache" in tools/cache.  Not all data is written to the file, some is held in an XMP file, which has same name as file.  You want them both to transfer at same time.
    To see if you have XMP files click on view/show hidden files.
    Don't know much about collections.

  • How to click a label and pop up a Word Document

    hi!
    i know this question has been asked many times...i did a search...but got alot of stuff that were either too much for me to read...or too tough for me...
    i hope i can GEt some help here!
    i am in a rush..thats why i opted to post it here instead.
    question is:
    i have a JLABel. hwo to create a link that once i click on it... a MS word DOC will open??
    i already have the doc. file made...but need to link it to the label..such that once its clicked, the doc is opened...
    thanks alot!!!

    A very important message about problem solving: Divide and conquer.
    Stop thinking "clicking a label and open a word document".
    Think
    - "Clicking a label, and do something"
    - "open a word document from a java program".
    Go on, and think
    - "How do I make my program notice when a specific label gets clicked"
    - "What external command will open a word document?"
    - "How do I run an external command from a java application?"
    Look at the hints you've got. Read the documentation for the classes and methods you've been pointed towards. Look them up in the index in a good book. Read the tutorial. Write code. Experiment. Maybe come back here if you get stuck on something specific.

  • I have an iPad 2 and want to be able to design my own templates for invitations, labels, and such. What do I need to do to be able to do this? Apps??

    I have an iPad 2 and want to be able to design my own templates for invitations, labels, and such. What do I need to do to be able to do this? Apps??

    Take a look at these three sites and you might find something in one that will work for you.
    http://appadvice.com/appnn/2011/06/appguide-updated-vector-drawing-apps-ipad
    http://jaevin.com/blog/2011/02/20/ipad-sketching-drawing-apps/
    http://www.designer-daily.com/10-great-ipad-applications-for-creative-people-623 4
    I downloaded iDraw - which is an Adobe Illustrator wannabe for the iPad. You can export to PDF and other formats using iDraw. iDraw also supports file sharing. File Sharing is the iPad/iTunes way to send files back and forth from the iPad to your computer and back again.
    This site will tell you about iDraw.
    http://www.indeeo.com/idraw/
    This is a link to iOS File Sharing which you will find useful as well.
    http://support.apple.com/kb/ht4094
    There are third party apps in the app store that will allow you to use virtually any printer even if you don't have one of the HP AirPrint compatible printers.
    You can even use an app like Pages to create your templates. You can insert art and photos into Pages and it supports file sharing as well. Pages is a Word Processing app and I would be inclined to not use it for your purposes but it will work for some basic designs however it's certainly not ideal for creating artwork.
    http://www.apple.com/ipad/from-the-app-store/pages.html

Maybe you are looking for

  • Is there a way to import images that have been edited and assign them to the original?

    I am transitioning to mac and aperture. Is there a way to import images that have been edited and assign them to the original? I have 10,000 originals and about 2,000 edited images. The originals are named img_XXXX and anything modified img_XXXX_modi

  • Multiple plans for my SQL- Which one is following?-11gr2

    11gr2, windows-64-bit I have one sql_id part of 3rd part application, need to tune it. When I tried to get its execution plan im seeing multiple plan_plan values. That means, multiple plans for same sql_id How could we know that which plan my sql_id

  • Generated Program from transformation

    Hi, I have created a transformation and transported it into production. I had to changed one of the routine on a key figure. The last changed key figure is now executed last in the generated program. Example: Start routine: declared global variables

  • EHP1 for PI7.1 DEPLOY_ONLINE_DEPL error can't authenticate SAP*

    The error is: Phase parameters have been checked. All required 1 phase parameters have been set. Mar 4, 2010 7:01:16 PM [Info]:    com.sap.sdt.sapjup.tools.sapjupjspm.SAPJupJSPMRapiAdapter.connect(SAPJupJSPMRapiAdapter.java:150) [Thread[main,5,main]]

  • Verification of data quality in migration process

    Hi All, I am in a project that migration data from SQLserver to Oracle database. But my quesion is not performance but the check of data quality. My procedures to move data is: a) Extract data to a flat file from SQLserver via a GUI tool b) ftp it to