Trouble in Modifying calculateMinorAxisRequirements() method of BoxView

Hi there,
I have written a custom View, called TreeView that extends BoxView. Basically, my TreeView lays out all its children on y-axis (so it calls BoxView(element,View.Y_AXIS) in constructor), and displays all its children (except the first and the last child) at an offset(determined by a variable INDENT) on the x-axis.
To achieve this, I have over-ridden layoutMinorAxis(int targetSpan, int axis, int[] offsets, int[] spans) method and calculateMinorAxisRequirements(int axis, SizeRequirements r) method in TreeView. Everything works fine, except when I want to use ParagraphView inside TreeView. When I use ParagraphView for all the text content in TreeView (that is, when ParagraphView is a child of TreeView), the text is not wrapped at the right place. As a result, some of the text is clipped at the right side.
Bsically, the text IS wrapped, but not at the right place. So, I have a paragraph with a bunch of lines, but each line has some words clipped/missing at the right end.
I figured out that it has to do with the amount of indentation I use for each child. So if the variable INDENT is 0 (when TreeView is essentially the same as BoxView(element,View.Y_AXIS)) , there is no clipping.
I tried over-ridding getPrefferedSpan(int axis), getMinimumSpan(int axis) and getMaximumSpan(int axis) along with layoutMinorAxis(int targetSpan, int axis, int[] offsets, int[] spans) and calculateMinorAxisRequirements(int axis, SizeRequirements r)
But no luck so far.
Can anyone please please help me with this? What am I doing wrong?
I have been struggling with this since a long time. Please please help me!
Here is the code of TreeView:
<code>
class TreeView extends BoxView
     public TreeView(Element elem)
super(elem, View.Y_AXIS);
public float getAlignment(int axis)
if (axis == View.X_AXIS)
return 0.0f;
return 0.0f;
protected void layoutMinorAxis(int targetSpan, int axis, int[] offsets, int[] spans)
baselineLayout(targetSpan, axis, offsets, spans);
     int n = getViewCount();
     for(int i = 1; i < n-1 ; i++) //leave out the leaf views.
{     offsets[i] += INDENT;
     //spans[i] += INDENT;
/* protected SizeRequirements calculateMinorAxisRequirements(int axis, SizeRequirements r)
     SizeRequirements s = super.calculateMinorAxisRequirements(axis,r);
     if(axis == View.X_AXIS)
     s.minimum += INDENT;
     //s.maximum += INDENT;
     s.preferred += INDENT;
          if(r != null)
               r.minimum += INDENT;
               //s.maximum += INDENT;
               r.preferred += INDENT;
     return s;
     public float getMinimumSpan(int axis)
          float value = 0;
          if(axis == View.X_AXIS)
               value = super.getMinimumSpan(axis);
               value += INDENT;
          else
               value = super.getMinimumSpan(axis);
          return value;
     public float getPreferredSpan(int axis)
          float value = 0;
          if(axis == View.X_AXIS)
               value = super.getPreferredSpan(axis);
               value += INDENT;
          else
               value = super.getPreferredSpan(axis);
          return value;
private static final short INDENT = 20;
</code>
I have commented calculateMinorAxisRequirements() because, I found out that internally it calls getXXXSpan() method. Even if I uncomment it,the result is the same: the text is clipped.
Please please help!
thanks,
Swati

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
// We only support single touches, so anyObject retrieves just that touch from touches
UITouch *touch = [touches anyObject];
// Only move the placard view if the touch was in the placard view
if ([touch view] != placardView) {
// In case of a double tap outside the placard view, update the placard's display string
if ([touch tapCount] == 2) {
[placardView setupNextDisplayString];
return;
// Animate the first touch
CGPoint touchPoint = [touch locationInView:self];
[self animateFirstTouchAtPoint:touchPoint];
Unless the first touch is within the placard this line does not get executed:
[self animateFirstTouchAtPoint:touchPoint];
This method call is required if the 'return to center' animation is to succeed.
You can demonstrate this my first moving starting outside the placard and lifting, the placard does not center. Now just touch the placard and lift, it returns to center.

Similar Messages

  • How to Modify Smartform Methods in CRM 5.0

    Hi,
       I have to modify the CRM Sales Order Smartform which requires adding new fields to the existing layout,for which I will have to modify the Method .Kindly help me and provide me with a solution to populate new data in the standard layout.
    The Class and Method are mentioned below:
    Processing Class CL_DOC_PROCESSING_CRM_ORDER
    Processing Method CRM_ORDER_EXEC_SMART_FORM
    Thanks and Regards,
    Faisal

    you need to copy this class and make the changes..in the method.
    Assign the new Z class, to the action profile.
    Rgds,
    Arjun

  • Is there a way to suppress calls to modify view method?

    We have a WDP application which consists of a tabstrip with multiple tabs. We find that everytime we click on a tab, all the modify view methods in the other tabs get executed, even though it is not necessary.
    This adds to response time BECAUSE WDP executes on the server and there are round trips to the server!
    Is there a way to suppress this?

    Hi Yew
    Why dont you find out which tab has been selected and execute only the relevant set of methods for the tab selected. Check this post for code samples on how to determine the selected tab
    Re: How to get the name of a Tab at runtime
    Regards
    Pran

  • ABAP modify a method to manage the result about a query

    Can i modify a method to manage the web query in particular a column of table? i would modify a class of name "CL_RSR_WWW_ITEM_GRID" in other same class where change only column's method, which is this method?
    Thanks al lot

    you need to use modify table interface method of achieving this.
    check out the how to doc for the same.
    <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/49dfeb90-0201-0010-a1a2-9d7a7ca1a238">How to Enhance your Web Query with the Table Interface</a>
    Regards
    Raja

  • I'm having trouble with "this" and method dependence

    For my Data Structures course, we have to create a simple Word Processor. The constructor contains two stacks, left and right. The way the class populates the strings is pretty straight forward. Any text to the left of the cursor gets pushed onto the left stack and any text to the right of the cursor gets pushed onto the right stack (in reverse order). For example, the phrase "hello" with the cursor between the l's, would push h, then e, then l onto the left stack. o then l is pushed onto the right stack. Follow me so far?
    Next, we have to implement several methods, such as moveLeft, moveRight, delete, insert, and moveToStart. There is also a toString() method which prints the two stacks as a String. The way I have my toString() method mapped out, is first to call the moveToStart() method. This method then pops all values from the left stack and pushes them onto the right stack (left: empty, right: h-e-l-l-o). So now, I simply pop each value from the right stack and store the values in a char[] array. The array is then returned as a String.
    This data structure converts the stacks to a String fine, the only problem is preserving the original stacks. So I tried to copy the value of "this," which should correlate to the EditableString es2 (declared in main), to a temp EditableString, tempEs. I then call moveToStart on tempEs, and pop values from tempEs.right. This is all in hopes to preserve the original es2. However, as you could see from the output at the bottom is that toString() modifies es2. If it didn't, "Hello, how are you" would have printed twice. Instead, an empty string is printed.
    There is obviously something wrong with my moveToStart(). Any suggestions? I apologize for not providing any comments in the code, it's just that I tried to save space. If any further explanation is necessary, don't hesitate to ask. Thanks.
    public class EditableString {
    private Stack left;
    private Stack right;
    private JavaStack l = new JavaStack();
    private JavaStack r = new JavaStack();
    private char[] text;
    private static String cursor = new String("|");
    private EditableString tempEs;
    private Character characterObject;
    private char test1;
    public EditableString() {
    left = new JavaStack();
    right = new JavaStack();
    public EditableString(String left, String right) {
    new EditableString();
    for (int i=0; i < left.length(); i++) {
    characterObject = new Character(left.charAt(i));
    l.push(characterObject);
    for (int i = right.length(); i > 0; i--) {
    characterObject = new Character(right.charAt(i-1));
    r.push(characterObject);
    this.left = l;
    this.right = r;
    public void moveToStart() {
    while (! this.left.isEmpty())
    this.right.push(this.left.pop());
    public String toString() {
    tempEs = this;
    tempEs.moveToStart();
    text = new char[(tempEs.right).size()];
    for (int i=0; i < text.length; i++)
    text[i] = ((Character) (tempEs.right).pop()).charValue();
    return new String(text);
    public static void main(String args[]) {
    System.out.println("Starting Word processor!");
    System.out.println("----------");
    EditableString es2 = new EditableString("Hello, how", " are you");
    System.out.println("es2: " + es2.toString());
    System.out.println("es2: " + es2.toString());
    /* Output:
    Starting Word processor!
    es2: Hello, how are you
    es2:
    */

    Ok, I tried to create a copy(Es) method and modified the toString() method as follows, but I am having the same problem. Ok, in order to test my methods, I print the various sizes of several stacks. In the toString() method, right after tempEs is declared, this.left=10, this.right=8 and tempEs.left=tempEs.right=0. After the copy method is invoked and assigned to tempEs, this.left=tempEs.left=10 and this.right=tempEs.right=8. Follow me?, this is where I have trouble.
    I try to "pop" one value from tempEs.right to see if the action occurs on tempEs and not this. Well, it does. Right after the pop() method, this.left=tempEs.left=10 and this.right=tempEs.right=7. I need this.right to stay at 8. Why are these Editable Strings dependent?
    And for the record, I'm not trying to "pay" anyone to do my homework. I am simply trying to pass, and in turn, graduate. This is the second time I am taking this course (failed it with style the 1st time) and desperately need to pass. I have VERY little Java background and this class is unfortunately required for my engineering degree. So, I am simply looking for some help with my 30+hour homework assignments.
    public EditableString copy(EditableString ES) {
            EditableString xTemp = new EditableString();
            xTemp.left = ES.left;
            xTemp.right = ES.right;
            return xTemp;
        public String toString() {
            EditableString tempEs = new EditableString();
            tempEs = copy(this);
            tempEs.right.pop();
            tempEs.moveToStart();
            text = new char[(tempEs.right).size()];
            for (int i=0; i < text.length; i++)
                text[i] = ((Character) (tempEs.right).pop()).charValue();
            return new String(text);

  • Trouble writing a blocking method when asking GUI for input

    Hi,
    I think this is more of a thread question than a GUI question, so that is why i posted it here...
    My problem is I have a client/server application, and the client also has a GUI, which I get an input string from.
    My problem is, that I don't know how to write a blocking method, which will wait for the GUI's input.
    The example I provided below is very simple, and the obvious solution would be to use a JOptionPane, but that is not a viable solution. The way I am getting around this now is using a Thread.sleep call in my GUI, but I feel that this is incorrect, and there should be another way around it.
    Here is my server class (w/ main method)
    import java.net.*;
    import java.io.*;
    public class Server {
        public static void main(String[] args) throws IOException {
            ServerSocket serverSocket = null;
            try {
                serverSocket = new ServerSocket(4444);
            } catch (IOException e) {
                System.err.println("Could not listen on port: 4444.");
                System.exit(1);
            Socket clientSocket = null;
            try {
                clientSocket = serverSocket.accept();
            } catch (IOException e) {
                System.err.println("Accept failed.");
                System.exit(1);
            PrintWriter out = new PrintWriter(clientSocket.getOutputStream(), true);
            BufferedReader in = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
            String  outputLine;
            outputLine = "Temp String";
            out.println(outputLine);
             System.err.println("Client: " + in.readLine());
            outputLine = "Bye";
            out.println(outputLine);
            out.close();
            in.close();
            clientSocket.close();
            serverSocket.close();
    }Here is my client class (w/ main method)
    import java.io.*;
    import java.net.*;
    public class Client {
        public static void main(String[] args) throws IOException {
            Socket kkSocket = null;
            PrintWriter out = null;
            BufferedReader in = null;
            try {
                kkSocket = new Socket("localhost", 4444);
                out = new PrintWriter(kkSocket.getOutputStream(), true);
                in = new BufferedReader(new InputStreamReader(kkSocket.getInputStream()));
            } catch (UnknownHostException e) {
                System.err.println("Don't know about host: localhost.");
                System.exit(1);
            } catch (IOException e) {
                System.err.println("Couldn't get I/O for the connection to: localhost.");
                System.exit(1);
            ClientGUI cg = new ClientGUI();
            String fromServer;
            String fromUser;
            while ((fromServer = in.readLine()) != null) {
                System.out.println("Server: " + fromServer);
                if (fromServer.equals("Bye."))
                    break;
                fromUser = cg.getInput();
             if (fromUser != null) {
                    System.out.println("Client: " + fromUser);
                    out.println(fromUser);
            out.close();
            in.close();
            kkSocket.close();
             System.exit(0);
    }and here is the ClientGUI class (note: you need to resize it in order to see the textbox....
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.ActionListener;
    import java.awt.event.ActionEvent;
    public class ClientGUI extends JFrame {
         private JTextField textBox = new JTextField();
         private JButton input = new JButton("Submit");
         private boolean recievedInput = false;
         private String inputText = "";
         public ClientGUI() {
              this.setupGUI();
         private ActionListener buttonAction = new ActionListener() {
              public void actionPerformed(ActionEvent e)  {
                   inputText = textBox.getText();
                   recievedInput = true;
         public String getInput() {
              while(recievedInput == false) {
                   try {
                        Thread.sleep(2000);  //I  DONT want to do this!!
                   catch(InterruptedException e) {
                        e.printStackTrace();
              recievedInput = false;
              return inputText;
         private void setupGUI() {
              textBox.setMinimumSize(new Dimension(100, 20));
              input.addActionListener(buttonAction);
              this.getContentPane().setLayout(new BorderLayout());
              this.getContentPane().add(textBox, BorderLayout.WEST);
              this.getContentPane().add(input, BorderLayout.EAST);
              this.pack();
              this.setSize(100,300);
              this.setVisible(true);
    }If you have any ideas, I would greatly appreciate it

    warnerja,
    I tried the following, but I got an exception.
    in the while loop inside Client.java, I put the following:
                 synchronized(cg) {
                      try {
                          cg.wait();
                        fromUser = cg.getInput();
                      catch(InterruptedException e) {
                           e.printStackTrace();
                 }and inside my ClientGUI class, I put the following:
    private ActionListener buttonAction = new ActionListener() {
              public void actionPerformed(ActionEvent e)  {
                   inputText = textBox.getText();
                   ClientGUI.this.notify();
         public String getInput() {
              return inputText;
         }But I got this exception:
    Exception in thread "AWT-EventQueue-0" java.lang.IllegalMonitorStateException: current thread not owner
         at java.lang.Object.notify(Native Method)
         at ClientGUI$1.actionPerformed(ClientGUI.java:21)
    any idea what I am doing wrong?

  • Having trouble with the renameTo() method in Windows

    Hi all,
    The below code works perfectly well in netbeans but as shown as I try to call it from cmd prompt I get issues.
    The below code is designed to move or delete log files from one area or another.
    now if i try to delete the logs from command prompt I have no problem.
    However when I tried to move the files by doing renameTo() I get a false back. And as this method seems to have no relevant error message, I am at a loss....
    Now I have checked the permissions, this is not a problem (all users can edit the files, if I can't edit them why will let me delete them?), I have checked to make sure no duplicate files exist and they don't. i have also tried to move the files to different locations, same problem. The files are definitely not open.
    I need the below to work on 1.5 due to compatibility issues with other programs.
    Any ideas?
    public class Main {
         * @param args the command line arguments
         * args[0] = Directory where files are to be processed from
         * args[1] = file extension to process
         * args[2] = Number of days to limit on. IE 31 means all files older than 31 days
         * args[3] = location of log file
         * args[4] = del/move. if del, files are deleted. if move, files are moved.
         * args[5] = Location of the new file. only applicable if file is moved.
        public static final String newLine = System.getProperty("line.separator").toString();
        public static void main(String[] args) {
            try {
                File file = new File(args[0]);
                FileNameFilter fileFilter = new FileNameFilter(args[1]);
                int days = Integer.parseInt(args[2]);
                File[] children = file.listFiles(fileFilter);
                // longs required because int overflow limit reached.
                long daysAgoPart1 = 1000 * 60 * 60;
                long daysAgoPart2 = 24 * days;
                long daysAgoPart3 = daysAgoPart1 * daysAgoPart2;
                long daysAgo = new Date().getTime() - (daysAgoPart3);
                // System.out.println(daysAgoPart3);
                // System.out.println(new Date().getTime());
                // System.out.println(daysAgo);
                // System.out.println(new Date().toString());
                Date limitDate = new Date(daysAgo);
                // System.out.println(new Date(new Date().getTime()).toString());
                //  System.out.println(limitDate.toString());
                for (int i = 0; i < children.length; i++) {
                    if (children.lastModified() - limitDate.getTime() < 0) {
    if (args[4].compareTo("del") == 0) {
    printLog("Deleted file: " + children[i].getAbsolutePath(), args[3]);
    children[i].delete();
    } else if (args[4].compareTo("move") == 0){
    String fileName = children[i].getAbsolutePath();
    if (!children[i].canRead()){
    printLog("Can't read: " + fileName, args[3]);
    } else if (!children[i].canWrite()){
    printLog("Can't write: " + fileName, args[3]);
    if( (children[i].renameTo(new File(args[5] + children[i].getName())))){
    printLog("Moved file "+ fileName, args[3]);
    } else {
    printLog("Failed to move file "+ fileName, args[3]);
    } catch (Exception err) {
    printLog(err.toString(), args[3]);
    public static void printLog(String message, String logLoc) {
    try {
    File errLog = new File(logLoc);
    FileWriter errFW = new FileWriter(errLog, true);
    errFW.append(new Date().toString() + " " + message);
    errFW.append(newLine);
    errFW.close();
    } catch (IOException errFWException) {
    }Edited by: enema0007 on Sep 2, 2009 8:27 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    right I think I have worked out what I am doing wrong I think.....
    I am calling the code with:
    java -jar "deleteLogs.jar" "D:\TADDM" ".rar" 31 "D:\Working Files\deleteFilesLog.log" "move" "D:\Working Files\"
    However when I go to create file its giving me:
    D:\Working Files"logs.rar
    Which is clearly not the correct file name....
    So why is it removing the \ and not the "?

  • I'm having trouble with my payment method payment type it's not accepting any of my cards

    Payment method/payment type will not accept any of my cards for payment it's saying my security codes are wrong there are available funds on both card

    You have exactly the same name and address on your iTunes account that the cards are registered to : http://support.apple.com/kb/TS1646 ?
    And when you say that there are available funds on the cards, do you mean that they are debit cards ? If they are then I don't think that they are still accepted as a valid payment method in all countries - from this page :
    You may be able to use other payment types in your country, like debit and Maestro cards
    which implies that they are not accepted in all countries, and there have been a number of posts about them being declined.

  • Trouble with modifying/deleting an adjustment layer

    First time posting on here and I'm going a little crazy!  I'm using the most up-to-date version of CS5.
    I have some pictures that I'm trying to have my subjects in color with the rest of the picture in black & white.  It's a common trend I do with a lot of my pictures, but for whatever reason I can't seem to delete any of the selected area I've created with the quick selection tool or lasso tool.
    To walk you through how I've always done this:
    I open the the image (these are jpgs) - the background layer is in full color
    I add a hue/saturation adjustment layer.
    I adjust the saturation in the layer to black and white.
    I typically use the quick selection tool to highlight my subject I want to be in color.
    When the subject is completely highlighted, I click 'delete' and I see in the layer mask the selected area turn black and my subject is in color from the background layer.
    I started doing this today and went through a handful of jpegs using this exact same method, but now all of a sudden I try and do it but when I click delete nothing happens and the layer mask stays completely white with no changes whatsoever. 
    Please please please help.  I have no idea why this method just stopped working all of a sudden.  I keep searching on Google to find similar issues but nothing is helping.

    Maybe your background color is not set to black.
    Hit the D key then the X key.
    MTSTUNER

  • Trouble with modify/edit in illustrator 4

    So, I'm building my first site in Catalyst. I designed my site in Illustrator 4 and imported it into Catalyst. I had all my states/transitions built and everything seemed to be working fine. I then went back to edit a pice of placeholder text by clicking on the item, going to modify/edit in illustrator 4 and then saving and accepting changes. Everything seemed to be fine until I went to run the project. Then I noticed that on the transition out of the page that had the updated text that it would flash back to the old text before going to the new page. The text had been set to fade in and fade out when you click on a button. The fading in works properly, but the fade out has a glitch where it flashes the old text on the way out. I've tried refreshing/restarting, whatever I could think of and it's still doing it. When I play the transition within FC I noticed that it shows a bunch of code where that that text should be. It happens to fast to read it all and I wouldn't understand it if I could anyway. Any ideas what's going on?
    Thanks

    Hi CrazyMerlin,
    That should not be happening.  Can you please write back with these two pieces of diagnostic information?
    What folder is Catalyst installed to?
    Click the "Edit in Adobe Illustrator" menu item in Catalyst to get the error message.  Then quit Catalyst, and locate the following file:
    Mac: ~/Library/Application Support/Adobe/Flash Catalyst/workspace/.metadata/.log (note that files/folders starting with "." are invisible in Finder, so you may have to use the Terminal to get to this file)
    XP: C:\Documents and Settings\<username>\Application Data\Adobe\Flash Catalyst\workspace\.metadata\.log
    Windows 7/Vista: C:\Users\<username>\AppData\Roaming\Adobe\Flash Catalyst\workspace\.metadata\.log
    Please send us this file (you should be able to post it as an attachment to your forum reply).
    We'll take a look from there and try to figure out what's going wrong.
    - Peter

  • Having trouble passing values between methods

    So if this isnt the right spot for this.
    Anyhow any coments on where I went wrong or need to fix will be apriciated.
    So I got two methods that return a value (getHour() and getMinute(). The values that are returned I am tring to pass into showTime. However it doesn't seem to work as all I get is zero's.
    I've done a search around on the net and Im starting to thing my intellagnce is limited.
    import java.util.Scanner;
    public class First
    static int sH, sM;
        public static void main(String args[]){
            getHour();
            getMinute();
           showTime(sH,sM);
        static int getHour(){
            Scanner input = new Scanner(System.in);
            System.out.println("Please enter the hour: ");
            int setHour = input.nextInt();
            if(setHour <= 24){
                System.out.println("You entered " +setHour+ " for the hour.");
            }else{
                System.out.println("Please enter the hour number from 0 to 24");
                getHour();
         return sH;
         static int getMinute(){
            Scanner input = new Scanner(System.in);
            System.out.println("Please enter the minutes: ");
            int setMinute = input.nextInt();
            if(setMinute <= 60){
                System.out.println("You entered " +setMinute+ " for the minutes.");
            }else{
                System.out.println("Please enter the hour number from 0 to 60");
                getMinute();
            return sM;
        private static void showTime(int sH, int sM){
              System.out.println(+sH+":"+sM);
    }

    Hi,pls compare ur coding with the one i have posted below. In your code, the variables sH and sM are still in initialised state(value =0) and its not assigned with the values returned by getHour and getMinute methods. This is why the shoTime method returned zero. Hope i helped you.
    import java.util.Scanner;
    * @author Jaison KS-IT
    public class First {
    static int sH, sM;
    public static void main(String args[])
    getHour();
    getMinute();
    showTime(sH,sM);
    static int getHour(){
    Scanner input = new Scanner(System.in);
    System.out.println("Please enter the hour: ");
    int setHour = input.nextInt();
    if(setHour <= 24){
    System.out.println("You entered " setHour " for the hour.");
    sH = setHour;
    }else{
    System.out.println("Please enter the hour number from 0 to 24");
    getHour();
    return sH;
    static int getMinute(){
    Scanner input = new Scanner(System.in);
    System.out.println("Please enter the minutes: ");
    int setMinute = input.nextInt();
    if(setMinute <= 60){
    System.out.println("You entered " setMinute " for the minutes.");
    sM = setMinute;
    }else{
    System.out.println("Please enter the hour number from 0 to 60");
    getMinute();
    return sM;
    private static void showTime(int sH, int sM){
              System.out.println(+sH+":"+sM);
    }

  • Having trouble passing a getter method in a PreparedStatement

    Basically I've got it so that the user fills in their name, dob etc and when they click on register it inserts their information in a registrations table. However, I'm having trouble getting this working (NullPointerException) so any help would be greatly appreciated :)
    RegisterDetails.java
    public void writeToTbl() throws SQLException, ClassNotFoundException {
              DBase d = new DBase();
              GUI g = new GUI();
              i = 0;
              String regStr = "INSERT INTO REGISTRATION VALUES(?,?,?,?,?,?,?,?)";
              PreparedStatement st = d.getConnection().prepareStatement(regStr);          
              st.setInt(1, i);
              st.setString(2, g.getName()); //Exception error points to this line
              st.setString(3, g.getDOB());
              st.setString(4, g.getRoad());
              st.setString(5, g.getCity());
              st.setString(6, g.getCounty());
              st.setString(7, g.getPhone());
              st.setString(8, g.getEmail());
              st.executeUpdate();
         }GUI.java
    btnReg.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent ev) {               
                        if (ev.getSource() == btnReg && (agree.isSelected())) {
                             writeToFile(f, bWriter);
                             RegisterDetails reg = new RegisterDetails();
                             try {
                                  reg.writeToTbl(); //Exception error points to this line
                             } catch (SQLException e) {
                                  e.printStackTrace();
                             } catch (ClassNotFoundException e) {
                                  e.printStackTrace();
                        else {
    // JTextFields return their results
    public String getName() {
              return name.getText(); //Exception error points to this line
         public String getDOB() {
              return dob.getText();
         public String getRoad() {
              return road.getText();
         public String getCity() {
              return city.getText();
         public String getCounty() {
              return county.getText();
         public String getPhone() {
              return phoneNo.getText();
         public String getEmail() {
              return email.getText();So essentially I'm trying to get the information from the textfields and insert it into the registrations table but nothing seems to work. I've followed numerous tutorials on how to do it, but all of them use "fixed" values e.g., setString(1, "James") etc but I need the value of the JTextFields as they will be different every time. I'm completely at a loss with this at the moment so any help would be magnificent. :-)
    Thank you!

    so any help would be magnificent.Write a class that accepts the values that you want to insert. I would suggest passing an ArrayList. It opens the connection, does the insert, closes the statement and the connection.
    It does NOT have any GUI code in it.
    You then debug that class and verify it works.
    THEN, after you have verified it works, you write ANOTHER class that does the gui. It uses the class above to do the database work.

  • Trouble with singly linked method

    i have this mothod in my program and im not sure how to go about it....
    here is what it is.. if anyone can help me get started that would be great
          * Compares this list to the parameter IntList for equality.
          * The two lists are equal iff they are the same size and
          * for each index 0 <= i < size, the ith elements of the two
          * lists are equal.
          * @param otherList - the right operand of the equality test
          * @return true if the two lists are equal, false otherwise
         public boolean equals(IntList otherList);

    Following your previous posts this might help:public class LinkedIntList implements IntList {
        protected class Node {
            protected int data;
            protected Node next;
        protected Node head;
        protected int size;
        public boolean equals(IntList otherList) {
            // *** verify that otherList is a LinkedIntList type
            // *** then assign it to a LinkedIntList local variable (eg. otherLinkedList)
            // *** verify equality of size between this and otherLinkedList
            // *** loop from this head till null found
            // *** in each iteration verify equality of data between current node from this
            // *** and current node from otherLinkedList
    }

  • Trouble exporting modified photos

    I'm trying to burn a CD for a PC user. I have followed the directions to export an album to a new folder but the original, unmodified photos show up in the folder. I don't want to send uncropped photos that are out of order. I tried changing the filenames of the photos thinking that might help but it doesn't. Would appreciate any suggestions.

    Check them all and leave them checked. The "!" problem can also occur if iPhoto is interrupted while writing to its database file, Library6.iPhoto. See the tip at the end of my signature. It can help you recover from the "!" problem and get your library back to where it was at the time of the last backup.
    TIP: For insurance against the iPhoto database corruption that many users have experienced I recommend making a backup copy of the Library6.iPhoto database file and keep it current. If problems crop up where iPhoto suddenly can't see any photos or thinks there are no photos in the library, replacing the working Library6.iPhoto file with the backup will often get the library back. By keeping it current I mean backup after each import and/or any serious editing or work on books, slideshows, calendars, cards, etc. That insures that if a problem pops up and you do need to replace the database file, you'll retain all those efforts. It doesn't take long to make the backup and it's good insurance.
    I've written an Automator workflow application (requires Tiger), iPhoto dB File Backup, that will copy the selected Library6.iPhoto file from your iPhoto Library folder to the Pictures folder, replacing any previous version of it. You can download it at Toad's Cellar. Be sure to read the Read Me pdf file.

  • Trying to create and excel graph and having trouble finding properties and methods for active x.

    I am trying to use Active X in labview 7 to create an excel graph and the HasMajorGridlines property for charts is not in my menu. Where can I get this property and others that appear to be missing and what is a good resource (looking for anything, especially books) for for using activeX/Labview/excel together?

    I am not sure if there is a book or tutorial how to use excel with LabView. I ncluded a Vi which gives you access to the HasMajorGridlines property. I hope it gives you the clou how to work with excel obejcts...
    Chris
    Attachments:
    excel_example.vi ‏24 KB

Maybe you are looking for

  • Why can I not download from the iTunes Store??

    I bought an album from the iTunes Store via my iPhone 5 and despite the fact that I have a strong 4G signal, it is telling me that one track is going to take over 42 minutes to download! I checked the speed on Speed Test and it showed 32mbps download

  • Firefox 19.0 PDF data is not showing when we use the Preview in firefox option.

    I am using FireFox 19.0 Version. In my application, I create the adobe PDF and it should shows on click on link button. On previous version it was working. but in 19.0 it is not working. In Firefox option i am using preview in firefox option to show

  • Problem related to generation of header file

    hi guys, I am getting Exception during the generation of the header file, using "javah -jni HelloWorld" I am refering jni.pdf (java.sun.com/docs/books/jni/download/jni.pdf ) I have given that error below Exception in thread "main" java.io.IOException

  • How to change datasource viewobject main query in .jsp

    Hi i have datasource DataSource viewobject="test" now in .jsp page i need to change it main query and after some things again back to default how i can doo it ? Thanks for tips! ID. Jdeveloper Studio Edition Version 11.1.1.6.0 ADF Business Components

  • Creating New "Photo" User

    OK, after much confusion over multiple users and a great deal of help on these forums I have decided to create a new user account "Photos" to hold my iPhoto data and then have separate user accounts for my wife and I who can view the photos. Currentl