Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: Whats wrong with this code?????

  1. #1
    Junior Member
    Join Date
    Sep 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Whats wrong with this code?????

    { //donor column
    FundTable model = getModel();
    String dFirstName = (String)model.getValueAt(rowIndex,0);
    String dLastName = (String)model.getValueAt(rowIndex,1);
    Boolean CharityChoice = (Boolean)model.getValueAt(rowIndex,3);
    if (Boolean.TRUE.equals())


  2. #2
    Member
    Join Date
    Jul 2013
    Location
    Mars
    Posts
    50
    My Mood
    Relaxed
    Thanks
    5
    Thanked 1 Time in 1 Post

    Default Re: Whats wrong with this code?????

    Welcome to the forums! Please read the info here: Announcements - What's Wrong With My Code?

    What are you trying to do with your code? you seem to be missing quite a bit.

  3. #3
    Junior Member
    Join Date
    Sep 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Whats wrong with this code?????

    just having trouble with FundTable here is all my code


    * Week4 assign
    * 9/16/13
    */



    package week4;

    import javax.swing.*;
    import javax.swing.event.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;


    public class FundraiserAp extends JFrame
    {
    /**
    *
    */
    private static final long serialVersionUID = 1L;

    /*
    * Building the list of Charities Panel
    * with Radio buttons so participant's can
    * choose which local charity to support.
    */
    private JPanel panel;//initiate JavaVille Panel

    private JLabel donorFirstName;
    private JLabel donorLastName;
    private JTextField dFirstName;
    private JTextField dLastName;

    private JLabel label;
    private JRadioButton JavaVilleBoysGirlsClub;
    private JRadioButton JavaBeans;
    private JRadioButton JavaTee;
    private JRadioButton CupOfJoe;
    private JRadioButton GrindOutCancer;
    private ButtonGroup CharityButtonGroup;

    private JLabel donationLabel;
    private JTextField donationField;
    private final int WINDOW_WIDTH = 1000;
    private final int WINDOW_HEIGHT = 900;


    public FundraiserAp()
    {
    super("Fundraiser application");
    setSize(WINDOW_WIDTH, WINDOW_HEIGHT);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    buildpanel();
    add(panel);
    pack();
    setVisible(true);
    }

    private void buildpanel()
    {
    donorFirstName = new JLabel ("Enter donors first name:");
    dFirstName = new JTextField (10);
    donorLastName = new JLabel ("Enter donors last name");
    dLastName = new JTextField (10);



    label = new JLabel ("Choose a Charity to Run for:");
    JavaVilleBoysGirlsClub = new JRadioButton ("JavaVille Boys and Girls Club", true);
    JavaBeans = new JRadioButton ("Java Beans for Premature Births");
    JavaTee = new JRadioButton ("Save the JavaTees");
    CupOfJoe = new JRadioButton ("Cup of Joe for Seniors");
    GrindOutCancer = new JRadioButton ("Grind Out Cancer");

    CharityButtonGroup = new ButtonGroup();
    CharityButtonGroup.add(JavaVilleBoysGirlsClub);
    CharityButtonGroup.add(JavaBeans);
    CharityButtonGroup.add(JavaTee);
    CharityButtonGroup.add(CupOfJoe);
    CharityButtonGroup.add(GrindOutCancer);



    donationLabel = new JLabel("Enter Donation Amount:");
    donationField = new JTextField(10);

    // ActionListener next, example
    JavaVilleBoysGirlsClub.addActionListener(new CharityButtonListener());
    JavaBeans.addActionListener(new CharityButtonListener());
    JavaTee.addActionListener(new CharityButtonListener());
    CupOfJoe.addActionListener(new CharityButtonListener());
    GrindOutCancer.addActionListener(new CharityButtonListener());


    panel = new JPanel(new GridLayout(6,1));//calling panel and layout of panel

    panel.add(donorFirstName);
    panel.add(dFirstName);
    panel.add(donorLastName);
    panel.add(dLastName);
    panel.add(label);
    panel.add(JavaVilleBoysGirlsClub);
    panel.add(JavaBeans);
    panel.add(JavaTee);
    panel.add(CupOfJoe);
    panel.add(GrindOutCancer);
    panel.add(donationLabel);
    panel.add(donationField);
    }//end of build panel

    private class CharityButtonListener implements ActionListener
    {
    public void actionPerformed (ActionEvent e)
    {
    String CharityChoice; //holds input

    JTable table = new JTable(new FundTable())
    {
    //Implement table cell tool tips.
    public String getToolTipText(MouseEvent e)
    {
    String tip = null;
    java.awt.Point p = e.getPoint();
    int rowIndex = rowAtPoint(p);
    int colIndex = columnAtPoint(p);
    int realColumnIndex = convertColumnIndexToModel(colIndex);

    if (realColumnIndex == 2) { //Sport column
    tip = "This fundraiser "
    + "Help many people: "
    + getValueAt(rowIndex, colIndex);

    } else if (realColumnIndex == 4)
    { //donor column
    FundTable model = getModel();
    String dFirstName = (String)model.getValueAt(rowIndex,0);
    String dLastName = (String)model.getValueAt(rowIndex,1);
    Boolean CharityChoice = (Boolean)model.getValueAt(rowIndex,3);
    if (Boolean.TRUE.equals())
    {
    tip = dFirstName + " " + dLastName
    + "Big donation";
    } else {
    tip = dFirstName + " " + dLastName
    + " small donation";
    }

    } else { //another column
    //You can omit this part if you know you don't
    //have any renderers that supply their own tool
    //tips.
    tip = super.getToolTipText(e);
    }
    return tip;
    }

    };

    }
    }

    public static void main(String[] args)
    {
    new FundraiserAp();
    }

    }
    //http://docs.oracle.com/javase/tutorial/uiswing/components/table.html

  4. #4
    Grand Poobah
    Join Date
    Mar 2011
    Posts
    1,512
    My Mood
    Grumpy
    Thanks
    0
    Thanked 165 Times in 156 Posts

    Default Re: Whats wrong with this code?????

    Post code between code tags ([ code ] before and [ /code ] after without the spaces.
    If your code is too long people won't read it. Post a SSCCE (google it).
    Ask a specific question. "My code doesn't work" is not a question nor is it specific.
    Improving the world one idiot at a time!

Similar Threads

  1. Whats wrong with my code?
    By mhphucld in forum What's Wrong With My Code?
    Replies: 1
    Last Post: May 26th, 2013, 08:50 PM
  2. help me with a code, whats wrong?
    By Heizzer10 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: October 17th, 2012, 10:09 AM
  3. Can someone see whats wrong with my code, please?
    By DJBENZ10 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: July 11th, 2012, 08:54 PM
  4. Whats wrong with my code??
    By mozza in forum What's Wrong With My Code?
    Replies: 1
    Last Post: May 14th, 2012, 10:37 AM
  5. Whats wrong with my code!!
    By nitwit3 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: July 22nd, 2011, 11:45 AM