Search Results

Search found 4279 results on 172 pages for 'crystal reports 8 5'.

Page 38/172 | < Previous Page | 34 35 36 37 38 39 40 41 42 43 44 45  | Next Page >

  • Specific query in Mysql

    - by Radhe
    I have two tables reports and holidays. reports: (username varchar(30),activity varchar(30),hours int(3),report_date date) holidays: (holiday_name varchar(30), holiday_date date) select * from reports gives +----------+-----------+---------+------------+ | username | activity | hours | date | +----------+-----------+---------+------------+ | prasoon | testing | 3 | 2009-01-01 | | prasoon | coding | 4 | 2009-01-03 | | prasoon | designing| 2 | 2009-01-04 | | prasoon | coding | 4 | 2009-01-06 | +----------+-----------+---------+------------+ select * from holidays gives +--------------+---------------+ | holiday_name | holiday_date | +--------------+---------------+ | Diwali | 2009-01-02 | | Holi | 2009-01-05 | +--------------+---------------+ Is there any way by which I can output the following? +-------------+-----------+---------+-------------------+ | date | activity | hours | holiday_name | +-------------+-----------+---------+-------------------+ | 2009-01-01 | testing | 3 | | | 2009-01-02 | | | Diwali | | 2009-01-03 | coding | 4 | | | 2009-01-04 | designing| 2 | | | 2009-01-05 | | | Holi | | 2009-01-06 | coding | 4 | | +-------------+-----------+---------+-------------------+

    Read the article

  • Constructor ambiguous quesiton

    - by Crystal
    I'm trying to create a simple date class, but I get an error on my main file that says, "call of overloaded Date() is ambiguous." I'm not sure why since I thought as long as I had different parameters for my constructor, I was ok. Here is my code: header file: #ifndef DATE_H #define DATE_H using std::string; class Date { public: static const int monthsPerYear = 12; // num of months in a yr Date(int = 1, int = 1, int = 1900); // default constructor Date(); // uses system time to create object void print() const; // print date in month/day/year format ~Date(); // provided to confirm destruction order string getMonth(int month) const; // gets month in text format private: int month; // 1 - 12 int day; // 1 - 31 int year; // any year int checkDay(int) const; }; #endif .cpp file #include <iostream> #include <iomanip> #include <string> #include <ctime> #include "Date.h" using namespace std; Date::Date() { time_t seconds = time(NULL); struct tm* t = localtime(&seconds); month = t->tm_mon; day = t->tm_mday; year = t->tm_year; } Date::Date(int mn, int dy, int yr) { if (mn > 0 && mn <= monthsPerYear) month = mn; else { month = 1; // invalid month set to 1 cout << "Invalid month (" << mn << ") set to 1.\n"; } year = yr; // could validate yr day = checkDay(dy); // validate the day // output Date object to show when its constructor is called cout << "Date object constructor for date "; print(); cout << endl; } void Date::print() const { string str; cout << month << '/' << day << '/' << year << '\n'; // new code for HW2 cout << setfill('0') << setw(3) << day; // prints in ddd cout << " " << year << '\n'; // yyyy format str = getMonth(month); // prints in month (full word), day, year cout << str << " " << day << ", " << year << '\n'; } and my main.cpp #include <iostream> #include "Date.h" using std::cout; int main() { Date date1(4, 30, 1980); date1.print(); cout << '\n'; Date date2; date2.print(); }

    Read the article

  • Unable to update the snapshot view in clearcase on linux

    - by crystal
    Hi I am trying to create a new snapshot view on my machine and i am using the following procedure: creating the view using ct mkview -snapshot -tag testview -vws /home/store/testview.vws /home/view/testview here the view gets created but fails to register which i register using the ct update on this /home/view/testview location tried to change the configspec using ct edcs & but got error "cleartool: Error: Cannot get view info for current view: not a ClearCase object." explicitly modifying the config_spec using vi editor, and the updating the view ends up creating a log...but no files are copied :( Can someone please direct me as to where i am going wrong?

    Read the article

  • Help with Hashmaps in Java

    - by Crystal
    I'm not sure how I use get() to get my information. Looking at my book, they pass the key to get(). I thought that get() returns the object associated with that key looking at the documentation. But I must be doing something wrong here.... Any thoughts? import java.util.*; public class OrganizeThis { /** Add a person to the organizer @param p A person object */ public void add(Person p) { staff.put(p, p.getEmail()); System.out.println("Person " + p + "added"); } /** * Find the person stored in the organizer with the email address. * Note, each person will have a unique email address. * * @param email The person email address you are looking for. * */ public Person findByEmail(String email) { Person aPerson = staff.get(email); return aPerson; } private Map<Person, String> staff = new HashMap<Person, String>(); public static void main(String[] args) { OrganizeThis testObj = new OrganizeThis(); Person person1 = new Person("J", "W", "111-222-3333", "[email protected]"); testObj.add(person1); System.out.println(testObj.findByEmail("[email protected]")); } }

    Read the article

  • Need help with a SQL CTE Query

    - by Chuck
    I have a table that I need to get some specific data from for a view. Here's the base table structure with some sample data: | UserID | ReportsToUserID | Org ID | ------------------------------------- | 1 | NULL | 1 | ------------------------------------- | 2 | 1 | 1 | ------------------------------------- | 3 | 2 | 1 | ------------------------------------- | 4 | 3 | 1 | ------------------------------------- The users will be entering reports and users can see the reports of users who report to them and any users who report to those users. Users who report to no one can see everything in their organization Given my sample data above, user 1 can see the reports of 2, 3, & 4; user 2 can see the reports of 3 & 4; and user 3 can see the reports of 4. For the view, I'd like to have the data returned as follows: | UserID | CanSeeUserID | OrgID | -------------------------------------------- | 1 | 2 | 1 | -------------------------------------------- | 1 | 3 | 1 | -------------------------------------------- | 1 | 4 | 1 | -------------------------------------------- | 2 | 3 | 1 | -------------------------------------------- etc... Below is my current code, any help is greatly appreciated. WITH CTEUsers (UserID, CanSeeUserID, OrgID) AS ( SELECT e.ID, e.ReportsToUserID, e.OrgID FROM Users e WITH(NOLOCK) WHERE COALESCE(ReportsToUserID,0) = 0 --ReportsToUserID can be NULL or 0 UNION ALL SELECT e.ReportsToUserID, e.ID,e.OrgID FROM Users e WITH(NOLOCK) JOIN CTEUsers c ON e.ID = c.UserID ) SELECT * FROM CTEUsers

    Read the article

  • Report generation in PHP (formats required pdf,xls,doc,csv)

    - by Ish Kumar
    I need to generate reports in my PHP website (in zend framework) Formats required: PDF (with tables & images) // presently using Zend_Pdf XLS (with tables & images) DOC (with tables & images) CSV (only tables) Please recommend robust and fast solution for generating reports in PHP. Platform: Zend Framework on LAMP I know there are some tricky solutions for creating such reports, i wonder is there any open source report generation utility that can be used with LAMP environment

    Read the article

  • Calculating volume for sphere in c++

    - by Crystal
    This is probably an easy one, but is the right way to calculate volume for a sphere in c++. My getArea() seems to be right, but when I call getVolume() it doesn't output the right amount. With a sphere of radius = 1, it gives me the answer of pi, which is incorrect: double Sphere::getArea() const { return 4 * Shape::pi * pow(getZ(), 2); } double Sphere::getVolume() const { return (4 / 3) * Shape::pi * pow(getZ(), 3); }

    Read the article

  • Help with method logic in Java, hw

    - by Crystal
    I have a Loan class that in its printPayment method, it prints the amortization table of a loan for a hw assignment. We are also to implement a print first payment method, and a print last payment method. Since my calculation is done in the printPayment method, I didn't know how I could get the value in the first or last iteration of the loop and print that amount out. One way I can think of is to write a new method that might return that value, but I wasn't sure if there was a better way. Here is my code: public abstract class Loan { public void setClient(Person client) { this.client = client; } public Person getClient() { return client; } public void setLoanId() { loanId = nextId; nextId++; } public int getLoanId() { return loanId; } public void setInterestRate(double interestRate) { this.interestRate = interestRate; } public double getInterestRate() { return interestRate; } public void setLoanLength(int loanLength) { this.loanLength = loanLength; } public int getLoanLength() { return loanLength; } public void setLoanAmount(double loanAmount) { this.loanAmount = loanAmount; } public double getLoanAmount() { return loanAmount; } public void printPayments() { double monthlyInterest; double monthlyPrincipalPaid; double newPrincipal; int paymentNumber = 1; double monthlyInterestRate = interestRate / 1200; double monthlyPayment = loanAmount * (monthlyInterestRate) / (1 - Math.pow((1 + monthlyInterestRate),( -1 * loanLength))); System.out.println("Payment Number | Interest | Principal | Loan Balance"); // amortization table while (loanAmount >= 0) { monthlyInterest = loanAmount * monthlyInterestRate; monthlyPrincipalPaid = monthlyPayment - monthlyInterest; newPrincipal = loanAmount - monthlyPrincipalPaid; loanAmount = newPrincipal; System.out.printf("%d, %.2f, %.2f, %.2f", paymentNumber++, monthlyInterest, monthlyPrincipalPaid, loanAmount); } } /* //method to print first payment public double getFirstPayment() { } method to print last payment public double getLastPayment() { }*/ private Person client; private int loanId; private double interestRate; private int loanLength; private double loanAmount; private static int nextId = 1; } Thanks!

    Read the article

  • Calling delegate methods and calling selectors

    - by Crystal
    I'm new to the concept of delegates and selectors when used with notifications. So my first question is, 1) Let's say you have a button that has a delegate that implements some doWork method. If you want the same functionality that's in the method, is it 'ok' to just call that method? I didn't know if that was considered good coding practices and/or if you should do that, or do something different in getting that type of functionality. Like if that is ok architecture? 2) Similarly, with NSNotificationCenter, I see some code that posts a notification. Then there's a HandleSegmentedControl:(NSNotification *)notification method. If I want to manually have that functionality, but without pressing the segment control, is it 'ok' to just take that functionality out of that method and put it in a new method so it would look like this: Original: - (void)HandleSegmentedControl:(NSNotification *)notification { NSDictionary *dict = [userInfo notification]; // do stuff with the dictionary } New: - (void)HandleSegmentedControl:(NSNotification *)notification { NSDictionary *dict = [userInfo notification]; [self newMethod:dict]; } - (void)newMethod:(NSDictionary *)dict { // do stuff with the dictionary } - (void)myOtherMethodThatNeedsTheSameFunctionality { NSDictionary *dict = // create some dictionary [self newMethod:dict]; } Sorry if these are basic questions. I'm not sure what the best practices are for things like this and wanted to start the right way. Thanks.

    Read the article

  • Query in sql involving joins of two table

    - by Satish
    I have two tables reports and holidays. reports: (username varchar(30),activity varchar(30),hours int(3),report_date date) holidays: (holiday_name varchar(30), holiday_date date) select * from reports gives +----------+-----------+---------+------------+ | username | activity | hours | date | +----------+-----------+---------+------------+ | prasoon | testing | 3 | 2009-01-01 | | prasoon | coding | 4 | 2009-01-03 | | prasoon | coding | 4 | 2009-01-06 | | prasoon | coding | 4 | 2009-01-10 | +----------+-----------+---------+------------+ select * from holidays gives +--------------+---------------+ | holiday_name | holiday_date | +--------------+---------------+ | Diwali | 2009-01-02 | | Holi | 2009-01-05 | +--------------+---------------+ Is there any way by which I can output the following? +-------------+-----------+---------+-------------------+ | date | activity | hours | holiday_name | +-------------+-----------+---------+-------------------+ | 2009-01-01 | testing | 3 | | | 2009-01-02 | | | Diwali | | 2009-01-03 | coding | 4 | | | 2009-01-04 | Absent | Absent | | | 2009-01-05 | | | Holi | | 2009-01-06 | coding | 4 | | | 2009-01-07 | Absent | Absent | | | 2009-01-08 | Absent | Absent | | | 2009-01-09 | Absent | Absent | | | 2009-01-10 | coding | 4 | | +-------------+-----------+---------+-------------------+ In other words I want to fill the activity and hours columns with "Absent" on the dates which are neither in table reports nor in table holidays. How can I write a specific query for it. The query should give the output between two specific dates.

    Read the article

  • Render asp.net repeater as-and-when chunks of html is ready (streaming)

    - by sash
    The problem is to render huge reports. Basically we have lots of data that get rendered in html reports (mostly using repeater or gridview). As it so happens, the data started out small and now we have tons of it. There are lots of such reports already built so total rewrite is not an option. Heck, the business is not even letting us page the data. Now server memory is shooting up each time we try to render some reports. So the question is - is there some way we can bind data to repeater and have it stream html to browser as and when chunks are ready? That way we hope to not bring all that data into app server at once. I'm thinking we'll use a datareader or something to get parts of data and render it to browser. Any pointers, links, ideas?

    Read the article

  • Enumeration classes in Java

    - by Crystal
    I have one class that declares an enumeration type as: public enum HOME_LOAN_TERMS {FIFTEEN_YEAR, THIRTY_YEAR}; Is this type usable in another class? I'm basically trying to complete a homework assignment where we have two types of loans, and one loanManager class. When I try to use the HOME_LOAN_TERMS.THIRTY_YEAR in my loanManager class that does not extend or implement the loan class, I get an error saying it 'cannot find symbol HOME_LOAN_TERMS.' So I did not know if my loanManager class needed to implement the two different loan classes. Thanks.

    Read the article

  • SQL query for an access database needed

    - by masfenix
    Hey guys, first off all sorry, i can't login using my yahoo provider. anyways I have this problem. Let me explain it to you, and then I'll show you a picture. I have a access db table. It has 'report id', 'recpient id', and 'recipient name' and 'report req'. What the table "means" is that do the user using that report still require it or can we decommission it. Here is how the data looks like (blocked out company userids and usernames): *check the link below, I cant post pictures cuz yahoo open id provider isnt working. So basically I need to have 3 select queries: 1) Select all the reports where for each report, ALL the users have said no to 'reportreq'. In plain English, i want a listing of all the reports that we have to decommission because no user wants it. 2) Select all the reports where the report is required, and the batchprintcopy is more then 0. This way we can see which report needs to be printed and save paper instead of printing all the reports. 3)A listing of all the reports where the reportreq field is empty. I think i can figure this one out myself. This is using Access/VBA and the data will be exported to an excel spreadsheet. I just a simple query if it exists, OR an alogorithm to do it quickly. I just tried making a "matrix" and it took about 2 hours to populate. https://docs.google.com/uc?id=0B2EMqbpeBpQkMTIyMzA5ZjMtMGQ3Zi00NzRmLWEyMDAtODcxYWM0ZTFmMDFk&hl=en_US

    Read the article

  • Getter/Setter (composition, Java, HW)

    - by Crystal
    I have one class called Person that basically looks like: public class Person { String firstName; String lastName; String telephone; String email; public Person() { firstName = ""; lastName = ""; telephone = ""; email = ""; } public Person(String firstName, String lastName, String telephone, String email) { this.firstName = firstName; this.lastName = lastName; this.telephone = telephone; this.email = email; } public String getFirstName() { return firstName; } public void setFirstName(String firstName) { this.firstName = firstName; } .... Using that class, I setup an abstract class called Loan that looks like: public abstract class Loan { public void setClient(Person client) { this.client = client; } public Person getClient() { return client; } public void setLoanId(int nextId) { loanId = nextId; nextId++; } public int getLoanId() { return loanId; } public void setInterestRate(double interestRate) { this.interestRate = interestRate; } public double getInterestRate() { return interestRate; } public void setLoanLength(int loanLength) { this.loanLength = loanLength; } public int getLoanLength() { return loanLength; } public void setLoanAmount(double loanAmount) { this.loanAmount = loanAmount; } public double getLoanAmount(double loanAmount) { return loanAmount; } private Person client; private int loanId; private double interestRate; private int loanLength; private double loanAmount; private static int nextId = 1; } I have to extend the Loan class with CarLoan and it looks like: public class CarLoan extends Loan { public CarLoan(Person client, double vehiclePrice, double downPayment, double salesTax, double interestRate, CAR_LOAN_TERMS length) { super.setClient(client); super.setInterestRate(interestRate); this.client = client; this.vehiclePrice = vehiclePrice; this.downPayment = downPayment; this.salesTax = salesTax; this.length = length; } public void setVehiclePrice(double vehiclePrice) { this.vehiclePrice = vehiclePrice; } public double getVehiclePrice() { return vehiclePrice; } public void setDownPayment(double downPayment) { this.downPayment = downPayment; } public double getDownPayment() { return downPayment; } public void setSalesTax(double salesTax) { this.salesTax = salesTax; } public double getSalesTax() { return salesTax; } public String toString() { return getClass().getName() + "[vehiclePrice = " + vehiclePrice + '\n' + "downPayment = " + downPayment + '\n' + "salesTax = " + salesTax + "]"; } public enum CAR_LOAN_TERMS {TWO_YEAR, THREE_YEAR, SIX_YEAR}; private double vehiclePrice; private double downPayment; private double salesTax; Few questions. (a) Is what I did in the Loan class to setClient correct given what I have in the Person class? (e.g.this.client = client) (b) Can I call super twice in a method? I have to set two attributes from the Loan class from the constructor in the CarLoan class and I thought that would be a way to do it. (c) Do you have to set attributes for enumeration types differently in a constructor or getter/setter methods? I get an error for (this.length = length) in my CarLoan class and I was unsure of how enumeration values should be set. Thanks!

    Read the article

  • SSRS mysterious extra pages

    I have two reports that are setup with the same page dimensions- A4 portrait, with page margins of 1cm. When I run the reports seperately and print them they both come out as expected: fitting into the width constraint of the page. However, when I include one report as a subreport in the other and then run and print the "master" report I start to experience problems. Even though both reports appear I get extra blank pages appearing every other page in the output. I'm sure I'm missing a simple trick - probably with the page sizes of the two reports but I can't figure it out - any pointers? I don't mind changing the setup of the subreport as it will never be run as a seperate eport in the wild, I only included that step to prove that it did indeed fit within the page!

    Read the article

  • Unresolved external symbol error in c++

    - by Crystal
    I am trying to do a simple hw problem involving namespace, static data members and functions. I am getting an unresolved external symbol error Error 1 error LNK2001: unresolved external symbol "private: static double JWong::SavingsAccount::annualInterestRate" (?annualInterestRate@SavingsAccount@JWong@@0NA) SavingsAccount.obj SavingsAccount And I don't see why I am getting this error. Maybe I don't know something about static variables compared to regular data members that is causing this error. Here is my code: SavingsAccount.h file #ifndef JWONG_SAVINGSACCOUNT_H #define JWONG_SAVINGSACCOUNT_H namespace JWong { class SavingsAccount { public: // default constructor SavingsAccount(); // constructor SavingsAccount(double savingsBalance); double getSavingsBalance(); void setSavingsBalance(double savingsBalance); double calculateMonthlyInterest(); // static functions static void modifyInterestRate(double newInterestRate); static double getAnnualInterestRest(); private: double savingsBalance; // static members static double annualInterestRate; }; } #endif SavingsAccount.cpp file #include <iostream> #include "SavingsAccount.h" // default constructor, set savingsBalance to 0 JWong::SavingsAccount::SavingsAccount() : savingsBalance(0) {} // constructor JWong::SavingsAccount::SavingsAccount(double savingsBalance) : savingsBalance(savingsBalance) {} double JWong::SavingsAccount::getSavingsBalance() { return savingsBalance; } void JWong::SavingsAccount::setSavingsBalance(double savingsBalance) { this->savingsBalance = savingsBalance; } // returns monthly interest and sets savingsBalance to new amount double JWong::SavingsAccount::calculateMonthlyInterest() { double monthlyInterest = savingsBalance * SavingsAccount::annualInterestRate / 12; setSavingsBalance(savingsBalance + monthlyInterest); return monthlyInterest; } void JWong::SavingsAccount::modifyInterestRate(double newInterestRate) { SavingsAccount::annualInterestRate = newInterestRate; } double JWong::SavingsAccount::getAnnualInterestRest() { return SavingsAccount::annualInterestRate; }

    Read the article

  • static const double in c++

    - by Crystal
    Is this the proper way to use a static const variable? In my top level class (Shape) #ifndef SHAPE_H #define SHAPE_H class Shape { public: static const double pi; private: double originX; double originY; }; const double Shape::pi = 3.14159265; #endif And then later in a class that extends Shape, I use Shape::pi. I get a linker error. I moved the const double Shape::pi = 3.14... to the Shape.cpp file and my program then compiles. Why does that happen? thanks.

    Read the article

  • Creating ActionEvent object for CustomButton in Java

    - by Crystal
    For a hw assignment, we were supposed to create a custom button to get familiar with swing and responding to events. We were also to make this button an event source which confuses me. I have an ArrayList to keep track of listeners that would register to listen to my CustomButton. What I am getting confused on is how to notify the listeners. My teacher hinted at having a notify and overriding actionPerformed which I tried doing, but then I wasn't sure how to create an ActionEvent object looking at the constructor documentation. The source, id, string all confuses me. Any help would be appreciated. Thanks! code: import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.util.List; import java.util.ArrayList; public class CustomButton { public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void run() { CustomButtonFrame frame = new CustomButtonFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } }); } public void addActionListener(ActionListener al) { listenerList.add(al); } public void removeActionListener(ActionListener al) { listenerList.remove(al); } public void actionPerformed(ActionEvent e) { System.out.println("Button Clicked!"); } private void notifyListeners() { ActionEvent event = new ActionEvent(CONFUSED HERE!!!!; for (ActionListener action : listenerList) { action.actionPerfomed(event); } } List<ActionListener> listenerList = new ArrayList<ActionListener>(); } class CustomButtonFrame extends JFrame { // constructor for CustomButtonFrame public CustomButtonFrame() { setTitle("Custom Button"); CustomButtonSetup buttonSetup = new CustomButtonSetup(); this.add(buttonSetup); this.pack(); } } class CustomButtonSetup extends JComponent { public CustomButtonSetup() { ButtonAction buttonClicked = new ButtonAction(); this.addMouseListener(buttonClicked); } // because frame includes borders and insets, use this method public Dimension getPreferredSize() { return new Dimension(200, 200); } public void paintComponent(Graphics g) { Graphics2D g2 = (Graphics2D) g; // first triangle coords int x[] = new int[TRIANGLE_SIDES]; int y[] = new int[TRIANGLE_SIDES]; x[0] = 0; y[0] = 0; x[1] = 200; y[1] = 0; x[2] = 0; y[2] = 200; Polygon firstTriangle = new Polygon(x, y, TRIANGLE_SIDES); // second triangle coords x[0] = 0; y[0] = 200; x[1] = 200; y[1] = 200; x[2] = 200; y[2] = 0; Polygon secondTriangle = new Polygon(x, y, TRIANGLE_SIDES); g2.drawPolygon(firstTriangle); g2.setColor(firstColor); g2.fillPolygon(firstTriangle); g2.drawPolygon(secondTriangle); g2.setColor(secondColor); g2.fillPolygon(secondTriangle); // draw rectangle 10 pixels off border int s1[] = new int[RECT_SIDES]; int s2[] = new int[RECT_SIDES]; s1[0] = 5; s2[0] = 5; s1[1] = 195; s2[1] = 5; s1[2] = 195; s2[2] = 195; s1[3] = 5; s2[3] = 195; Polygon rectangle = new Polygon(s1, s2, RECT_SIDES); g2.drawPolygon(rectangle); g2.setColor(thirdColor); g2.fillPolygon(rectangle); } private class ButtonAction implements MouseListener { public void mousePressed(MouseEvent e) { System.out.println("Click!"); firstColor = Color.GRAY; secondColor = Color.WHITE; repaint(); } public void mouseReleased(MouseEvent e) { System.out.println("Released!"); firstColor = Color.WHITE; secondColor = Color.GRAY; repaint(); } public void mouseEntered(MouseEvent e) {} public void mouseExited(MouseEvent e) {} public void mouseClicked(MouseEvent e) {} } public static final int TRIANGLE_SIDES = 3; public static final int RECT_SIDES = 4; private Color firstColor = Color.WHITE; private Color secondColor = Color.DARK_GRAY; private Color thirdColor = Color.LIGHT_GRAY; }

    Read the article

  • Passing ActionListeners in Java, pack()

    - by Crystal
    Two questions. First question is I'm trying to create a simple form that when you press a button, it adds a Person object to the ArrayList. However, since I am not used to GUIs, I tried creating one and am first just trying to get the user input from the JTextField, create an ActionListener object of the appropriate type, so once that works, then I can pass in all the JTextField inputs to create my Person object. Unfortunately, I am not getting any data when I type in something to the firstName JTextField and was wondering if someone could look at my code below. import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.util.List; import java.util.ArrayList; public class AddressBook { public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void run() { AddressBookFrame frame = new AddressBookFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JMenuBar menuBar = new JMenuBar(); frame.setJMenuBar(menuBar); JMenu fileMenu = new JMenu("File"); JMenuItem openItem = new JMenuItem("Open"); JMenuItem saveItem = new JMenuItem("Save"); JMenuItem saveAsItem = new JMenuItem("Save As"); JMenuItem printItem = new JMenuItem("Print"); JMenuItem exitItem = new JMenuItem("Exit"); fileMenu.add(openItem); fileMenu.add(saveItem); fileMenu.add(saveAsItem); fileMenu.add(printItem); fileMenu.add(exitItem); menuBar.add(fileMenu); JMenu editMenu = new JMenu("Edit"); JMenuItem newItem = new JMenuItem("New"); JMenuItem editItem = new JMenuItem("Edit"); JMenuItem deleteItem = new JMenuItem("Delete"); JMenuItem findItem = new JMenuItem("Find"); JMenuItem firstItem = new JMenuItem("First"); JMenuItem previousItem = new JMenuItem("Previous"); JMenuItem nextItem = new JMenuItem("Next"); JMenuItem lastItem = new JMenuItem("Last"); editMenu.add(newItem); editMenu.add(editItem); editMenu.add(deleteItem); editMenu.add(findItem); editMenu.add(firstItem); editMenu.add(previousItem); editMenu.add(nextItem); editMenu.add(lastItem); menuBar.add(editMenu); JMenu helpMenu = new JMenu("Help"); JMenuItem documentationItem = new JMenuItem("Documentation"); JMenuItem aboutItem = new JMenuItem("About"); helpMenu.add(documentationItem); helpMenu.add(aboutItem); menuBar.add(helpMenu); frame.setVisible(true); } }); } } class AddressBookFrame extends JFrame { public AddressBookFrame() { setLayout(new BorderLayout()); setTitle("Address Book"); setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT); AddressBookToolBar toolBar = new AddressBookToolBar(); add(toolBar, BorderLayout.NORTH); AddressBookStatusBar aStatusBar = new AddressBookStatusBar("5"); add(aStatusBar, BorderLayout.SOUTH); AddressBookForm form = new AddressBookForm(); add(form, BorderLayout.CENTER); } public static final int DEFAULT_WIDTH = 500; public static final int DEFAULT_HEIGHT = 500; } /* Create toolbar buttons and add buttons to toolbar */ class AddressBookToolBar extends JPanel { public AddressBookToolBar() { setLayout(new FlowLayout(FlowLayout.LEFT)); JToolBar bar = new JToolBar(); JButton newButton = new JButton("New"); JButton editButton = new JButton("Edit"); JButton deleteButton = new JButton("Delete"); JButton findButton = new JButton("Find"); JButton firstButton = new JButton("First"); JButton previousButton = new JButton("Previous"); JButton nextButton = new JButton("Next"); JButton lastButton = new JButton("Last"); bar.add(newButton); bar.add(editButton); bar.add(deleteButton); bar.add(findButton); bar.add(firstButton); bar.add(previousButton); bar.add(nextButton); bar.add(lastButton); add(bar); } } /* Creates the status bar string */ class AddressBookStatusBar extends JPanel { public AddressBookStatusBar(String statusBarString) { setLayout(new FlowLayout(FlowLayout.LEFT)); this.statusBarString = new JLabel("Total number of people: " + statusBarString); add(this.statusBarString); } private JLabel statusBarString; private int totalContacts; } class AddressBookForm extends JPanel { public AddressBookForm() { this.setLayout(new GridLayout(2, 1)); JPanel formPanel = new JPanel(); formPanel.setLayout(new GridLayout(4, 2)); JTextField firstName = new JTextField(20); JTextField lastName = new JTextField(20); JTextField telephone = new JTextField(20); JTextField email = new JTextField(20); JLabel firstNameLabel = new JLabel("First Name: ", JLabel.LEFT); formPanel.add(firstNameLabel); formPanel.add(firstName); JLabel lastNameLabel = new JLabel("Last Name: ", JLabel.LEFT); formPanel.add(lastNameLabel); formPanel.add(lastName); JLabel telephoneLabel = new JLabel("Telephone: ", JLabel.LEFT); formPanel.add(telephoneLabel); formPanel.add(telephone); JLabel emailLabel = new JLabel("Email: ", JLabel.LEFT); formPanel.add(emailLabel); formPanel.add(email); add(formPanel); JPanel buttonPanel = new JPanel(); JButton insertButton = new JButton("Insert"); JButton displayButton = new JButton("Display"); // create button actions AddressBookManager insertAction = new AddressBookManager(firstName.getText()); insertButton.addActionListener(insertAction); buttonPanel.add(insertButton); buttonPanel.add(displayButton); add(buttonPanel); } private List<Person> addressList = new ArrayList<Person>(); private class AddressBookManager implements ActionListener { public AddressBookManager(String text) { // addressList.add( setName(text); System.out.println("Test" + text); } public void actionPerformed(ActionEvent e) { System.out.println("Hello" + name); } public void setName(String name) { this.name = name; } private String name; } } Second question is, how do I make my form not take up the whole center space. I don't like the stretch look and was hoping the JTextFields could be just one line long, not a big box. Same thing with the buttons. Any thoughts? Thanks.

    Read the article

  • Getter/Setter from separate class file in Java

    - by Crystal
    I'm new to Java and for a HW assignment, we had to create a Person class that has a constructor, getter/setter for the attributes of firstName, lastName, phone. That is in a separate file from an old HW assignment (Person.java). Now we have to use that Person class in our new HW assignment (LoanApplication.java). So if one of the attributes is private Person client do I need to create getter/setters or a constructor again? Otherwise, how does each LoanApplicaiton instance know which Person attribute it is to go with? How does the JVM know that it can use the Person.class even though my LoanApplicaiton.class does not extend Person.class? Thanks.

    Read the article

  • Friends, templates, overloading <<

    - by Crystal
    I'm trying to use friend functions to overload << and templates to get familiar with templates. I do not know what these compile errors are: Point.cpp:11: error: shadows template parm 'class T' Point.cpp:12: error: declaration of 'const Point<T>& T' for this file #include "Point.h" template <class T> Point<T>::Point() : xCoordinate(0), yCoordinate(0) {} template <class T> Point<T>::Point(T xCoordinate, T yCoordinate) : xCoordinate(xCoordinate), yCoordinate(yCoordinate) {} template <class T> std::ostream &operator<<(std::ostream &out, const Point<T> &T) { std::cout << "(" << T.xCoordinate << ", " << T.yCoordinate << ")"; return out; } My header looks like: #ifndef POINT_H #define POINT_H #include <iostream> template <class T> class Point { public: Point(); Point(T xCoordinate, T yCoordinate); friend std::ostream &operator<<(std::ostream &out, const Point<T> &T); private: T xCoordinate; T yCoordinate; }; #endif My header also gives the warning: Point.h:12: warning: friend declaration 'std::ostream& operator<<(std::ostream&, const Point<T>&)' declares a non-template function Which I was also unsure why. Any thoughts? Thanks.

    Read the article

  • Vector iterators in for loops, return statements, warning, c++

    - by Crystal
    Had 3 questions regarding a hw assignment for C++. The goal was to create a simple palindrome method. Here is my template for that: #ifndef PALINDROME_H #define PALINDROME_H #include <vector> #include <iostream> #include <cmath> template <class T> static bool palindrome(const std::vector<T> &input) { std::vector<T>::const_iterator it = input.begin(); std::vector<T>::const_reverse_iterator rit = input.rbegin(); for (int i = 0; i < input.size()/2; i++, it++, rit++) { if (!(*it == *rit)) { return false; } } return true; } template <class T> static void showVector(const std::vector<T> &input) { for (std::vector<T>::const_iterator it = input.begin(); it != input.end(); it++) { std::cout << *it << " "; } } #endif Regarding the above code, can you have more than one iterator declared in the first part of the for loop? I tried defining both the "it" and "rit" in the palindrome() method, and I kept on getting an error about needing a "," before rit. But when I cut and paste outside the for loop, no errors from the compiler. (I'm using VS 2008). Second question, I pretty much just brain farted on this one. But is the way I have my return statements in the palindrome() method ok? In my head, I think it works like, once the *it and *rit do not equal each other, then the function returns false, and the method exits at this point. Otherwise if it goes all the way through the for loop, then it returns true at the end. I totally brain farted on how return statements work in if blocks and I tried looking up a good example in my book and I couldn't find one. Finally, I get this warnings: \palindrome.h(14) : warning C4018: '<' : signed/unsigned mismatch Now is that because I run my for loop until (i < input.size()/2) and the compiler is telling me that input can be negative? Thanks!

    Read the article

  • Invalid table view update with insertRowsAtIndexPaths:

    - by Crystal
    I'm having trouble with insertRowsAtIndexPaths:. I'm not quite sure how it works. I watched the WWDC 2010 video on it, but I'm still getting an error. I thought I was supposed to update the model, then wrap the insertRowsAtIndexPaths: in the tableView beginUpdates and endUpdates calls. What I have is this: self.customTableArray = (NSMutableArray *)sortedArray; [_customTableView beginUpdates]; [tempUnsortedArray enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { [sortedArray enumerateObjectsUsingBlock:^(id sortedObj, NSUInteger sortedIdx, BOOL *sortedStop) { if ([obj isEqualToString:sortedObj]) { NSIndexPath *newRow = [NSIndexPath indexPathForRow:sortedIdx inSection:0]; [_customTableView insertRowsAtIndexPaths:[NSArray arrayWithObject:newRow] withRowAnimation:UITableViewRowAnimationAutomatic]; *sortedStop = YES; } }]; }]; [_customTableView endUpdates]; customTableArray is my model array. sortedArray is just the sorted version of that array. When I run this code when I hit my plus button to add a new row, I get this error: Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid update: invalid number of rows in section 0. The number of rows contained in an existing section after the update (2) must be equal to the number of rows contained in that section before the update (1), plus or minus the number of rows inserted or deleted from that section (2 inserted, 0 deleted) and plus or minus the number of rows moved into or out of that section (0 moved in, 0 moved out).' I'm not sure what I'm doing wrong. Thoughts? Thanks.

    Read the article

  • Ambiguous constructor call

    - by Crystal
    I'm trying to create a simple date class, but I get an error on my main file that says, "call of overloaded Date() is ambiguous." I'm not sure why since I thought as long as I had different parameters for my constructor, I was ok. Here is my code: header file: #ifndef DATE_H #define DATE_H using std::string; class Date { public: static const int monthsPerYear = 12; // num of months in a yr Date(int = 1, int = 1, int = 1900); // default constructor Date(); // uses system time to create object void print() const; // print date in month/day/year format ~Date(); // provided to confirm destruction order string getMonth(int month) const; // gets month in text format private: int month; // 1 - 12 int day; // 1 - 31 int year; // any year int checkDay(int) const; }; #endif .cpp file #include <iostream> #include <iomanip> #include <string> #include <ctime> #include "Date.h" using namespace std; Date::Date() { time_t seconds = time(NULL); struct tm* t = localtime(&seconds); month = t->tm_mon; day = t->tm_mday; year = t->tm_year; } Date::Date(int mn, int dy, int yr) { if (mn > 0 && mn <= monthsPerYear) month = mn; else { month = 1; // invalid month set to 1 cout << "Invalid month (" << mn << ") set to 1.\n"; } year = yr; // could validate yr day = checkDay(dy); // validate the day // output Date object to show when its constructor is called cout << "Date object constructor for date "; print(); cout << endl; } void Date::print() const { string str; cout << month << '/' << day << '/' << year << '\n'; // new code for HW2 cout << setfill('0') << setw(3) << day; // prints in ddd cout << " " << year << '\n'; // yyyy format str = getMonth(month); // prints in month (full word), day, year cout << str << " " << day << ", " << year << '\n'; } and my main.cpp #include <iostream> #include "Date.h" using std::cout; int main() { Date date1(4, 30, 1980); date1.print(); cout << '\n'; Date date2; date2.print(); }

    Read the article

< Previous Page | 34 35 36 37 38 39 40 41 42 43 44 45  | Next Page >