BestJewSinceJC 700 Posting Maven

You could start by getting a book from the library and reading about master theorem or by looking it up online. It isn't impossible.

BestJewSinceJC 700 Posting Maven

Do you think you might be able to use De Morgan's laws? http://en.wikipedia.org/wiki/De_Morgan%27s_laws

BestJewSinceJC 700 Posting Maven

Use a Scanner. Really, the exact way to do it depends on how your text file is set up, but here is a general tutorial on Scanner.

BestJewSinceJC 700 Posting Maven

So a tool bar (you know, the link you would've seen if you'd looked through the last link I sent you)? Sorry if that isn't what you wanted, your post actually still makes no sense, typing in caps doesn't really help though.

http://java.sun.com/docs/books/tutorial/uiswing/components/toolbar.html

Majestics commented: Great Help... +0
BestJewSinceJC 700 Posting Maven

im ahvren trublesz givien advics ?? but i dink dat u shud google!!!!

BestJewSinceJC 700 Posting Maven

javaAddict If I use Scanner.nextLine, so it will not read the file as binary but as character string. I mean if I use Scanner.nextLine the filetype is important for me because you can not read the 1s and 0s if they are not on the file.
I dont understant how the filetype is important when I want to read a character or integer from a file ? That is something impossible for me . I know that every file is saning on my harddisk as 1010101111011011............. and when I open the file with mp3player it reads the bits as what mp3 player wants to do. When I open it with "txt viewer" it reads (i don't know exactly and it is not important now) first 4 bytes for first character, and second 4 bytes for second character and shows me them on the screen. And I tell you that I want to read any file as I want to read. For example first 4 bytes (4*8 bits) is a long integer for me. Or the second 1 byte is a just a key for my grafic interface color ... or something. And I tell you that there is I way to show the bits of file on the screen. I think that if I can read the first two bytes as integer and I convert it on binary base I would be able to see the file as binary. If my suggestion is false can you tell me how …

BestJewSinceJC 700 Posting Maven

My worst secret is that I thought this was a serious thread, but then clicked the link and loled at those poor peoples' broken hearts, but I don't want you guys to know I thought the link was mildly funny, so instead, I leave you with this: stop spamming daniweb, you suck.

VernonDozier commented: Yes, he does suck. +0
BestJewSinceJC 700 Posting Maven

And apparently other people like to up three year old threads on forums. Who would've thought?

Will Gresham commented: Obviously got bored and thought this would be a good google search... +0
BestJewSinceJC 700 Posting Maven

For playing sound, you can use the Java Sound API. Specifically, it sounds like the section in this article on Using a Clip is relevant to what you are trying to do.

BestJewSinceJC 700 Posting Maven

What is this supposed to mean?

Q4 myInstanceOfQ4(3,5.5);

I think you should read about classes, methods, and Objects in the Java tutorials.

BestJewSinceJC 700 Posting Maven

Is that a serious question? People take college courses, high school courses, certification programs, ask work related questions, have their own projects, etc

BestJewSinceJC 700 Posting Maven

Change the code in your action performed method to the following:

JOptionPane.showMessageDialog(null, "Adding JPanel");
        ColectionBean cb=new ColectionBean();
        cb.setSize(500,500);
        cb.add(new JLabel("THIS IS THE NEW PANEL YO"));
        cb.setVisible(true);
        this.inColecaoPanel.add(cb);
        cb.revalidate();
        System.out.println("É Visivel? "+cb.isVisible());
        this.inColecaoPanel.setVisible(true);
        this.inColecaoPanel.revalidate();

And when you click the button you will see that your panel shows up, not like you'd want it to, (i.e. parts of it are cut off and it doesn't look pretty) but it does show up. You can fix this by playing with the setPreferredSize methods and you need to read the java sun tutorial on how to use GroupLayout. . it has a lot of helpful ways to design components so that dynamic updates are possible.

jpavao commented: Very good and quick answer +1
BestJewSinceJC 700 Posting Maven

You're using JTable I assume?

See "setting and changing column widths" here
In particular, you might be interested in the section of text where it says, "For an example of setting cell widths based on an approximation of the space needed to draw the cells' contents, see the initColumnSizes method" (and then they give a link)

BestJewSinceJC 700 Posting Maven

Well, without digging into it thoroughly, I won't be able to help (considering the size of the code), so I'll get back to you tomorrow. If I forget to get back to you, don't hesitate to PM me with a link to this thread (sometimes if I don't see the link, I forget about it). The names of the variables aren't really that important for digging through it, I can always do a search if I see something strange, but it seems like your issue is unrelated to the text field and may be caused by errors with your other components.

Oh, and in the future, for code of this length, it is better to just attach the file, or if someone requests to run your code on their machine. If you see this before I get back tomorrow could you do that?

BestJewSinceJC 700 Posting Maven

Java Addict is absolutely correct.

From online (would credit source, closed the tab accidentally): "Since Strings are objects, the equals(Object) method will return true if two Strings have the same objects. The == operator will only be true if two String references point to the same underlying String object. Hence two Strings representing the same content will be equal when tested by the equals(Object) method, but will only by equal when tested with the == operator if they are actually the same object."

In summary, if you wanted to test if two People objects were the same person, you would probably consider them the same person if they had the same name, social security number, and birthday. You would therefore need to use the equals() method to make this comparison, since using '==' would tell you if those two Java Objects had the same memory address. Similarly, you would probably consider two Strings that both said "Same thing" to be the same String, however, if you tested this with '==', it would only test to see if those Strings were the same Object... and therefore, resided in the same place in your computer's memory. . not to see if they are logically the same String.

kvprajapati commented: Helpful +7
BestJewSinceJC 700 Posting Maven

Are those JTextFields? If so, setText is the right method.
http://java.sun.com/docs/books/tutorial/uiswing/components/textfield.html

Are you sure your text fields are properly initialized and added to the panel? Can you post a bit more code showing where this is done? And have you taken similar steps in your code as I have in this example:

package kyle;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextField;

public class TextFieldTest {

	static JTextField field = new JTextField("text here!!");
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		JFrame frame = new JFrame("Text Field Test");
		JPanel panel = new JPanel();
		panel.add(field);
		frame.add(panel);
		frame.setVisible(true);
		frame.setSize(250,250);
		
		try {
			Thread.currentThread().sleep(3000);
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		field.setText("different text now.");
	}

}

(Ignore bad usage of Thread.sleep, etc, that was just a quick example - I'm referring to whether or not you added your panel to your frame, otherwise your text fields won't show to begin with. Can you see your text fields to begin with?)

ceyesuma commented: Incredible! BestJewSinceJC showed me some very impotant programming concepts. +0
BestJewSinceJC 700 Posting Maven

http://www.pcmech.com/article/monitor-your-computers-bandwidth-usage/

Just the first thing I found. Something like that is what you're talking about, right? Since there are pre-existing programs that do what you want, anyone of any experience level can accomplish this task.

BestJewSinceJC 700 Posting Maven

I type with two fingers, and I probably type at well over 60 wpm, (over 70 according to some typing thing someone posted here - but who knows how accurate that was). My advice is just to type however you want and to do so more often. Save your money on the typing class.

BestJewSinceJC 700 Posting Maven

The search option is obviously still missing. The way it is not, is that ok? I have no idea how to implement the search though. I don't know how to do the search.
Help would be relly appreciated.

Create an 'Automobile' class. Your ArrayList should be filled with Automobiles. In the Automobile class, override the equals() method. The equals() method should be designed like so. After you do all of that, searching will be as simple as using the appropriate method listed here. (i.e. contains, indexOf(), whatever else you find).

BestJewSinceJC 700 Posting Maven

If you're using Scanner's next() method to read in the String, it is probably killing your whitespace. http://java.sun.com/j2se/1.5.0/docs/api/java/util/Scanner.html#next%28%29 . Keep in mind that the default delimiter pattern matches whitespace, so your 'tokens' that it refers to in the method documentation is preceded and followed by whitespace. Do you mind posting your code?

Also, you should try this:

yourString.split("[|]");

You should look into java's regular expressions tutorial, but using "|" seems to not work, while what I have above does.

BestJewSinceJC 700 Posting Maven

I first ran into Adatapost in the C# section. He was a fairly prominent figure there when I first started (all those long months ago!!) and still keeps up his posts as a mod. I think he's patient and kind to the extreme and truly enjoys helping people learn. He's also encouraging with rep and nice comments!

P.S. Just like with vegaseat, I have yet to figure out what an adatapost is. Is that like a sign post for data to follow? ;)

Huh, I never even knew he posted there, but I stick to Java. I also browse the C forum but almost exclusively to read answers to interesting topics, I hardly venture an answer unless it is something fairly simple. Anyway, I always thought his name just referred to the content of his posts.

BestJewSinceJC 700 Posting Maven

adatapost

When he first joined the site he seemed different in some ways (one being that his English wasn't as good, or didn't seem as good to me). However, he has since become a mod in the Java forum (and perhaps other forums as well?) and has definitely earned my respect. I'm not going to claim that his solutions are always correct or the best, but I don't recall seeing any of his solutions that anyone disagreed with, and he is generally helpful with replying to questions, providing useful information, and enforcing code tags and other rules.

BestJewSinceJC 700 Posting Maven

The government also has the power to print money. lots of it! A measly 14 trillion, ha, just a drop in the bucket!

But when the government abuses that power, the money becomes worthless.

Salem commented: Just like Zimbabwe - 14Tn wasn't national debt, it was a loaf of bread. +0
BestJewSinceJC 700 Posting Maven

Why do you need a StringSelection Object? You should just need the String, i.e. the one that is stored in your variable called 'selection'.

Btw, the error is that you're using PrintWriter's "print" method, and you are passing it a StringSelection Object. But if you look at the class documentation for PrintWriter, no such method exists. However, PrintWriter does have a method that takes a String, so you should get rid of the StringSelection variable and do:

pr.print(selection);

http://java.sun.com/j2se/1.4.2/docs/api/java/io/PrintWriter.html
^ Here is the PrintWriter javadoc, take a look. No "print" method exists that takes a StringSelection Object as a param.

BestJewSinceJC 700 Posting Maven

I mean you could use a while loop, but it would be very unusual to do so in this situation. For example, consider the following array:

int[] myints = new int[10];
int i = 0;
while (i < myints.length){
//do something
i++;
}

//compare that improper use of while loop to this:
for (int i =0 ; i < myints.length; i++){
//do something
}

Hope that helps.

BestJewSinceJC 700 Posting Maven

Combine the path that JFileChooser undoubtedly returns with this: http://forums.sun.com/thread.jspa?threadID=760337

There might be more current solutions available, and in fact I wrote the exact program you're describing myself, but since my program is on my older machine... you're out of luck there.

BestJewSinceJC 700 Posting Maven

And some of us hate baseball.

Nick Evan commented: Yup. Soccer however kicks ass :) +0
BestJewSinceJC 700 Posting Maven

The folks at the NSA will pick your super secret password in less than a second. So, pick something simple you can easily type and remember in the hope that it is safe from the boss or your underage sister.

Really, how? Because the NSA might have faster computers and similarly capable algorithms, or even more advanced, than anyone else... but mathematics still applies to them and if I use a sufficiently long password they are still never going to figure it out without seizing my computer or intercepting it on the interwebs. Not that I know anything worth knowing, I'm just saying, I call BS on you.

BestJewSinceJC 700 Posting Maven

Use your brain. This problem is practically begging you to have some level of intelligent thought. They didn't even ask for programming examples, they just asked for examples. Are you really that dumb.. ?

BestJewSinceJC 700 Posting Maven

Grab an algorithms book or tutorial and read a little bit, if you're thinking you're going to get a ready made formula like a 'typical' math formula, you're on the wrong track. You might want to read about asymptotic analysis, runtime analysis, Big O, and connected topics that come up in searches. (I'm just giving you some terms to search for so you aren't at a loss where to start). The beginning of CLRS (Introduction to Algorithms by Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Cliff Stein, published by MIT Press and McGraw-Hill) introduces everything you need to know to analyze *most* (and by most I mean simple) programs, so if you're still at a loss after looking into other sources, check that out.

BestJewSinceJC 700 Posting Maven

Not that I'm going to help, because I'm not, but the origin of number systems has nothing to do with programming languages, so I don't understand your response, Seten.

BestJewSinceJC 700 Posting Maven

Well, I gave him some reputation, and your gratefulness is probably enough anyway. After all, people don't usually help on forums because of all the money they'll make from it. :) But good luck on your project; sorry I couldn't be of more assistance, but I was in a rush and I didn't understand the full scope of your problem.

BestJewSinceJC 700 Posting Maven

Well. . even among the dedicated members, there is a lot of variation in skill here. Wouldn't it be better to have 3 different levels, similar to Sane's challenge at Daniweb's sister site, PFO?

BestJewSinceJC 700 Posting Maven

if you do things like removeAll() on a JFrame or JPanel, then after adding new panels, you might need to call revalidate() or validate(). I've told people that before and they've reported back success, so go try it and let me know. If that doesn't work, post all of your code so that I can run it and I'll help.

BestJewSinceJC 700 Posting Maven

If you declare a method as taking an int as a parameter, then you need to pass that int. i.e. in your setX and setY methods, you cannot call setX(), you have to call setX(PUTANINTHERE!!!)

hope that helps.

And one more thing - having getX and getY methods might not be helpful, unless you are returning random x and y positions. If you are actually getting the position of a mouse click or something of that nature, Swing's MouseListener class (and corresponding tutorial) will be helpful. You should start by just writing a client/server pair where the client can send the server the x and y position. Then add on another client, one by one.

BestJewSinceJC 700 Posting Maven

This is definitely interesting. Before I get into my crazy idea of how to do this (that involves bit stuffing and using a special character to denote the start and end of images) let me make sure I understand the issues. Mixing images and text is never really done in the same file, and I don't think there are any 'standard' ways to do this. Do you plan to read back in the images and Strings properly later? Because if you just start writing them to a file together how will you know which is which? You need some way to denote where an image starts and ends. I hardly think writing both to the same file is your issue - being able to read them back in correctly later is your real problem. Yes/no? And any other more intelligent members here have any suggestions? (Before I go off on a tangent about bit stuffing, because there is probably a much easier way to do this?)

BestJewSinceJC 700 Posting Maven

Why is there so much code in your remove method? All you need to do is search linearly through your array looking for an item with the name that matches the String you're searching for. That should take maybe three lines or so of code.

method remove(string removeMe)
for (every element in the array)
if (current element isEqualTo removeMe)
then remove the current element from the array

BestJewSinceJC 700 Posting Maven

Your error indicates that you attempted to parse an integer at line 128 of your program (which is correct: it says Integer.parseInt(input)). However, the program was unable to parse an int, because your input did not immediately contain an integer. Which means you are reading in the file incorrectly. For example if you say something like Integer.parseInt("This isn't an int!"); it will throw the same exception/error.

hope that helps

BestJewSinceJC 700 Posting Maven

For specific components see here: http://java.sun.com/docs/books/tutorial/uiswing/components/index.html

(for example, if you want to use a button in your app, look there to see how, or if you want to use a table, etc)

BestJewSinceJC 700 Posting Maven

Where is class Phrases code? It will be easier for me to find your mistakes having all your project's code.

Did you even look at his code? The problem is obviously with the way he is reading in the text file.

@OP:

Scanner's next() method reads in input between the delimiter pattern, which by default matches whitespace. In English: when you call next(), it is searching for something that has a space before and after it. Since your text file has things in it like "ahoy there" that contain multiple words, scanner.next() would've only read in ahoy, not ahoy there. Don't you want to read in the whole line? Use scanner.nextLine().

Scanner scanner = null;
		try {
			 scanner = new Scanner(new File("pirate"));
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		int num;
		System.out.println(num = scanner.nextInt());
		scanner.nextLine();
		for(int i=0;i<num; i++){
			System.out.println(scanner.nextLine());
			System.out.println(scanner.nextLine());
		}
BestJewSinceJC 700 Posting Maven

Get help from a professional, in person, with your write up. Here are some tips since I've been through similar processes myself, but I'm not a professional at this, nor are most anyone on daniweb. And if you don't get help from a professional, at least get help from someone who knows good grammar. Bad grammar will cause your write up to be thrown out immediately.

1. Don't give more examples, give better examples. Talking about word processing your work isn't impressive. Get rid of it.
2. Explain all of the extras you have listed briefly. For example, what Ecommerce software? Give a one line description.
3. Some of your statements will only hurt your chances (i.e. "I didn't find their courses too demanding or challenging") it sounds like you didn't get that much out of the course. Talk about how you utilized past courses to improve your skills, if anything. Don't mention them at all otherwise.

donaldw commented: Good advice on resume/mission statement. +1
BestJewSinceJC 700 Posting Maven

SWT was created for faster native widgets - it is faster because it uses the OS's native tools to draw the widgets, essentially. However, Swing should be plenty fast for most any purposes, and I personally prefer it. I also think Swing looks nicer.

P.S. I used SWT at my internship all summer last year and I never had any problems with disposing the objects, so I don't consider that enough reason to use one instead of the other. But again, Swing just looks better, plain and simple.

BestJewSinceJC 700 Posting Maven

I agree that it's getting to be a daft system. Some idiots using it to upset other people. If it's not worth moaning about - if it's not that important - if it's just eye candy - pull the plug.

Down-voting for the sake of it is really sad. If the system is to have any use, an user can check a contributor's rating to see how reliable/popular (etc) their advice/opinions (etc) are. BTW - that would be a bit sad in itself! To my mind, if this is unworkable or unfeasible, pull the mod - it has absolutely no value.

Maybe I misunderstand. But if I was a new member and I didn't know who knew what they were talking about and who didn't, being able to check the user votes percentage might be a pretty useful metric. According to Dani she was trying to create something so people know what thread to click on, but really, it seems to be displayed on the profile as if it was the same thing as 'reputation'. e.g. Rashakil has a pretty horrible vote percentage, but he is very helpful when it comes to many topics. The way it is displayed is misleading.

BestJewSinceJC 700 Posting Maven

I guess, but without some degree of feedback, nothing can ever improve.

BestJewSinceJC 700 Posting Maven

Yeah, I understand how it works. I was saying 50 different members.

Also, jbennet, do you not like sknake? I only ask because I have made more comments about the voting system than he has, but you have replied to my threads much differently than to his.

BestJewSinceJC 700 Posting Maven

It's like when a girl punches you -- it means she loves you. Except I'm not a girl. And I don't love you.

That was like when a comedian makes a funny joke. Except you're not a comedian. And that joke wasn't funny.

Anyway, why not just search my name and down vote every post? Don't be so uncommitted. Why should sknake be any more important than I am? And I don't really know who serkan is or care, so that reference is meaningless to me.

BestJewSinceJC 700 Posting Maven

The system is idiotic. Lets see how low we can get this post guys. -50?

BestJewSinceJC 700 Posting Maven

If you use Java's built in Stack class and Queue class, you can simply call the appropriate methods to add the items on and take them off. For both of them, to add an item on, you probably just use the add method, for stack, to take it off, you probably use pop(), and for queue, it might be called next() or get() or something like that. Just google for the documentation and then read what the method descriptions say. It really is that simple. Although if you don't know what a stack or a queue is, I would recommend building your own. Of course, using the already existing classes is much faster. If you want to learn how to build your own stack and queue, I will help you implement the necessary methods. But if you want to use the easier, preexisting Java classes, then you're on your own because there is already plenty of documentation and examples on the web.

BestJewSinceJC 700 Posting Maven

abccba

if you add each letter in order to the stack and the queue, here is the final stack and queue (in the order they would be popped off)

1. abccba
2. abccba

But looking at something random that isn't a palindrome:

abc

1. cba (stack)
2. abc (queue)

So the idea is that if you add everything to the stack and the queue, then pop off one letter at a time... if the letters are always the same, you have a palindrome, otherwise, you don't. So the first step in your program should be to add everything to both the stack and the queue. And the second step should be to iterate through the lists, making sure the letter popped off the stack is the same as the letter popped off the queue... otherwise, you don't have a palindrome.

Stack is a LIFO data structure and a queue is a FIFO data structure. So a stack is similar to a pile of dishes (last one put on the pile is the first one you pick off the pile to wash) whereas a queue is similar to a line - first one in the line gets to go first - (and in fact, British people call what Americans call a line a queue)

BestJewSinceJC 700 Posting Maven

My question for him is why he couldn't at least thinly veil the obvious COTS "my professor wrote this and then I pasted it on daniweb"... question