Search:

Type: Posts; User: DuncanS

Search: Search took 0.20 seconds.

  1. Re: How to properly kill a thread that is loading resources in the background

    If that's the case, shouldn't a graceful shutdown be fine? Something like this:



    public class MyThread implements Runnable {

    private volatile Thread myThread;

    public MyThread() {
    ...
  2. Replies
    2
    Views
    106

    Re: count the length of each word in a string

    After reading the answers the dreamincode users gave, it seems like you just ignored their advice. What is it that you are trying to fix? Go through your code line by line and trace what the program...
  3. Re: Unbale to setText to a label multiple times in same program

    For future reference, you should put your code in
    [\CODE] tags.

    [CODE=Java]
    setTitle1 = new JLabel(); // Welcome To
    setTitle1.setBounds(250,220,950,150);
    setTitle1.setForeground(new...
  4. Re: How to properly kill a thread that is loading resources in the background

    As outlined here, ChristopherLowe's suggestions are your best bet for killing the thread abruptly, but I would wrap it in a ShutdownHook -



    Runtime.getRuntime().addShutdownHook(new Thread() {...
  5. Re: java program that converts number grades to letter grade

    There are several considerations to be made here.

    First, why such long comments on lines that are already printing output? Comments are tools used to point out important logic and reasoning in a...
  6. Re: how to convert any date formats into yyyyMMdd format

    Next time you should probably edit your post rather than starting a new thread.

    That output is because "23-04" in yyyyMMdd is parsed as "the 4th of the month 0 months before year 23", 0022-12-04....
  7. Replies
    2
    Views
    53

    Re: this in Java for particular example

    The this keyword in Java refers to the object executing the code, in this case the Exam object you create. In this context, using this modifies the globally scoped age field in the object, without...
  8. Replies
    4
    Views
    49

    Re: Splitting string in Java error

    The issue is also that the \t in your test1 String object is becoming a tab. As Cornix said, .split() uses a regular expression as a parameter, so it expects something after the escaped backslash. In...
  9. Re: Really important assignment need checking please :)

    I think the most important factors to note in the example stats you gave is that 4944 + 7606 + 3725 > 10000, and 49.44 + 76.06 + 37.25 > 100%... There's clearly an issue there; it probably has to do...
  10. Replies
    8
    Views
    47

    Re: Get the mouse x , y?

    There was no way for me to know that within the confines of your post. I'll refer back to what GregBrannon posted initially:



    Provide some demonstrable code within your posts that indicates the...
  11. Replies
    13
    Views
    65

    [SOLVED] Re: nary tree from string

    The out of memory error is caused because you never decrease p. Use --p instead of p - 1 here:
    Object get2 = a1.get(p-1);

    The ArrayOutOfBounds exception is because your break condition never...
  12. Replies
    8
    Views
    47

    Re: Get the mouse x , y?

    Note the very first line of my response - 'If you haven't already, ...'. I'm not going to dig through your entire project to debug your code for you. You gave a cursory explanation of your problem,...
  13. Re: Best way to solve this ConcurrentModificationException

    Maybe something like this?



    import java.util.ArrayList;
    import java.util.List;
    import java.util.ListIterator;

    public class SignalEmitter {
  14. Replies
    37
    Views
    134

    Re: Empty dialog

    Well I'm confused. I assume you mean to say that you haven't had a formal education in Java, but then I would argue that a formal education isn't necessary as long as you have the drive to learn the...
  15. Replies
    2
    Views
    102

    Re: multiple session browser

    The session shouldn't carry over to the new browser. How are you defining a session? How are the values being sent to the backend (ie. Spring, Struts)? Is there an auth procedure being used to...
  16. Replies
    37
    Views
    134

    Re: JCheckBox

    I feel as though this thread should be merged with your previous question.

    EDIT: You've posted 5 questions about this program in the past 24 hours... Do you do any of your own work?
  17. Replies
    37
    Views
    134

    Re: Empty dialog

    I don't really understand your point. Read the tutorials, and if there is a point at which functionality differs tangibly, find an OJDK reference for that specific functionality.

    Your code seems...
  18. Replies
    13
    Views
    65

    [SOLVED] Re: nary tree from string

    It's your algorithm, so the burden is on you to make it right in the first place. If you want help with specific questions, this is the place, but from your initial question it seems as though you...
  19. Replies
    37
    Views
    134

    Re: Empty dialog

    You're in university. The web is an open book, full to the brim with information, so I suggest you start by actually trying to learn rather than passing the buck like this. There are myriad tutorials...
  20. Replies
    8
    Views
    47

    Re: Get the mouse x , y?

    If you haven't already, add a class that implements MouseListener and MouseMotionListener to your main frame - whichever you're using of the awt version of Applet/Frames or the Swing JApplet/JFrame -...
  21. Replies
    3
    Views
    86

    Re: Nagging Run Result on Console!

    Either set up run configurations for your programs, or right click the file in the Project Explorer view and select Run As > Java Application. You can also use the Run button drop-down menu to select...
  22. Poll: Re: I want to convert sloane1.com (php website) to Java Website

    PHP is just a preprocessor language. To "replace" an entire WordPress site with a Java stack would be very difficult, as you would have to build the site from the ground up. Your poll makes no sense...
  23. Thread: Java problem

    by DuncanS
    Replies
    7
    Views
    24

    Re: Java problem

    >= and <= are used when you need an inclusive set. if (num2>=5 && num2<=10) will return true for the set { 5, 6, 7, 8, 9, 10 }, whereas if (num2>5 && num2<10) will return true for the set { 6, 7, 8,...
  24. Replies
    4
    Views
    48

    Re: Alternating Numbers Of two sequences

    Use a ListIterator:



    public ArrayList<Integer> merge(Sequence other) {
    ListIterator<Integer> li = other.values.listIterator();

    for (Integer i : values) {
    if (li.hasNext()) {
    ...
  25. Thread: Java problem

    by DuncanS
    Replies
    7
    Views
    24

    Re: Java problem

    The issue is here:

    if (num2>15 && num3>15) {
    System.out.println ("Two larger");
    }

    With your inputs you're asking if (15>15 && 34>15), but 15 is not greater than 15, it is equal. If you need...
Results 1 to 25 of 25