473,385 Members | 1,740 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Displaying images

12
first i am sorry if my english is not that good,
i have a little question. i have begun to teech myself Java just few monthes ago and i have a little problem...
how can i print chickweeds on the screen? i mean how can i let the user who uses my application trace the number of the chickweeds that he wants to print on the screen (and than the computer would print them for him)???

thanks alot!
mike
Sep 17 '07 #1
10 1306
JosAH
11,448 Expert 8TB
first i am sorry if my english is not that good,
i have a little question. i have begun to teech myself Java just few monthes ago and i have a little problem...
how can i print chickweeds on the screen? i mean how can i let the user who uses my application trace the number of the chickweeds that he wants to print on the screen (and than the computer would print them for him)???

thanks alot!
mike
Your English vocabulary is way better than mine: I didn't even know what
'chickweed' was, I had to look it up. Do you want to show their image on the
screen? Have you looked at the Icon and JLabel classes?

kind regards,

Jos
Sep 17 '07 #2
mike131
12
Your English vocabulary is way better than mine: I didn't even know what
'chickweed' was, I had to look it up. Do you want to show their image on the
screen? Have you looked at the Icon and JLabel classes?

kind regards,

Jos
hoo hii!
thanks alot (for your quick asnwer)...
well i havnt looked there yet, and mmm yes i mean to show their picture on the screen i belive that for the picture itself i just need to use "*"... but the problem is how can the user trace their amount??
i thought that i can use a loop, (for loop):

bla bla bla bla...... // The lines before my main example LOL
int amount;
amount = info.nextInt();
for (i=0;i<amount;i++)
{
System.out.print("*");
}
am i wrong??

actually i "came" from the Macromedia/Adobe "flash world", so my ActionScript is perfect but Java is annoing!! (LOL :))
Sep 17 '07 #3
mike131
12
hoo hii!
thanks alot (for your quick asnwer)...
well i havnt looked there yet, and mmm yes i mean to show their picture on the screen i belive that for the picture itself i just need to use "*"... but the problem is how can the user trace their amount??
i thought that i can use a loop, (for loop):

bla bla bla bla...... // The lines before my main example LOL
int amount;
amount = info.nextInt();
for (i=0;i<amount;i++)
{
System.out.print("*");
}
am i wrong??

actually i "came" from the Macromedia/Adobe "flash world", so my ActionScript is perfect but Java is annoing!! (LOL :))
oh my god! it's alive!!!!!!!!
can i write here the final script??
Sep 17 '07 #4
r035198x
13,262 8TB
oh my god! it's alive!!!!!!!!
can i write here the final script??
Of course you can if you want. Just try to wrap the code in code tags when you do so.

P.S Changed the thread title.
Sep 18 '07 #5
mike131
12
hye everyone...
well,here is one of my first Java applications:

Expand|Select|Wrap|Line Numbers
  1. import java.util.Scanner;
  2. public class Card
  3. {
  4. public static void main(String[] args)
  5. {
  6.     Scanner info = new Scanner(System.in); 
  7.     int i; 
  8.     int amount; 
  9.     String name; 
  10.     String nameLast; 
  11.     int phone; 
  12.     String adress; 
  13.     int adressNum; 
  14.  
  15.     System.out.println("please insert your first name");
  16.     name = info.next(); 
  17.  
  18.     System.out.println("please insert your last name");
  19.     nameLast = info.next(); 
  20.  
  21.     System.out.println("please insert your phone number");
  22.     phone = info.nextInt(); 
  23.  
  24.     System.out.println("please insert your adress");
  25.     adress = info.next(); 
  26.  
  27.     System.out.println("please insert the number of your house");
  28.     adressNum = info.nextInt(); 
  29.  
  30.     String nameAndLast = "My name is: " + name + " " + nameLast;
  31.     int nameAndLastName = nameAndLast.length(); 
  32.  
  33.     System.out.println(nameAndLast);
  34.     System.out.println("phone number: " + phone);
  35.     System.out.println("Adress: " + adress + " " + adressNum);
  36.  
  37.     amount = nameAndLastName + 3; 
  38.  
  39.  
  40.     for(i=0;i<amount;i++)
  41.     {
  42.     System.out.print("*");
  43.     }
  44.  
  45. }
  46. }  
do you have suggestion for making this clumsy script shorter??

thanks alot!
mike
Sep 18 '07 #6
JosAH
11,448 Expert 8TB
Does it work? Did you try to compile and run it?

kind regards,

Jos
Sep 18 '07 #7
mike131
12
ohh yes! i forgot to say :)
it works perfectly!
Sep 18 '07 #8
r035198x
13,262 8TB
You can start by declaring variables closest to where they are used.
Why do
Expand|Select|Wrap|Line Numbers
  1. String name; 
  2. ....
  3. name = info.next(); 
When you can simply do

Expand|Select|Wrap|Line Numbers
  1. String name = info.next(); 
That "declare all variables first" is only required in C. In Java you can declare variables as and when you need them.
That should make the code considerably shorter.
Sep 18 '07 #9
JosAH
11,448 Expert 8TB
Also, instead of cramming everything in one single method think of separate
methods that do just one single task, i.e. instead of the statement combination
for prompting the user for something:

Expand|Select|Wrap|Line Numbers
  1. System.out.println("please insert your first name");
  2. name = info.next(); 
  3.  
Think of something like this:

Expand|Select|Wrap|Line Numbers
  1. String prompt(Scanner scanner, String prompt) {
  2.    System.out.println(prompt);
  3.    return scanner.next();
  4. }
  5. ...
  6. name= prompt(info, "please insert your first name");
  7.  
This won't necessarily reduce the line count of your code but it certainly structures
the functionality of it all quite a bit more.

kind regards,

Jos
Sep 18 '07 #10
mike131
12
thank you all!
i have never seen so supporting guys like you before!
Sep 18 '07 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: Ian Davies | last post by:
Hello Im having problems displaying my images as thumbnails in a table. My code for producing the new width and height from the original image is as follows...
2
by: Woodmon | last post by:
I'm observing issue with linked images not displaying in either Firefox 1.5b2 or IE6 when running on Win XP (they display fine in either browser on W2k). Example problem HTML is: <a...
3
by: Dalan | last post by:
At first I was not certain what could cause Access 97 from displaying most jpeg images, but not all. After further testing, it seemed that all original images of less than 275 pixels per inch or...
1
by: tshad | last post by:
Is there some reason why the Hyperlink in a DataGrid will not show an image? I have a datagrid with the following: <asp:TemplateColumn visible="false" HeaderText="Skills"> <itemtemplate>...
1
by: David Lozzi | last post by:
Hello, I'm wondering whats the best method to use for displaying several photos' thumbnails. One method I know is to dynamically resize the photo at the time the page is loaded. What does this...
10
by: gnewsgroup | last post by:
I've googled and tried various approaches, but could not resolve this problem. The article at MSDN: Displaying Images in a GridView Column only presents a simple case where all data (including the...
5
by: Tom | last post by:
VS 2003/C# Have a axWebBrowser control that will not render images. Originally our app was just launching IE7 to display an HTML page. The bitmap images were not displaying - path was correct...
4
by: redpears007 | last post by:
Hi Again, Throwing this one out to you again as i am not getting anywhere and can find little to no information out there. I am currently displaying images (Jpegs) in access via the routine...
7
by: Sonasang | last post by:
Hi , I am creating a web page in ASP. I will place some images in the folder, The images placed in the folder should be disaplayed. I am having the two button in the web page if I click next...
1
by: littlealex | last post by:
IE6 not displaying text correctly - IE 7 & Firefox 3 are fine! Need some help with this as fairly new to CSS! In IE6 the text for the following page doesn't display properly - rather than being...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.