How to see if JTextField is blank?

I have yet another question. How do you check to see if a JTextField is blank, for example:
    int i = 0;
    String s = jtfStudentID.getText();
    String c = jtfCourseID.getText();
    if ((s != null) && (c != null)) {
      FindStudAndCour(s, c);
    else {
      if (FindSC == 1) {
        while ((i < studentVec.size()) &&
              (!s.equals((String)studentVec.elementAt(i)))) {
          i++;
        if (i == studentVec.size()) {
          jtfMessage.setText("Student ID not found.");
        else {
          String t;
          int Grade = 0, Passed = 0, NumCourComp = 0, Average = 0;
          try {
            for (int j = 0; j < markVec.size(); j++) {
              if (s.equals((String)markVec.elementAt(j))) {
                NumCourComp++;
                t = (String)markVec.elementAt(j + 2);
                Grade = Integer.valueOf(t).intValue();
                Average = Average + Grade;
                if (Grade >= 50) {
                  Passed++;
            if(NumCourComp != 0){
              Average = Average / NumCourComp;
          catch (Exception x) {
            jtfMessage.setText("Error: " + x);
          jtfLastName.setText("" + studentVec.elementAt(i + 1));
          jtfFirstName.setText("" + studentVec.elementAt(i + 2));
          jtfAddress.setText("" + studentVec.elementAt(i + 3));
          jtfCity.setText("" + studentVec.elementAt(i + 4));
          jtfProvince.setText("" + studentVec.elementAt(i + 5));
          jtfPCode.setText("" + studentVec.elementAt(i + 6));
          jtfPhone.setText("" + studentVec.elementAt(i + 7));
          jtfEMail.setText("" + studentVec.elementAt(i + 8));
          jtfNumCourComp.setText("" + NumCourComp);
          jtfStudAverGrade.setText("" + Average);
          jtfMessage.setText("Student found.");
      else {
        while ((i < courseVec.size()) &&
              (!c.equals((String)courseVec.elementAt(i)))) {
          i++;
        if (i == courseVec.size()) {
          jtfMessage.setText("Course ID not found.");
        else {
          String r;
          int Grade = 0, Passed = 0, NumCourses = 0, Average = 0;
          try {
            for (int j = 0; j < markVec.size(); j++) {
              if (c.equals((String)markVec.elementAt(j))) {
                NumCourses++;
                r = (String)markVec.elementAt(j + 1);
                Grade = Integer.valueOf(r).intValue();
                Average = Average + Grade;
                if (Grade >= 50) {
                  Passed++;
            if(NumCourses != 0){
              Average = Average / NumCourses;
          catch (Exception x) {
            jtfMessage.setText("Error: " + x);
          jtfCourseName.setText("" + courseVec.elementAt(i + 1));
          jtfCoordinator.setText("" + courseVec.elementAt(i + 2));
          jtfNumStudPassed.setText("" + Passed);
          jtfAverGradeCourse.setText("" + Average);
          jtfMessage.setText("Course found.");
    }Colin

Try:
if (yourTextField.getText().trim().length() == 0) {
// do something here
Good luck!

Similar Messages

  • How to see available space in a blank dvd when burning in finder? It no longer display at the bottom of the finder window.

    How to see available space in a blank dvd when adding files in finder? It no longer displays at the bottom of the finder window.

    Choose Show Status Bar from the View menu.
    (113198)

  • How can I display JTextFields correctly on a JPanel using GridBagLayout?

    I had some inputfields on a JPanel using the boxLayout. All was ok. Then I decided to change the panellayout to GridBagLayout. The JLabel fields are displayed correctly but the JTextField aren't. They are at the JPanel but have a size of 0??? So we cannot see what we type in these fields... Even when I put some text in the field before putting it on the panel.
    How can I display JTextFields correctly on a JPanel using GridBagLayout?
    here is a shortcut of my code:
    private Dimension sFieldSize10 = new Dimension(80, 20);
    // Create and instantiate Selection Fields
    private JLabel lSearchAbrText = new JLabel();
    private JTextField searchAbrText = new JTextField();
    // Set properties for SelectionFields
    lSearchAbrNumber.setText("ABR Number (0-9999999):");
    searchAbrNumber.setText("");
    searchAbrNumber.createToolTip();
    searchAbrNumber.setToolTipText("enter the AbrNumber.");
    searchAbrNumber.setPreferredSize(sFieldSize10);
    searchAbrNumber.setMaximumSize(sFieldSize10);
    public void createViewSubsetPanel() {
    pSubset = new JPanel();
    // Set layout
    pSubset.setLayout(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    // Add Fields
    gbc.gridy = 0;
    gbc.gridx = GridBagConstraints.RELATIVE;
    pSubset.add(lSearchAbrNumber, gbc);
    // also tried inserting this statement
    // searchAbrNumber.setText("0000000");
    // without success
    pSubset.add(searchAbrNumber,gbc);
    pSubset.add(lSearchAbrText, gbc);
    pSubset.add(searchAbrText, gbc);
    gbc.gridy = 1;
    pSubset.add(lSearchClassCode, gbc);
    pSubset.add(searchClassCode, gbc);
    pSubset.add(butSearch, gbc);
    }

    import java.awt.*;
    import java.awt.event.*;
    import javax .swing.*;
    public class GridBagDemo {
      public static void main(String[] args) {
        JLabel
          labelOne   = new JLabel("Label One"),
          labelTwo   = new JLabel("Label Two"),
          labelThree = new JLabel("Label Three"),
          labelFour  = new JLabel("Label Four");
        JLabel[] labels = {
          labelOne, labelTwo, labelThree, labelFour
        JTextField
          tfOne   = new JTextField(),
          tfTwo   = new JTextField(),
          tfThree = new JTextField(),
          tfFour  = new JTextField();
        JTextField[] fields = {
          tfOne, tfTwo, tfThree, tfFour
        Dimension
          labelSize = new Dimension(125,20),
          fieldSize = new Dimension(150,20);
        for(int i = 0; i < labels.length; i++) {
          labels.setPreferredSize(labelSize);
    labels[i].setHorizontalAlignment(JLabel.RIGHT);
    fields[i].setPreferredSize(fieldSize);
    GridBagLayout gridbag = new GridBagLayout();
    JPanel panel = new JPanel(gridbag);
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.weightx = 1.0;
    gbc.weighty = 1.0;
    gbc.insets = new Insets(5,5,5,5);
    panel.add(labelOne, gbc);
    panel.add(tfOne, gbc);
    gbc.gridwidth = gbc.RELATIVE;
    panel.add(labelTwo, gbc);
    gbc.gridwidth = gbc.REMAINDER;
    panel.add(tfTwo, gbc);
    gbc.gridwidth = 1;
    panel.add(labelThree, gbc);
    panel.add(tfThree, gbc);
    gbc.gridwidth = gbc.RELATIVE;
    panel.add(labelFour, gbc);
    gbc.gridwidth = gbc.REMAINDER;
    panel.add(tfFour, gbc);
    final JButton
    smallerButton = new JButton("smaller"),
    biggerButton = new JButton("wider");
    final JFrame f = new JFrame();
    ActionListener l = new ActionListener() {
    final int DELTA_X = 25;
    int oldWidth, newWidth;
    public void actionPerformed(ActionEvent e) {
    JButton button = (JButton)e.getSource();
    oldWidth = f.getSize().width;
    if(button == smallerButton)
    newWidth = oldWidth - DELTA_X;
    if(button == biggerButton)
    newWidth = oldWidth + DELTA_X;
    f.setSize(new Dimension(newWidth, f.getSize().height));
    f.validate();
    smallerButton.addActionListener(l);
    biggerButton.addActionListener(l);
    JPanel southPanel = new JPanel(gridbag);
    gbc.gridwidth = gbc.RELATIVE;
    southPanel.add(smallerButton, gbc);
    gbc.gridwidth = gbc.REMAINDER;
    southPanel.add(biggerButton, gbc);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.getContentPane().add(panel);
    f.getContentPane().add(southPanel, "South");
    f.pack();
    f.setLocation(200,200);
    f.setVisible(true);

  • How to see if rental film has been charged

    How to see if rental film has been charged to my iTunes account, because it has left a blank grey square instead of a picture??

    You can view account's purchase history via the Store > View Account menu option on your computer's iTunes, or (on the current version of iTunes) by clicking on your name towards the top right of iTunes and clicking Account Info on the popup) : See your purchase history in the iTunes Store - Apple Support
    Or on your iPad, or on a browser on a computer, you can view the last 90 days purchases on your account (and optionally contact iTunes Support if you have a problem with a purchase) via http://reportaproblem.apple.com

  • How can i open a new blank page, if i open a new tab??

    how can i open a new blank page, if i open a new tab?? because if i click the plus "+" sign(at right corner) it open a website that i don't like.... please help meee....

    Start Firefox in [[Safe Mode]] to check if one of the add-ons is causing the problem (switch to the DEFAULT theme: Tools > Add-ons > Themes).
    * Don't make any changes on the Safe mode start window.
    See:
    * [[Troubleshooting extensions and themes]]

  • When building a web site, how do I set up a blank browser page that I can pull html & css files into.

    When building a web site, how do I set up a blank browser page that I can pull html & css files into.

    David's book is a good place to start. This is really far more involved that can be covered in this forum. You'll need to get familiar with a database, most likely MySQL, PHP, how to send requests tot he database - queries - and most likely maintain a state with Sessions. As you can see, it's a bit involved. The good news is this skills you'll acquire to do this will go a long way! It will cover all the basic requirements of web application development.
    Dive in, and have fun!
    Lawrence   *Adobe Community Expert*
    www.Cartweaver.com
    Complete Shopping Cart Application for
    Dreamweaver, available in ASP, PHP and CF
    www.twitter.com/LawrenceCramer

  • HT3266 HI... I NEED SEE MY ID OF MY COMPUTER.. IS THE UUID HOW I SEE THIS? IS NOT THE IP OR SOMETHING LIKE THAT.. PLEASE I NEED UR HELP PLEASE...

    Hi everyone.. the problem is: The server have all the UUID or ID of the computers.... but in windows we know how to see that but in mac we dont have idea to where see this number... so.. i try in terminal with some commands but everytime say the UUID of hardware or UUID of user but i need other UUID and this UUID is the number that the server say that is mine....
    Is strange....
    In windows we found a program,, but in mac i dont find some program can help my problem... My UUID is the same only show me the UUID of Hardware... i need the 4 UUID of the computers...
    Thanks

    Ok, Mr. Happy Duck, mouse over to the Apple menu in the top/left corner, select About this Mac. Click on More Info... then on System Report... The Hardware overview should give you all you need.

  • In SQL Trace how to see which statement getting more time .

    Hi Expart,
    In SQL Trace (T-code ST05) . I am running the standard transaction . how to see which statement
    running more time and less time . suppose one statement running more time so how resolve the
    performance .
    Plz. reply me
    Regards
    Razz

    > The ones in 'RED' color are the statement which are taking a lot of time and you need to
    > optimise the same.
    No, that is incorrect, the red ones show only the ones which need several hundret milliseconds in one execution. This can even be correct for hard tasks. And there are lots of problem, which you will not see
    I have said everything here:
    SQL trace:
    /people/siegfried.boes/blog/2007/09/05/the-sql-trace-st05-150-quick-and-easy
    Go to 'Tracelist' -> Summarize by SQL statements', this is the view which you want to see!
    I summarizes all executions of the same statement.
    There are even the checks explained, the slow ones are the one which need a lot of time per record!
    See MinTime/Rec > 10.000 microseconds.
    Check all number of records, executions, buffer, identicals.
    The SE30 Tipps and Tricks will not help much.
    Siegfried

  • How To See Numbers In Arabic Instead Of Indian Format

    I want to see numbers in Arabic format not in Indian format when i log on the Arabic Interface .
    I have EBS (12.0.6) installed on Linux centos , I have implement the below Oracle Metalink Note to solve this issue
    How To See Numbers In Arabic Instead Of Indian Format [ID 785243.1]
    I installed all the patched mentioned in the note (Apply forms version 10.1.2.2.0 with the forms patch 7488328 , Apply patch 7207440:R12.TXK.A , Apply patch 7601624 - NEW PROFILE OPTION: FORMS DIGIT SUBSTITUTION)
    These patches add the Profile option (FORMS DIGIT SUBSTITUTION) , but when i try to used it has no effect at all .
    So kindly if you have any idea about this issue please help me.
    Regards
    Fadi Lafi

    Hi,
    These patches add the Profile option (FORMS DIGIT SUBSTITUTION) , but when i try to used it has no effect at all .At what level you have set this profile option?
    So kindly if you have any idea about this issue please help me.Have you bounced the application services after setting this profile option? If not, please do so, login again and see if it works.
    Thanks,
    Hussein

  • TS2972 I have finished home sharing for my macbook air and apple tv, now how to see my macbook air on the TV monitor?

    how to see my macbook air on the TV monitor after I finished home sharing for the system?

    Did you purchase your MacBook Air new?  Do you still have its box?  Locate its serial number and telephone Apple at the number shown at the bottom of this page (1-800-MY-APPLE if you're in the U.S.).  They can help you.

  • How to see the Open PO Qty in Mass

    Dear Experts,
                        How to see the Open Qty in PO in mass, is there any report available..Please help 
    Regards
    karthik

    use the Txn ME2N
    Enter the follwoing details . Scope of list - ALV, Selection parameters- WE101, Plant- XXXX, Enter the document dates From and TO and execute ( F8), You will get all the details, If you want to adjust the format use cntrl+F8 to get the POP_up for selection of fields and use as you wish.

  • How to see the balance under different balance if special ledgers exist???

    Some of the company using special ledgers. I need to teach user how to see the balance under different balance.
    I will focus on
    1. display voucher
    2. check GL balance
    Anyone have idea (detailed flow)/template (preferred) on these issues?
    Thanks a lot for your help in advance

    hi,
    /n----
    > acccounting -
    >financial accounting -
    >GL acccounts -
    > information system -
    > gl reports
    here in this path u can get all the gl list and gl balances list ....
    u can check what ever reports u want.....
    if useful assign points...
    regards,
    santosh kumar

  • How to see Trial Balance for a Segment

    Hi Experts,
    Does anybody has idea on how to see Triala Balance for a Segment ?
    In Standard Reports for Balance Sheet and Profit & Loss, SAP B1 has provided option for filtering on Segment, but the same is not true for Trial Balance.
    BR
    Samir Gandhi

    Hi Samir,
    yes it is possible to display Trial Balance in Segment format.
    open Trial Balance Report, in the Upper right hand of the of the window next to G/L Accounts you can find the "FIND" button, click that one then the Find G/L Account window opens. from this window you cans Select Segmentation accounts.
    regards,
    Fidel

  • How to see the print preview of outgoing excise invoice.

    Hi Experts,
    How to see the print preview of outgoing excise invoice.
    Thanks,
    srinivas.

    Dear Sreeni,
    Just go to J1IIN, click on "Exc.inv for delivery -- Display" where you input delivery reference and execute. If you have generated excise invoice, you can see the corresponding excise invoice for that delivery / billing document.
    Preethi.

  • How to see photos on icloud drive with iphone 5c ios 8.1

    how to see photos loaded onto icloud drive with iphone 5c ios 8.1?? carnt see them in the new photos app everythings up to date and icloud enabled on phone??
    many thanks

    Go to iCloud.com on a computer. To see them on your iPhone go to iCloud.com in Safari. Tap the URL field. Pull favorites down and tap request desktop site. Sign into your iCloud account. Now you can view iCloud Drive or Photos if you turned on iCloud Photo library.

Maybe you are looking for

  • OWSM: Gateway has encountered an unexpected error

    Hi everyone, Oracle SOA suite version: 10.1.3.1.0 I tested a web services application which deployed on GlassFish 9.1 (Java EE 5) on Test Page of OWSM, all the services methods worked fine. then, I followed the steps of the quick start tutorial of OW

  • No Audio with JMF

    I encoded some video using virtualdub. I haven't been able to find any audio settings that result in audio playing back properly. I've looking at the supported formats, and I've tried plenty of different settings. Does anyone have any information abo

  • HELP! I'm drowning in digital quicksands of archiving projects!

    I have been creating projects since March of this year and have completed 4 projects so far but I am continuing to keep them in the project library for this simple reason: not being able to decide how to archive them because of their huge sizes! I do

  • What are the AdditionalEssentials.pkg included in the Mountain Lion installation disk?

    I have done a clean install of Mountain Lion on my 13" MBP early 2011 and noticed on the install disk under Packages Folder there is an AdditionalEssentials.pkg andw wondered what are these additional essentials and wheather I should install it or no

  • Since update 10.6, iTunes doesn't recognize my iPhone 4 or iPad 2

    Hello, I just wanted to synchronize my iPhone 4 with iTunes. But iTunes does not show my iPhone 4. Neither my iPad 2 or an other device. I tried to sync from iPhone 4 preferences but it stops searching my Macbook without error. It just did nothing. L