Lukasz Jarocki

Greenhorn
+ Follow
since Jan 01, 2013
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
1
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Lukasz Jarocki

Hi, recently I've passed OCAJP 8 and now I study to OCPJP8 exam. Do I need to have extensive knowledge of java.util.Date and java.util.Calendar (etc.)?
What are the pros and cons of taking beta exam instead of regular non-beta exam?
I haven't considered that. Usually people at work follow the rule that property name is the same as instance variable name (in fact Eclipse use this "rule" while auto-generating setters/getters). Good to know that it's not part of convention.

Thanks a lot.
Hi,
I study to the OCA 8 exam and I've noticed strange answer for Question 9 in Chapter 4 (answer on page 343, question on page 220). I think option C is incorrect. As you can see property numberWings has a getter called getNumWings . I am not an expert in JavaBeans conventions, but the book clearly states on page 206, table 4.5 that:

The method name must have a prefix of set/get/is, followed by the first letter of the property in uppercase, followed by the rest of the property name.

. In this example setter should be called getNumberWings to obey the convention. Am I right?

I am sorry if this topic was already mentioned on coderanch, but unfortunately I haven't been able to find it on the forum.
Just put your class here without any unnecessary methods.

EDIT:
For me this code works fine. I removed your unnecessary methods like setOpaque(true), and set HorizontalTextPostion. While a.png is that image then it produces . Button caption is visible.

6 years ago
I have figuered it out.

JFrame must implement ComponentListener and in overridden componentResized method you must put that code:

6 years ago
Hello my dears,

After Saturday (Sheldon Cooper) Laundry Night, Sunday is wonderful day for Java coding. But I have a serious* problem here with SeaGlass UI.

Background:
I need for my next project a little better Look and Feel than that which Java originally provide. I choosed to dive into SeaGlass L&F which seems to be pretty nice. However I encountered the problem. I can't prevent user of app from resizing and maximazing my JFrame. From what I found it is well-known issue in SeaGlass and it will be fixed in 2.1 version (what its stated here). Unfortunately, last available version is 2.0 and it looks like this project is abandoned - last update is one year old.

Question:
While setResizable(false) and setUndecorated(false) don't work at all (no effect), is there any work-around to stop user from resizing my JFrame? We can assume that targeted user of application is newbie to computers so he won't use any hacks and tricks to maximaze it (i.e. using Windows Task Manager). Basically I just need to deal with maximize button at the top of JFrame and manually resize using mouse.

My thoughts revolve around MouseListener or overwriting event fired when something is happening to JFrame.

*I have asked first on stackoverflow (I'm sorry!) and they didin't know answer. Since they are so horny on getting points for answer I assume that question is not easy.
6 years ago
I have similar problem.
I am trying to read some text from .ini file and display it on JOptionPane confirm dialog. Here is the text in .ini file:



I supposed that each part of text will be placed in another line. But I was wrong. Whole string is in single line.


Surprisingly, I receive the same effect when I put string on stdout by System.out.println().
Here is the code:



Of course "sometext" appears in new line on console. How can I fix it?

Edit:
Ok I get it. I should use html.
http://docs.oracle.com/javase/tutorial/uiswing/components/html.html
6 years ago
Well, show some effort, nobody won't write whole code. Just show which part of implemantation is difficult for you.

Basicaly all you need to do (on server side) is:
- create server socket and bind it
- wait for connection (accept method)
- then handle every new connection in new thread:
6 years ago
You need to use Threads and put every communication with client in another thread.
6 years ago
Thank you. It looks like there is some work to do, I just thought there is an easier way. Temporarily I use deprecated method from DataInputStream to read header. So far so good. I'll fix it later.
Thanks for reply. Unfortunately, I must use Sockets instead of built in java.net.HttpURLConnection. Also, I am not sure that you understood my problem.

Once more: I am able to detect beginning of response body. Its not hard. I have problems with mixed data.
As you may know, if client sends GET, server replies with header (text data) and some data (sometimes binary [image] sometimes not [example: js script]).

Assume that I ask server for jpeg image. I use BufferedReader stream

to read header with that code:

But later I have to read bytes. I know Content-Length (how much bytes to read) - its in the header but I can't use BufferedReader because it doesn't have method like readByte() or readFully().
So how can I read them? I've tried to read bytes from buffer by readLine() method and than call getBytes() on returned String but it doesn't work (image downloaded had similiar size to original but was broken). Also I've tried to read whole data with DataInputStream - it has appropriate methods to read bytes but method readLine() in this class is deprecated so I can't read header that way.

My code:


Note that, this code doesn't work - there is an error in line number 29. I can't read data in that way.
Hello,
I am looking for 3 months internships somewhere in Europe (excluding my home country which is Poland). I need to find company before end of January. I participate in Erasmus Internships programme.
I study Information Technology on Poznan University of Technology and my main interests include software development in Java but I am also familiar with many other (sometimes exotic) languages. I speak English and Polish (a little German too). Please do not hesitate to ask questions.

I prefer mail contact: lukasz.jarocki (at) student.put.poznan.pl

6 years ago
Hello,
this is my first post on board as you may noticed.

I have a problem with understanding streams, and how they collaborate with sockets.

I need to implement simple HTTP client in Java. I didnt have any problems with connection, sending requests (GET, DELETE etc.), sending text or reading pure html. But I am stucked on reading bytes from stream.
Assume that my client sending GET to server.


Server response with HTTP header, blank line and html text go on. I am reading that with following code:

It works well.


But imagine that I read server response and I noticed that I need to download external images from server (These days nearly everysite has images). So what I do? Sending GET to server. But what to do next?
I expect that response will contain text (HTTP header) blank line and bytes (image). So how can I read that?

In the end, my question is: how to read from InputStream when I expect that data will be mixed? I know that, servers usually send type of data with Content-type attribute, so its easy to check (by reading HTTP header) what will be send in HTTP body. But I dont know how to mix streams or read mix data.