tigerxx 0 Light Poster

what ever ur if can stand the time it's great.........
somethings we will consider as great just like windows....
but after some time world will ask u wat's dat .if dy havn'y made a mark.
so the difference is between the ability to stand high or not
the only answer is time will proove it
the real judge is time ...................

tigerxx 0 Light Poster

hi friend i am not telling to how to code in java because i m also new to java i am doing my MCA in pune (INDIA) in FIRST SEM i m ne wto this programming :D


i want to know that how to post my quries to every one i read that select forum and click new thread button but i can't saw :cry: any such button

so please HELP ME

we have projrcts in JAVA if u know any project title please tell me it will only for 50 marks and without data base .

plz HELP MI

u can go for a image processing in java

can go in GUI manner

tigerxx 0 Light Poster

hey guys,

I have problem in printing from java

i have used PrinterJob in awt
but it's going mad sometimes . it's going to it's print method
two times

some times doesn't print anything

the code is

=========================================================

import java.awt.print.Printable;
import java.awt.print.Book;
import java.awt.Graphics;
import java.awt.print.PageFormat;
import java.awt.print.PrinterJob;		
import java.io.File;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.io.*;
import javax.print.*;
import java.awt.print.*;
import javax.print.attribute.HashAttributeSet;
import javax.print.attribute.standard.Media;
import javax.print.attribute.standard.MediaSize;
import javax.print.attribute.standard.Copies;
import javax.print.PrintServiceLookup;
import javax.print.attribute.PrintJobAttributeSet;


class PrintStringTest {
	
	
	
	public static void main(String args[]){   
		
		
		int lines = 0;
		int totalLines = 30;
		String str = "bgfgkjdffffffffffffffffffffffffffffffffffffffffdghdfkjgkjdfgkjdfgk"+
		"fdfdsf"+System.getProperty("line.separator")+"dfdsfsssssssssssssss"+
		"fdfdxxxxxxxxsf"+System.getProperty("line.separator")+"dfdsfsssssssssssssss"+
		"fxxxdfdsf"+System.getProperty("line.separator")+"dfdaaaaaaaasssssssssssssssssssss"+
		"fdfxxxxxxxdsf"+System.getProperty("line.separator")+"dfdsfssssssssssssxxxxxxxxxsss";	
				
		PrinterJob job = PrinterJob.getPrinterJob();
		
		PageFormat landscape = job.defaultPage();
		
		System.out.println ("hight"+landscape.getImageableHeight());
		System.out.println ("how many lines"+landscape.getHeight()/10);
		System.out.println ("orientation"+landscape.getOrientation());
		System.out.println ("orientation"+PageFormat.PORTRAIT);		
		String[] array = str.split(System.getProperty("line.separator"));
		
		int linex = (int)landscape.getImageableHeight()/10;
		
		int total = (int)array.length/linex;
		
		System.out.println (total);
		
		test t = new test();
		
		Book book = new Book();
					 
		System.out.println ("length of string"+str.length());			 
		System.out.println (str);
					 
		landscape.setOrientation(PageFormat.PORTRAIT);
		
		StringBuffer strb = new StringBuffer();
		int i = 0;
		
		while(total-- >= 0){
			
			
			strb = new StringBuffer();
			for(lines = 0;lines < linex && lines < array.length ;lines++)
						strb.append( array[lines]+"@");
    		t.setString(strb.toString());
			
			book.append(t,landscape, 1);
			
			System.out.println ("content to print"+t.getString());
//			i+=lines;
			
			
		}
			
		
		System.out.println (book.getNumberOfPages());
		
		job.setPageable(book);
		
		if(job.printDialog()){
			
		
			try {
			
				job.print();
			
			}catch(Exception e){
				e.printStackTrace();
			}
		}
		
		
    
    }		
}

class test implements  Printable{
	
	private String str;
	private boolean isPrinted;
	
	
	public void setString(String str){
		this.str = str;
	}
	
	public String getString(){
		return this.str;
	}
	
	public int print(Graphics g,PageFormat p,int index){
		int count = 0;
		System.out.println("print "+index);
		if(!isPrinted) {
			isPrinted = true;
			return Printable.PAGE_EXISTS; …
tigerxx 0 Light Poster

hey can u paste fulll code ?

tigerxx 0 Light Poster

Can anyone tell me how to get rid of console window? I'm writing a gui program for an assignment... Spoiled by VB... I use the console for troubleshooting while testing or writing code, but would like to make it invisible or close it while sharing with the class. (We run the programs in the JCreator LE compiler in class.)

Thanks

for that u have to make it to a ".exe" file in windows for a standalone
executable application
for that pupose u can user JExpress .it's a great tool.

tigerxx 0 Light Poster

**************************************
Statement statement1 = con.createStatement();
****************************************

here is the problem u hav to give the query inside createStatement()

like

Statement statement1 = con.createStatement(string);

then it'll work

tigerxx 0 Light Poster

hmmm. I think when you name your fields you want to fill like this "<[(myfield1)]>" etc you have a great chance to fill your document without any word interpreter. Only stupid string-replacement. Try it.

Its interessting wether it works for me, too.

Let me know.

Greetings from Germany

Ben

no u misunderstood i wann to create some template and fill
them with correct data ..............

tigerxx 0 Light Poster

Hi everyone,

Can i do this to create a platform independent file

String str1 = "C:\\abc\\efg.exe"
     File file1 = new File(str1);
     String str2 = file1.getCanonicalPath();
     //Now i will the instance of str2 for any file streams

OR THIS

String str1 = "C:\\abc\\efg.exe"
     File file1 = new File(str1);
     String str2 = file1.getAbsolutePath();
     //Now i will the instance of str2 for any file streams

Will what i do create a platform independent file?

By the way

Merry Christmas and a Happy New Year to everyone

Thank You

Yours Sincerely

Richard West

u can use some ppty files to take the location an can configure
on dat about location.

dat's is the only possible way to make platform independent

for ex:. u can take systemroot as root
in windows it may be c:\windows and
in linux it will be "/" based on this u can take the relative path.

tigerxx 0 Light Poster

HI,

How can we print an MS Word document from Java ???
We can print .txt files, but while printing .doc, it gives junk chars in print out when we set
DocFlavor docFlavor = DocFlavor.INPUT_STREAM.AUTOSENSE;

I tried,
1.DocFlavor docFlavor = new DocFlavor("application/msword", "java.io.InputStream");

2. DocFlavor docFlavor = new DocFlavor("application/vnd.ms-word", "java.io.InputStream");

and got PrintJobFlavorException

It would be helpful if any one could help me out..

Thanks in advance..

tigerxx 0 Light Poster

I need to open a word doc template from a java application
and i also need to dynamically update the fields
in the template with some values from the java application..
Can anybody help me????......

Thanks in advance..........

tigerxx 0 Light Poster

Hello all from javaDumb! I'm in my first java class and this is my first post so please be patient. I'm suppose to use StringTokenizer to search a document and replace some text, but the book for this course only explains how to print the text to the screen as tokens. I have created a class called editor with two constructors; one that has no parameters and one that passes one parameter(the document to be searched). I also have methods for getDocument(), setDocument(). This project also calls for two overloaded methods called replace(), one passes (search text, replace text) and the other passes (document, search text, replace text). I don't know how to use these and StringTokenizer together.

Any help would be appreciated.

u can read the whole amount of text in doc together and

pass it to u r fun. ther u can use stringtokenizer to get each string from ur
whole content string and den u can use replace fun of string

tigerxx 0 Light Poster

http://www.devx.com/tips/Tip/13625

thankx

but in Java we can directly asign one object to another

then other case ie; member wise assigning is not comng

am i right ..............

am a bit confused

tigerxx 0 Light Poster

what is shallow copying ?

tigerxx 0 Light Poster

Well what was the point in posting the same code twice when someone else already had?

hav u look at my code
it much simpler than urs

bye eat good and think good

tigerxx 0 Light Poster

Thanx for your help ! I am waiting for your links :)

am avilable at jijoycl@sify.com

u can snd mails
bye

tigerxx 0 Light Poster

I have written source for TCP and UDP servers and clients(and they work), now I need to write a build file, please, please, point me in the right direction. I have no idea what a build file is.

I've been out searching for info on build files and still don't understand. Can some please step me throw the basics. I do not want someone to do this for me, I don't think they could without knowing my source code with any kind of effectiveness, just please point me in the right direction. Give me some basics, or send me to a site with a good explaination.

is it build file for ant or something others

if it is for ant ,(ant is a tool that help u to compile and make a jar file of
ur whole project)

plz reply

i will help u

tigerxx 0 Light Poster

Of course it was easy for you. You basicly copied my code above.

am practising java for more than 4 yrs
i don;t have to copy it from u
man .................

but if u thing ur great genous just keep it in ur mind only

no need to tell./............

tigerxx 0 Light Poster

Hi TigerXX,

But what happens if we use desktop pane??? How should we manage?

u can use it bye

set
this.setContentPane(new JDesktopPane());
remaining everything as i have mentioned like above
thnkx............

tigerxx 0 Light Poster

hey all

what are pros of jdic

ref avilable at java.net

try this...........................

tigerxx 0 Light Poster

Here is how to reverse an inputed string, just apply it all to Int and you should have your program:

class ReverseString

public class ReverseString
{
 public String reverse(String arg)
 {
	String tmp = null;
	if (arg.length() == 1)
	{
		return arg;
	}
	
	else
	{
		

		//extract the last char
		String lastChar = arg.substring(arg.length()-1,arg.length());
		
		
		//extract the remaining chars
		String remainingString = arg.substring(0, arg.length() -1);

		tmp = lastChar + reverse(remainingString);
		return tmp;
		
		
	}
  }
}

class TestReverse

import java.io.*;


public class TestReverse
{
	public static void main(String[] args) throws IOException
 	{
		System.out.println("Enter a line to be reversed");
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String inData;
		inData = br.readLine();
		ReverseString rs = new ReverseString();
		System.out.println("Reversed: " + rs.reverse(inData));	
	}
}

plz don't do like this..................
they should do the hw themselvs

tigerxx 0 Light Poster

do u know somthing abt java
or using this forum for hw
.............................................

tigerxx 0 Light Poster

hi everyone,
can anyone solve me the code for the java problem.

i need a java programthat holds twenty integers in an array, loop though each cell sequentially and prints each number on the console.
thank you very much.

shantuli

tht's very easy

class Test{
    public static void main(String args[]){
        int[] arr = new int[20];
        for(int j=0;j<20;j++){
            arr[j]=j;
        }
        for(int i=0;i<arr.length;i++){            
            System.out.println(arr[i]);
        }
    }
}

arr is array containing 20 integers
this will print first 20 from 0 to 19
this will do the job

tigerxx 0 Light Poster

hi all

Can anyone tell me wat is Synthetic field in Java

if possible send me links also

thankx in advance

tigerxx 0 Light Poster

hi mmr

i have a piece of code for u

/************************************************/
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

class Test extends JFrame implements ActionListener {

JInternalFrame f1 = new JInternalFrame("Frame1");
JInternalFrame f2 = new JInternalFrame("Frame2");
Container cont;
JButton jBtn  = new JButton("Click");
    public Test(){
        cont = this.getContentPane();
        cont.setLayout(new FlowLayout());
        cont.add(f1);
        cont.add(f2);
        Container co = f1.getContentPane();
        co.setLayout(new FlowLayout());
        co.add(jBtn);
        f1.setVisible(true);
        f1.setBounds(0,0,100,100);
        f2.setVisible(false);
        f2.setBounds(100,100,50,50);
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        setBounds(0,0,400,400);
        setVisible(true);
        jBtn.addActionListener(this);
    }
    public void actionPerformed(ActionEvent ae){
        if(ae.getSource()==jBtn){
            cont.add(f2);
            f2.setVisible(true);
            cont.add(new JLabel("Second Frame is Visible NOW"));
        }
    }
    public static void main(String args[]){
        new Test();
    }


}
/***************************************************/

try this code and send me reply
i think this is ur requirement
if not plz be more specific
best luck
plz be feel free to ask qstns
bye

tigerxx 0 Light Poster

then u should be adding the button to the container of the 1st internal frame
and in the actionperfromed of the button please add the code i
specified.

tigerxx 0 Light Poster

Thank you guys so far for your input. I did the suggested changes and I am getting 2 error messages, : char cannot be dereferenced
if (accttype.equalsIgnoreCase("d")) as well as for if(accttype.equalsIgnoreCase("w")).

And yes this is an input/output program.

The program is supposed to ask the user for the checking account balance, amount to witdrawl or deposit and when the user finally hits "B" for balance then it is supposed to give an output of the transaction, amount and balance.

u can just use if(accttype=='B') or not
no need of equalIgnorCase

tigerxx 0 Light Poster

Hi All,

I am working with Internal Frames. I used JDesktopPane and added 2 frames to it. I made one frame visible and the other was setVisible(false). This happens when I first run the program(Only first frame appearing). Now, what I want is to make the second frame visible, when I click a button on the first frame. Can you please help me out.

Thank you

u just add it to container of(ie,desktop pane) main frame ie;window of ur app and make it setVisible(true)
so
wer u r buton is now in main frame or in first internal frame?
if it's in main frame
i think cod will be like this
********************************************
JFrame a= new JFrame("Main Window");
JInternalFrame f1 = new JInternalFrame();
JInternalFrame f2 = new JInternalFrame();
a.setContentPane(desktopPane);
Container c = getContentPane();
now
c.add(f1);
c.add(f2);
c.add(btn)
now add actionlistener for btn
f1.setVisible(true);
f2.setVisible(false);
now in action performed of btn
add

f2.setVisible(true);
************************************
if btn in first frame the whole thing will change
please sepecify that also
if u want pls snd mails to jijoy18@yahoo.com
pls feel free to ask qstns.

tigerxx 0 Light Poster

Ok i have gotten stuck on this program and I need help

This program is supposed to calculate the balance of a
checking account after the user has entered
the type of action (withdrawl, deposit)
they would like to do.

My output should be a report that prints the beginning balance, the action (deposit or withdrawl), the amount and the ending balance.

Thank You Guys In Advance.

public class CheckingAcct
{
   public static void main (String [] args)

   {
     double balance;
     double amount;
     char accttype;





     System.out.print("Enter checking account balance:  ");
     balance = Input.readDouble ();
     balance=0;
     System.out.print("Enter account type D=Deposit, W=Withdrawl or    B=Balance to end");
     accttype = Input.readChar ();

     if (accttype.equalsIgnoreCase("d"))
     {
        System.out.print("Enter deposit amount: ");
        amount = Input.readDouble ();
        balance = balance + amount;
     }
     else if (accttype.equalsIgnoreCase("w"))
     {
        System.out.print("Enter withdrawl amount: ");
        amount = Input.readDouble ();
        balance = balance + amount;
        System.out.println(balance + accttype + amount + balance);
     }
     else
     {
        System.out.print(+balance + accttype + amount + balance);
     }

   } //end main
} // end class CheckingAcct

first thing u hav to do is not to assign the value of balance to 0 after reading
it from input.
Since amount and balance are same type (double) the system.out. will calculate their sum and will display if u want them seperate seperate the +
with +","+. and after withdrawl the balance is decresed so
in withdrawl balance=balance-amount
if u just displaying this or wnat to have validations wether …

tigerxx 0 Light Poster

Hey there,

I'm new to java and I need to write a string that i generated in my code to an output file. I'm currently writing the string to the standard output like so :

System.out.println("K_"+Receiver+",t"+msgnum+"(R("
+Receiver+",t"+msgnum+"("+out1+")))");

All the types e.g. 'Receiver' or 'out1' are of type string. Could anyone show me how to open a file for writing and then write this information to the file? Is there some sort of file writer equivalent for system.out.println()? Thanks very much

u can use PrintStream out = new PrintStream(new OutputStream(new FileOutputStream(new File("Name of ur file"))));
now u can use same line for wrting into file
like this
out.println("K_"+Receiver+",t"+msgnum+"(R("
+Receiver+",t"+msgnum+"("+out1+")))");

it will write to the file don't forgot to import import java.io.*;
if any doubts please revert

tigerxx 0 Light Poster

hey please avoid the lazy procedural
always use oops
any way use BufferedReader br = BufferedReader (new InputStreamReader(new FileInputStream (new File("your file name"))))
and
use
String str=new String();
while((str=br.readLine())!=null){
System.out.println(str);
}
it will print the whole file
any more clarifications please write

}

tigerxx 0 Light Poster

Hi thanx for your guidance !
but that is some how complex to understant for someone like me for the first time :o
I want to know if you have got sample of this code ! or any thing like that !
thanx :)
E-mail : nazanin_dnr@yahoo.com

sorry for the gap in reply
actually then way i tell is very easy u have to just use a class for defining all the acess privilages and read from there
ok i 'll try to send some coe snipplets for this

tigerxx 0 Light Poster

Hello,

Please send me the equivalent code for the following
i.e the Database connecting code is written for MS Acess

I want to know for Oracle.


Class.forName("jdbc:odbc:dsnName");

Connection con=DriverManager.getConnection("jdbc.odbc.JdbcOdbcDriver","","");


can we use the same code(The above given) to connect to SQL Server.

With warm regards,
Azmat

u can either give the dsn name as in case of sql server or can give the ip address + port no of ur db server and then try to connect

tigerxx 0 Light Poster

I am a postgraduate student and I have exams in java language..I have some problems with 3 programs.Can anybody solve them for me?Can I send them to someone who loves Java?

ask ...........

free to ask.............

tigerxx 0 Light Poster

Hi :)
thanx for your comments , but you have been misunderstanded!
I want to give different privilleges to different users :)

- Nazanin

that's easy
u can define each user's access rights in some constants
and can store in backend along with his user id
while one tries to do a function u can chek if he have the right do it

tigerxx 0 Light Poster

Hi everyone
I have written an applcation and now its the step that I want to make user authorization !
but I don't know any thing about it !
if anyone knows please introduce me some articles or please guides me !
thanx for your help

If u want it in great looking industrial standard way
u can give him a logon screen
wen he submits u can check to ur backend storage and if avialable
proceed else can show err msg
u can have stoarge at first for purpose of studying can use files and later can
move to dbs.In java u can have both these provisions easily
but if u keep user's details until his sessions that 'll be better because
if ur app have more than one modules and a normal user will not have acess to all.that'll be great :lol: