Mike DeStefano

Ranch Hand
+ Follow
since May 24, 2002
Merit badge: grant badges
For More
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 Mike DeStefano

OMG!!! It worked!!! Praise Zeus and the Java Gods! To think disabling scrolling on UP and DOWN keyboard events was that easy! GGGGEEEEEEZZZZ!!!

Thanks very much!
18 years ago
EXCELLENT! Thank you both for sharing examples of this. I will take a look in detail at the code today...

FYI - I am looking to prevent both the JScrollPane and JTextArea from scrolling on keyboard events. I only want scrolling on mouse events.

Mike DeStefano
18 years ago
I have an uneditable JTextArea embedded within a JScrollPane. Is there any way to remove the caret in the JTextArea document so that UP and DOWN don't move the document.

Thanks in advance..
18 years ago
I have an application in which I put a JTextArea into a JScrollPane. I want to disable the scrolling when UP or DOWN is pressed (aka only scroll using the mouse). However I try to do it, I cannot seem to stop keyboard events from scrolling the text in the text area.

Below is some sample test code. Please help - already spent a week trying to figure it out as you'll see by all the things I've tried to do to stop keyboard events from scrolling the text area.

Thanks in advance for your help,
Mike DeStefano

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.plaf.basic.*;

public class TestFrame extends JFrame {

protected Container contentPane;

public TestFrame() {
super("TestFrame");

contentPane = getContentPane();
contentPane.setLayout(new BorderLayout());

setupConsolePanel();

pack();
setVisible(true);
}

public void setupConsolePanel() {
JLabel label = new JLabel("Test Text Area With Scrolling -");

MyTextArea myTextArea = new MyTextArea(5,40);
myTextArea.setMargin(new Insets(5,5,5,5));
myTextArea.setEditable(false);
myTextArea.setUI(new MyTextAreaUI());
myTextArea.unregisterKeyboardAction(KeyStroke.getKeyStroke(KeyEvent.VK_UP,0));

JScrollPane myScrollPane = new JScrollPane(myTextArea);
myScrollPane.setUI(new MyScrollPaneUI());
myScrollPane.unregisterKeyboardAction(KeyStroke.getKeyStroke(KeyEvent.VK_UP,0));
myScrollPane.getVerticalScrollBar().setUI(new MyScrollBarUI());
myScrollPane.getVerticalScrollBar().unregisterKeyboardAction(KeyStroke.getKeyStroke(KeyEvent.VK_UP,0));
myScrollPane.getHorizontalScrollBar().setUI(new MyScrollBarUI());
myScrollPane.getHorizontalScrollBar().unregisterKeyboardAction(KeyStroke.getKeyStroke(KeyEvent.VK_UP,0));
myScrollPane.getViewport().setUI(new MyViewportUI());
myScrollPane.getViewport().unregisterKeyboardAction(KeyStroke.getKeyStroke(KeyEvent.VK_UP,0));

JPanel myPanel = new JPanel(new BorderLayout(5,5));
myPanel.add(label, BorderLayout.NORTH);
myPanel.add(myScrollPane, BorderLayout.CENTER);
myPanel.unregisterKeyboardAction(KeyStroke.getKeyStroke(KeyEvent.VK_UP,0));

contentPane.add(myPanel, BorderLayout.SOUTH);

//TESTING TESTING TESTING:

myTextArea.println("testing");
myTextArea.println("testing");
myTextArea.println("testing");
myTextArea.println("testing");
myTextArea.println("testing");
myTextArea.println("testing");
myTextArea.println("testing");
myTextArea.println("testing");
myTextArea.println("testing");
}

public static void main(String[] args) {
JFrame frame = new TestFrame();
}
}


//*****************************************************************
//*****************************************************************
//*****************************************************************

class MyTextArea extends JTextArea {

public MyTextArea() {}

public MyTextArea(int rows, int cols) {
super(rows, cols);
}

public void println(Object o) {
append(o.toString() + "\n");
setCaretPosition(getText().length());
}

public void print(Object o) {
append(o.toString());
setCaretPosition(getText().length());
}

public void println(Object o, boolean setPos) {
append(o.toString() + "\n");
if (setPos) {
setCaretPosition(getText().length());
}
}

public void print(Object o, boolean setPos) {
append(o.toString());
if (setPos) {
setCaretPosition(getText().length());
}
}
}


//*****************************************************************
//*****************************************************************
//*****************************************************************

class MyTextAreaUI extends BasicTextAreaUI {
public MyTextAreaUI() {}
protected void installKeyboardActions() {}
}


//*****************************************************************
//*****************************************************************
//*****************************************************************

class MyScrollPaneUI extends BasicScrollPaneUI {
public MyScrollPaneUI() {}
protected void installKeyboardActions() {}
}

//*****************************************************************
//*****************************************************************
//*****************************************************************

class MyScrollBarUI extends BasicScrollBarUI {
public MyScrollBarUI() {}
protected void installKeyboardActions() {}
}

//*****************************************************************
//*****************************************************************
//*****************************************************************

class MyViewportUI extends BasicViewportUI {
public MyViewportUI() {}
protected void installKeyboardActions() {}
}
18 years ago
Whether you declare it formally by saying

new String("blah blah blah")

or by saying

x = "blah blah blah"

This is the same thing. Java did this for convenience.

String is referenced by address and is not like and int or double (that is, not a primitive)... char is a primitive. String is simply an array of chars for the most part.
19 years ago
Riddle me this - Why is it when the executed code below produces the unexpected results also below?

Code -
double dblTest = 1.00;
while (dblTest > 0) {
System.out.println("dblTest = " + dblTest);
dblTest -= .05;
}

Results -
dblTest = 1.0
dblTest = 0.95
dblTest = 0.8999999999999999
dblTest = 0.8499999999999999
dblTest = 0.7999999999999998
dblTest = 0.7499999999999998
dblTest = 0.6999999999999997
dblTest = 0.6499999999999997
dblTest = 0.5999999999999996
dblTest = 0.5499999999999996
dblTest = 0.4999999999999996
dblTest = 0.4499999999999996
dblTest = 0.39999999999999963
dblTest = 0.34999999999999964
dblTest = 0.29999999999999966
dblTest = 0.24999999999999967
dblTest = 0.19999999999999968
dblTest = 0.1499999999999997
dblTest = 0.09999999999999969
dblTest = 0.049999999999999684

How do I fix this?

Thanks in advance,
- Mike
19 years ago
Riddle me this - Why is it when the executed code below produces the unexpected results also below?

Code -
double dblTest = 1.00;
while (dblTest > 0) {
System.out.println("dblTest = " + dblTest);
dblTest -= .05;
}

Results -
dblTest = 1.0
dblTest = 0.95
dblTest = 0.8999999999999999
dblTest = 0.8499999999999999
dblTest = 0.7999999999999998
dblTest = 0.7499999999999998
dblTest = 0.6999999999999997
dblTest = 0.6499999999999997
dblTest = 0.5999999999999996
dblTest = 0.5499999999999996
dblTest = 0.4999999999999996
dblTest = 0.4499999999999996
dblTest = 0.39999999999999963
dblTest = 0.34999999999999964
dblTest = 0.29999999999999966
dblTest = 0.24999999999999967
dblTest = 0.19999999999999968
dblTest = 0.1499999999999997
dblTest = 0.09999999999999969
dblTest = 0.049999999999999684

How do I fix this?

Thanks in advance,
- Mike
19 years ago
In my previous posting, the directory structure didn't post correct. Let me repost...

I have several webapp directories under the main "webapps" folder of resin 3.0.9. I cannot seem to get automatic class reloading to work. Can someone explain how to configure resin to automatically reload classes under various webapps. My directory structure is as follows -

resin-3.0.9
|---webapps
....|---ROOT
....|...|---WEB-INF
....|.......|---classes
....|---myApp1
....|...|---WEB-INF
....|.......|---classes
....|---myApp2
....|...|---WEB-INF
....|.......|classes


How do I get the resin class loader to automattically reload classes in myApp1/WEB-INF/classes and myApp2/WEB-INF/classes?

I'm baffled.

Thanks for your support,
- Mike
19 years ago
I have several webapp directories under the main "webapps" folder of resin 3.0.9. I cannot seem to get automatic class reloading to work. Can someone explain how to configure resin to automatically reload classes under various webapps. My directory structure is as follows -

resin-3.0.9
webapps
ROOT
WEB-INF
classes
myApp1
WEB-INF
classes
myApp2
WEB-INF
classes


How do I get the resin class loader to automattically reload classes in myApp1/WEB-INF/classes and myApp2/WEB-INF/classes?

I'm baffled.

Thanks for your support,
- Mike
19 years ago
I downloaded JDAVMail in send emails through my hotmail account from JAVAMail.. I put the jar file in my classpath along with the javamail, commons-httpclient, and commons-logging jar... I ran the TestSend class provided in the "readme.txt" file of the JAVMail download and got a NoSuchProviderException.

I realize that JAVAMail is looking for the providers on a javamail.providers file. And the JDAVMail jar file has one in it under the META-INF directory. So why won't javamail find the providers that come with the jdavmail jar?

Thanks in advance,
- Mike
19 years ago
I've tried response.flushBuffer() along with printWriter.flush()... Any other ideas? It won't flush the buffer to the client. Does anyone have any familiarity with this problem in Websphere 3.5?
19 years ago
When I get the Object from response.getWriter(), I use the flush() method... Is there another method I didn't see called flushBuffer() that I should be using?
19 years ago
I have an application where I wish to write a line of text to the output stream and then flush it to the client. On websphere 0S/390 webserver, it seems that it won't flush. Instead, it waits until the servlet finishes running.

I've tried using both the response.getOutputStream and response.getWriter Objects to do this and no success. I've sen tried setBufferSize(0), but no luck...

Any ideas to get the toilet to flush would be great! Any plumbers out there?

Thanks in advance,
- Mike
19 years ago
Thanks big-big! 1.5 fixed it. You da man!
19 years ago