Win a copy of OCP Java SE 8 Programmer II Exam Study Guide this week in the OCP forum!

Rajesh Nair

Greenhorn
+ Follow
since Aug 22, 2001
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
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Rajesh Nair

hi all,
i have developed a stand alone application using JFC.As the last step i need to generate a licence code for the software.Can anybody give me some suggestions for doing this.
Thnx in Advance
Rajesh Nair
16 years ago
hi all,
i have developed a database application using
JFC and MS Access.If i am keeping the application as idle
for long time ( >half hour) the connection becomes
automatically slow and thus performance dicreases.
can any body help me please by giving some sugestion to
solve this.
Thanx in Advance
Rajesh
Hi all,
Can anybody tell me how to print java graphics in PDF or DOC format instead of printing on Printer
Thanks in Advance
Rajesh
16 years ago
Hi all,
Can anybody tell me how to impose the Mouse click event on
using keyboard..
My requirement is to have the population effect (I meant the effect which we r having while clicking
on the combobox using mouse) by using Keyboard , after focussing to the particular Combo box.But the important thing to note is combo box is inside a JTable Cell.
Please respond , if any part of the question is not clear..
Thankx in advance
Rajesh
16 years ago
Hi all,
I was trying to create a small browser window , by doing some modifications in the coding i have got from some site.But the program is showing an IOException in the coding part which is shown as bold and it could not connect with the URL specified.
I am using DSL connection and i am working through proxy server.
If it is the problem , How can i specify the Proxy Server IPAddress in the program ??
Thanx in Advance
Rajesh
import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;
import java.net.*;
import java.io.*;
/** Very simplistic "Web browser" using Swing. Supply a URL on the
* command line to see it initially, and to set the destination
* of the "home" button.mn
* 1998 Marty Hall, http://www.apl.jhu.edu/~hall/java/
*/
public class Browser extends JFrame implements HyperlinkListener,
ActionListener {
public static void main(String[] args) {
if (args.length == 0)
new Browser("http://www.apl.jhu.edu/~hall/");
else
new Browser(args[0]);
}
private JIconButton homeButton;
private JTextField urlField;
private JEditorPane htmlPane;
private String initialURL;
public Browser(String initialURL) {
super("Simple Swing Browser");
this.initialURL = initialURL;
//addWindowListener(new ExitListener());
//WindowUtilities.setNativeLookAndFeel();
JPanel topPanel = new JPanel();
topPanel.setBackground(Color.lightGray);
homeButton = new JIconButton("home.gif");
homeButton.addActionListener(this);
JLabel urlLabel = new JLabel("URL:");
urlField = new JTextField(30);
urlField.setText(initialURL);
urlField.addActionListener(this);
topPanel.add(homeButton);
topPanel.add(urlLabel);
topPanel.add(urlField);
getContentPane().add(topPanel, BorderLayout.NORTH);
try {
htmlPane = new JEditorPane(initialURL);
htmlPane.setEditable(false);
htmlPane.addHyperlinkListener(this);
JScrollPane scrollPane = new JScrollPane(htmlPane);
getContentPane().add(scrollPane, BorderLayout.CENTER);
} catch(IOException ioe) {
warnUser("Can't build HTML pane for " + initialURL
+ ": " + ioe);
}
Dimension screenSize = getToolkit().getScreenSize();
int width = screenSize.width * 8 / 10;
int height = screenSize.height * 8 / 10;
setBounds(width/8, height/8, width, height);
setVisible(true);
}

public void actionPerformed(ActionEvent event) {
String url;
if (event.getSource() == urlField)
url = urlField.getText();
else // Clicked "home" button instead of entering URL
url = initialURL;
try {
htmlPane.setPage(new URL(url));
urlField.setText(url);
} catch(IOException ioe) {
warnUser("Can't follow link to " + url + ": " + ioe);
}
}
public void hyperlinkUpdate(HyperlinkEvent event) {
if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
try {
htmlPane.setPage(event.getURL());
urlField.setText(event.getURL().toExternalForm());
} catch(IOException ioe) {
warnUser("Can't follow link to "
+ event.getURL().toExternalForm() + ": " + ioe);
}
}
}

private void warnUser(String message) {
JOptionPane.showMessageDialog(this, message, "Error",
JOptionPane.ERROR_MESSAGE);
}
}

class JIconButton extends JButton {
public JIconButton(String file) {
super(new ImageIcon(file));
setContentAreaFilled(false);
setBorderPainted(false);
setFocusPainted(false);
}
}

[This message has been edited by Rajesh Nair (edited August 29, 2001).]
16 years ago
Hi all,
Can anybody point out , how is it possible to restrict the user from moving the TableColumns using mouse inside a JTable ..
Thanx in Advance
Rajesh
16 years ago
Carl Trusiak,
Thanks a lot..
I got the result by using the following code.
Please let me know whether this method of coding will
show any problems in future while i am using it for copying a mdb file with lakhs of records.
Rajesh Nair
CopyBin.java
------------
import java.io.*;
public class CopyBin {
public static final String IN_FILE = "C:\\check\\test.mdb";
public static final String OUT_FILE = "d:\\trials\\copy.mdb";
public static void main( String[] args ){
int binaryByte;
BufferedInputStream bufferIn;
BufferedOutputStream bufferOut;
try {
bufferIn = new BufferedInputStream(
new FileInputStream(IN_FILE) );
} catch ( IOException ioErr ){
System.out.println( "Error accessing input file: " + IN_FILE );
return;
}
try {
bufferOut = new BufferedOutputStream(
new FileOutputStream(OUT_FILE) );
} catch ( IOException ioErr ){
System.out.println( "Error accessing output file: " + OUT_FILE );
return;
}
try {
binaryByte = bufferIn.read();
while( binaryByte >= 0 ){
bufferOut.write( binaryByte );
binaryByte = bufferIn.read();
}
} catch (IOException ioErr ){
System.out.println( "Error copying file" );
}
try {
bufferOut.close();
bufferIn.close();
} catch (IOException ioErr ){
System.out.println( "Error closing files" );
}
}
}

16 years ago
hi all,
i have been trying to take the back-up of a MS Access Database file by using the coding listed below.The Coding
is working well and i am getting a
new mdb file.But while trying to
open the file , it shows some error
( as wrong format file ).Can anybody suggest a solution
for this problem or any other better option for taking
database backup.
Thanx in Advance
Rajesh Nair

Transcriber.java
----------------
import java.io.*;
public class Transcriber
{
public static final String IN_FILE = "C:\\check\\test.mdb";
public static final String OUT_FILE = "d:\\trials\\copy.mdb";
private BufferedReader br;
private FileReader fr;
private BufferedWriter bw;
private FileWriter fw;
public static void main( String[] args )
{
Transcriber t = new Transcriber();
t.transcribe();
}
private void transcribe()
{
String inLine = null;
String outLine = null;
try
{
fr = new FileReader( IN_FILE );
br = new BufferedReader( fr );
fw = new FileWriter( OUT_FILE );
bw = new BufferedWriter( fw );
while ( ( inLine = br.readLine() ) != null )
{
// This line could be anything, but here
// I just copy the line.
outLine = inLine;
bw.write( outLine, 0, outLine.length() );
bw.newLine();
}
bw.close();
br.close();
}
catch ( FileNotFoundException e )
{
e.printStackTrace();
}
catch ( IOException e )
{
e.printStackTrace();
}
}
}
16 years ago
Hi all,
In Java how can I make it possible to copy a file from
my local system to a Network drive or vice versa.
Thanx in Advance
Rajesh Nair

16 years ago