| newbie question: processing large database in chunks? |
|
 |
Index ‹ java-programmer
|
- Previous
- 1
- ResourceBundle with Database BackendHi all,
We're busy creating a web application that needs different localization.
ResourceBundles would probably be the best thing to use for this. However,
we would like to use a database as the backend for the ResourceBundle.
This would make changing and adding translated strings much easier. We
would like our client to be able to do this himself, using a front end we
will write.
From what I understand of ResourceBundles, we would have to create a
ResourceBundle class for each translation. We'd like to create just one
subclass of ResourceBundle however, which handles all translations. Is
this possible? I can't find any examples of how this should work..
thanks for thinking along, please tell me if my question isn't completely
clear or something like that,
Ilja Booij
MMS2P B.V.
- 1
- 2
- Problem was javax.comm.ParallelPort 's getOutputStream() -ed objects write() method. HERE goes ANSWERTo all, who tryed to send tada to Parallel port using javax.comm api.
I had the same problem at home when I wrote program.
Then I went to my working place and tested my program, - the problem
remained - program hanged forever after sending bytes to parallel port.
I had tryed almost everything at home, so the way could be only one -
PRINTER and SO THAT WAS ENDEED!!!
I turned printer on and bytes went away :) program worked fine!
So, as we could see Windows platforms (and maybe others too) block all
outgoing signals to the ports from where OS does not get or receive the
signal that means the port is alive (=something is connected to that
port).
That was one more good lesson for me.
If this helped somebody, let me know.
Tengo
----------
Who is looking for something, that will find it.
- 3
- extends DefaultTableModel ???Hi
I have an exception of the line "return content.size();" in
getRowCount(), it said the vector content is null. But if i extends
the AbstractTableModel rather than DefaultTableModel, no exception,
please tell me why?
thanks
from Peter
public class MyTableModel extends DefaultTableModel {
String columnNames[] = {"1", "2", "3", "4", "5"};
Vector content=new Vector();
public MyTableModel() {
}
public int getColumnCount() {
return columnNames.length;
}
public String getColumnName(int col) {
return columnNames[col];
}
public Object getValueAt(int row, int column) {
"Peter"
}
public int getRowCount() {
return content.size();
}
}
- 4
- Jedit: Error about MouseWheelListenerI installed the same Jedit archive on Windows and on HP-UX (with
JavaVM-1.3). On
Windows, it runs fine. On Unix, I get the following error message on
startup:
java.lang.NoClassDefFoundError: java/awt/event/MouseWheelListener
Could it be that something is missing in my CLASSPATH? Where is the
MouseWheelListener
supposed to be? I thought this class was added in 1.4, but note that
the
installation notes for JEdit say that it can run under Unix with Java
1.3.
Ronald
- 5
- Exception NumberFormatException when creating an instance of JFileChooserHi,
I getting a NumberFormatException executing the following code:
JFileChooser fc = new JFileChooser();
The following line is called in my code in
...
ReadFileFrame.<init>() line: 23
...
Yes, it is simple JFileChooser instance... I'm using JDK 1_5, Swing in
a XP Pro machine and the only thing that I can remember that have been
changed in my environment was a Windows Update.
Based in the stack, I believe that something is broken in the way that
Java is getting some Windows UI data.
The stack:
Thread [AWT-EventQueue-0] (Suspended (exception NumberFormatException))
Integer.parseInt(String, int) line: 447
Integer.parseInt(String) line: 497
Win32ShellFolderManager2.get(String) line: 234
ShellFolder.get(String) line: 221
WindowsLookAndFeel$LazyWindowsIcon.createValue(UIDefaults) line: 1876
UIDefaults.getFromHashtable(Object) line: 183
UIDefaults.get(Object) line: 128
MultiUIDefaults.get(Object) line: 44
MultiUIDefaults(UIDefaults).getIcon(Object) line: 409
UIManager.getIcon(Object) line: 613
WindowsFileChooserUI(BasicFileChooserUI).installIcons(JFileChooser)
line: 237
WindowsFileChooserUI(BasicFileChooserUI).installDefaults(JFileChooser)
line: 219
WindowsFileChooserUI(BasicFileChooserUI).installUI(JComponent) line:
135
WindowsFileChooserUI.installUI(JComponent) line: 140
JFileChooser(JComponent).setUI(ComponentUI) line: 650
JFileChooser.updateUI() line: 1755
JFileChooser.setup(FileSystemView) line: 366
JFileChooser.<init>(File, FileSystemView) line: 332
JFileChooser.<init>() line: 285
ReadFileFrame.<init>() line: 23
DecAid.readFile() line: 1086
DecAid.access$1(DecAid) line: 1059
DecAid$ActionListenerAdapter.actionPerformed(ActionEvent) line: 2532
JMenuItem(AbstractButton).fireActionPerformed(ActionEvent) line: 1849
AbstractButton$Handler.actionPerformed(ActionEvent) line: 2169
DefaultButtonModel.fireActionPerformed(ActionEvent) line: 420
DefaultButtonModel.setPressed(boolean) line: 258
JMenuItem(AbstractButton).doClick(int) line: 302
WindowsMenuItemUI(BasicMenuItemUI).doClick(MenuSelectionManager) line:
1000
BasicMenuItemUI$Handler.mouseReleased(MouseEvent) line: 1041
JMenuItem(Component).processMouseEvent(MouseEvent) line: 5488
JMenuItem(JComponent).processMouseEvent(MouseEvent) line: 3093
JMenuItem(Component).processEvent(AWTEvent) line: 5253
JMenuItem(Container).processEvent(AWTEvent) line: 1966
JMenuItem(Component).dispatchEventImpl(AWTEvent) line: 3955
JMenuItem(Container).dispatchEventImpl(AWTEvent) line: 2024
JMenuItem(Component).dispatchEvent(AWTEvent) line: 3803
LightweightDispatcher.retargetMouseEvent(Component, int, MouseEvent)
line: 4212
LightweightDispatcher.processMouseEvent(MouseEvent) line: 3892
LightweightDispatcher.dispatchEvent(AWTEvent) line: 3822
JFrame(Container).dispatchEventImpl(AWTEvent) line: 2010
JFrame(Window).dispatchEventImpl(AWTEvent) line: 1766
JFrame(Component).dispatchEvent(AWTEvent) line: 3803
EventQueue.dispatchEvent(AWTEvent) line: 463
EventDispatchThread.pumpOneEventForHierarchy(int, Component) line: 234
EventDispatchThread.pumpEventsForHierarchy(int, Conditional,
Component) line: 163
EventDispatchThread.pumpEvents(int, Conditional) line: 157
EventDispatchThread.pumpEvents(Conditional) line: 149
EventDispatchThread.run() line: 110
- 6
- MIDP 1.0: Filled rectanglesHello!
I'm beginning to develop a 3D game for J2ME mobile phones. The obvious
problem is, how to draw filled triangles. I know that in MIDP 2.0 this
can be done easily, and Nokia has an extension to MIDP 1.0 which
allows to draw filled polygons. Now the problem is how to do it in
plain MIDP 1.0 (say, on a Motorola T720 or SonyEricsson T610). I
thought of two solutions:
* Use two or three fillArc() invocations. Each of them would paint an
arc which has a center in one triangle vertex. The arcs can be scaled
so that they cover the whole triangle and never paint outside the
triangle. Or perhaps even one arc can be used which approximates the
triangle well, especially when it's small.
* Divide the triangle into horizontal and vertical lines and draw them
using drawLine().
The second method requires (or at least appears to require) more code,
and uses much more drawing operations than the first, so it seems to
be slower. But on the other hands, perhaps scaling the arc and
painting it would be much time-consuming?
If you have any experience or insight about this problem, I'd be very
grateful.
Regards,
Michau.
- 6
- Help needed, rotation behaviors with java3DHi, I've been trying for weeks to solve a problem, hope someone out
there can assist me. I am a beginner with java3d.
Problem:
How do i attach a flat cylinder (line) between two spheres, whilest
both spheres are rotating around thier own axis and orbiting
(rotating) around the center of the universe with different rotation
(alpha)interval?
Pls. all suggestions are welcome. Time is runing out and i'm about to
miss my deadline./Sheena
- 6
- Unexpected Signal : 11 occurred at PC=0x2845BB2FHi ,
Just reporting this core dump from my web application
Regards
Samuel Jackson
----------------------------------------------
root@ds226# more hs_err_pid77432.log
Unexpected Signal : 11 occurred at PC=3D0x2845BB2F
Function=3Dfollow_stack__9MarkSweep+0x3F
Library=3D/jdk1.4.2/jre/lib/i386/client/libjvm.so
Dynamic libraries:
0x8048000 /usr/local/jdk1.4.2/bin/java
0x2806c000 /usr/local/lib/libc_r.so.4
0x28123000 /jdk1.4.2/jre/lib/i386/client/libjvm.so
0x2866a000 /usr/local/lib/libstdc++.so.3
0x286af000 /usr/local/lib/libm.so.2
0x286ca000 /jdk1.4.2/jre/lib/i386/native_threads/libhpi.so
0x286d8000 /jdk1.4.2/jre/lib/i386/libverify.so
0x286f3000 /jdk1.4.2/jre/lib/i386/libjava.so
0x28714000 /jdk1.4.2/jre/lib/i386/libzip.so
0x34fb2000 /jdk1.4.2/jre/lib/i386/libnet.so
0x2804e000 /usr/libexec/ld-elf.so.1
Heap at VM Abort:
Heap
def new generation total 2304K, used 256K [0x2c5b0000, 0x2c830000, =
0x2ca90000)
eden space 2048K, 0% used [0x2c5b0000, 0x2c5b0000, 0x2c7b0000)
from space 256K, 100% used [0x2c7f0000, 0x2c830000, 0x2c830000)
to space 256K, 0% used [0x2c7b0000, 0x2c7b0000, 0x2c7f0000)
tenured generation total 31080K, used 30993K [0x2ca90000, 0x2e8ea000, =
0x305b0000)
the space 31080K, 99% used [0x2ca90000, 0x2e8d4488, 0x2e8d4600, =
0x2e8ea000)
compacting perm gen total 14336K, used 14218K [0x305b0000, 0x313b0000, =
0x345b0000)
the space 14336K, 99% used [0x305b0000, 0x31392af8, 0x31392c00, =
0x313b0000)
Local Time =3D Sat Nov 27 13:30:41 2004
Elapsed Time =3D 63665
#
# HotSpot Virtual Machine Error : 11
# Error ID : 4F530E43505002F1
# Please report this error to
# email***@***.com mailing list
#
# Java VM: Java HotSpot(TM) Client VM (1.4.2-p6-root_19_aug_2004_10_42 =
mixed mode)
#
_______________________________________________
email***@***.com mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-java
To unsubscribe, send any mail to "email***@***.com"
- 6
- window basis..Jep!
I think i need a good tutorial here,
would please receive few links, in need to get familiar with window opening,
sizening and drawing images on it..
Yours : JariTapio
Homepage : www.EuroJari.net
EMail : email***@***.com
- 11
- Immutable text area idiom?Andrew Thompson wrote:
> (sighs) You can lead a horse to water.. ;-)
(I lied.)
Look, I understand your points, and they are good ones. Boiled down,
they are essentially "Don't try to outsmart the look and feel; it knows
what it's doing." With this I agree entirely.
This is not a look and feel issue, however. I don't have a problem with
the way that a given component is being rendered in a particular look
and feel. I don't have a problem with look and feel implementations
period. I have a problem with exactly what components I should use to
represent particular information.
I have never seen a property sheet that displays information about a
live object somewhere that uses /disabled/ components to show "enabled"
information. Non-editable components? Sure. But that's different. If
a component is disabled, that means you aren't really supposed to look
at it, or it is not applicable in some other way. Those are NOT the
semantics I wish my UI in this case to convey. I wish simply to convey
that X is the current value for property Y, and nothing else.
Again, I thank you for your obviously hard work on this subject.
Cheers,
Laird
- 12
- deploying multiple instances of same application (.war file) on tomcat 5.5We have a web application running on tomcat 5.5 that works fine when
deployed independently. However, we would like to deploy multiple
instances of the same application on the same server. We have built a
new war file of the same application with a different name including a
new context file for the application. This new war file also runs fine
independently but, when deployed along with the original application,
generates a Java Heap Space error.
Is there a special way to deploy multiple instances of the same
application on the same server using Tomcat?
Please help us! Thank you!!!
- 12
- [?] Struts looses authenticate informations ?Hi,
I'm trying to make my first struts application and I'm fighting with
authentication and roles.
I've only one jsp page (index.jsp) that prints authentication type ("BASIC")
and user roles.
<%
authentication+="Authentication " + request.getAuthType();
if (request.isUserInRole("ADMIN")) { role += "ADMIN; " ; }
if (request.isUserInRole("USER")) { role += "USER; " ; }
%>
<br>----------------------------------------------------
<br><%= authentication %>
<br><%= "ROLES : " + role %>
<br>----------------------------------------------------
<br>
Then there's an empty form with a "submit" button.
<html:form action="/index">
<html:submit value="SUBMIT" />
</html:form>
the execute method in action is the following :
public ActionForward execute(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws Exception {
String forward = "index";
return mapping.findForward(forward);
}
When I enter my application the first time it shows exactly authentication
BASIC and ROLES : ADMIN
but when I press "submit" it shows "authentication NULL" and "ROLES : "
I'm using tomcat 4.1.18 (I also tried .24 and .27 !) and struts 1.1
WHERE' S THE ERROR ??
Thanks
---
- 14
- Java is a third class language.Hi Mark Thornton,
Re: Windows' GDI for easily writing to any raster device
using essentially the same code,
regardless of the printer or the screen.
You asserted,
" Not only does it work well ( in Java )
it also supports some features ( e.g. anti-aliasing )
which may not be available on the OS. "
Even if that were true ( and I highly doubt it ),
Java still couldn't do it with out the OS.
Java Overlays an OS, it doesn't replace it.
Java is a third class language.
No one would use it if they didn't have other options.
- 15
- Secure FTP API for Java ReleasedMyJavaWorld.com is pleased to announce the release of Secure FTP API
for Java, an API that allows you to add secure file transfer
capabilities to your Java applications. Some of the features of Secure
FTP API for Java are:
Complete implementation of the File Transfer Protocol as defined RFC
959
Support for secure file transfer using SSL/TLS as defined in RFC 2228.
Both Explicit and Implicit SSL connections are supported.
Extendable architecture to support legacy/non-standard FTP servers
Event notification to notify the connection and transfer evens to
interested objects.
Support for active and passive data transfers
Support for ASCII and Binary data types
Set the time outs and buffer size to use for the control and data
connections
And many more...
Check it out at http://www.myjavaworld.com
Regards
Sai Pullabhotla
|
| Author |
Message |
cerios

|
Posted: 2006-1-24 14:09:00 |
Top |
java-programmer, newbie question: processing large database in chunks?
Hi,
When I
select * from XX
I'm geting an OutOfMemoryError. I'm using JDBC with Mysql,
and calls like:
ResultSet rs = dbc.executeQuery("select * from thetable");
My beginner's question: what's the right way to read and process the
table in chunks, to avoid running out of memory?
Is using LIMIT n1,n2 inside the query the right thing to do, giving
e.g. LIMIT 1,100 followed by another query using LIMIT 101,200, etc?
Is there a more efficient way?
I guess I'm surprised that it's even necessary. I would have thought
that the data would stay on the server until pulled to the client
by resultset.next() and a resultset.getXX(). But evidently
the whole table is being sent to the client??
|
| |
|
| |
 |
Boris Stumm

|
Posted: 2006-1-24 16:47:00 |
Top |
java-programmer >> newbie question: processing large database in chunks?
cerios wrote:
> My beginner's question: what's the right way to read and process the
> table in chunks, to avoid running out of memory?
What do you want to do exactly?
> I guess I'm surprised that it's even necessary. I would have thought
> that the data would stay on the server until pulled to the client
> by resultset.next() and a resultset.getXX(). But evidently
> the whole table is being sent to the client??
Depends probably on the JDBC driver.
|
| |
|
| |
 |
Mladen Adamovic

|
Posted: 2006-1-25 0:37:00 |
Top |
java-programmer >> newbie question: processing large database in chunks?
cerios wrote:
> When I
> select * from XX
> I'm geting an OutOfMemoryError. I'm using JDBC with Mysql,
> and calls like:
> ResultSet rs = dbc.executeQuery("select * from thetable");
Try to add JVM parametar -Xmx1000m
It suggest JVM to use 1GB heap for data.
Initial heap is to small (8 MB)
If your table is more than 1GB large you definitly shouldn't use select
* statement without where clause due to performance problem.
--
Mladen Adamovic
http://home.blic.net/adamm
|
| |
|
| |
 |
Alun Harford

|
Posted: 2006-2-4 6:31:00 |
Top |
java-programmer >> newbie question: processing large database in chunks?
"cerios" <email***@***.com> wrote in message
news:230120062209110097%email***@***.com...
>
> Hi,
>
> When I
> select * from XX
> I'm geting an OutOfMemoryError. I'm using JDBC with Mysql,
> and calls like:
>
> ResultSet rs = dbc.executeQuery("select * from thetable");
>
Have a look at java.sql.Statement.setFetchSize(int size)
Alun Harford
|
| |
|
| |
 |
| |
 |
Index ‹ java-programmer |
- Next
- 1
- pasting images from excel with transparency have a black backgroundHi There,
I've searched on this topic, but have only found an unanswered post
from 2003. Basically, if I copy a chart from excel (well, from a
number of vector based packages it seems) that has transparency, the
resulting image in java has had the transparency replaced with black.
However, if you paste the chart into word, select it and then copy it,
it will paste into java with no problems.
I've searched the java bug database, but have had not luck.
To repeat this, simply create a chart in excel, set it's background to
fill:none and copy the chart. Then run the class below and press the
button.
I am running Office 2002 and using Sun JDK 1.5.07
Any help much appreciated on this as it's driving me nuts.
Thanks,
Brian
=============================================================
import java.awt.*;
import java.awt.datatransfer.*;
import java.awt.event.*;
import javax.swing.*;
public class ClipboardTest
{
public static void main(String[] args)
{
try
{
JFrame frame = new JFrame();
frame.setLayout(new BorderLayout());
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
final JLabel label = new JLabel();
label.setPreferredSize(new Dimension(200, 200));
frame.add(label, BorderLayout.CENTER);
JButton button = new JButton("Get Clipboard");
button.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
try
{
Transferable xfer =
Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null);
label.setIcon(new
ImageIcon((Image)xfer.getTransferData(DataFlavor.imageFlavor)));
}
catch (Exception ex) {}
}
});
frame.add(button, BorderLayout.SOUTH);
frame.pack();
frame.setVisible(true);
}
catch (Exception e){}
}
}
- 2
- 3
- a question about uploading files...I'm using jakarta.commons.FileUplaod to upload a file and it's working
fine (followed what I read in
http://www.onjava.com/pub/a/onjava/2003/06/25/commons.html?page=3)
only thing I would like to know is, is it possible to upload more than
one file at a time? (I mean is it possible to write code so in "choose
file" dialog you can select more than one file?)
I asked in jakarta.commons listserv (gmane.comp.jakarta.commons.user)
about two days ago, but well, still haven't gotten response (and am not
even sure whether this is strictly a jakarta.commons.FileUpload question
or a general java question..) thank you.. Frances
- 4
- Using JMF to build rtsp serverHi, I'd like to know if it's possible to create a server application
that transmits a .rm file through rtsp. I've seen some examples using
AVI and other standard formats, but I'm not sure if this is possible.
Basically what I need is a server which waits for connections and
transmit a .rm file to it. Of course I could use Helix, but I need
something for free. In any case, is there any free alternative?
TIA.
- 5
- Including a folder's JAR files in CLASSPATHI have a folder C:\DevPrograms\Hibernate\lib which has 33 JAR files. I want
to include them in my CLASSPATH but not hardcoding the name of the jar
files; instead i want some thing like C:\DevPrograms\Hibernate\lib\*.jar so
that it can pick up all jar. I tried doing it but no success. What other
ways I can do it?
Thanks
- 6
- Interesting Java interview questionA friend of mine likes to ask this question when interviewing Java
developers. Thought I'd pass it along because it's sort of interesting.
Why does the following compile, and what does the output look like?
System.out.println(new Object(){{{}}}.toString());
He says he has asked this question of several dozen people, and almost
everyone just stares at it in shock. Only one has answered it
correctly. I wish I had his resume...
dleifker
- 7
- annoying eclipse automatisms (resource copying)I really like Eclipse as Java editing platform, but now I want to do
the following:
I have a directory with not only self-written Java sources but also
some non-Java source files (namely parser/lexer constructed in
CUP/JLex). From this, I generate Java sources which land in the same
directory. Now when I build this directory from Eclipse it persists in
copying my non-Java sources to the output directory. While this
doesn't exactly cause any malfunction, it does disturb my cleanly
nature ;)
What options would you suggest to keep the structure clean? I think
setting up yet another directory for the CUP/JLex sources would be
rather impractical.
Thanks,
Justin
- 8
- 9
- Controlling XML elements orderHi I'm returning an XML to my clients (SOAP). Now I want to order the
items in my XML (I dont want my clients to sort it) is there any API
in DOM that I can use for sorting the elements some way ? or simply
preserving the sort order of that that I added items to the DOM tree?
(I'm adding the items in a sorted way however when I look at the XML
generated its not sorted)
- 10
- questions about the implications of multiple JFrames using dispose() on closingHi
I've come up against some perplexing questions caused by the creation
of multiple instances of JFrame.
obj is referencing a JButton click. This then loads a FileDialog for
opening an image and displaying it in an extended JFrame called
'ResizeFrame'. JFrame then loads a panel which displays the Image. The
code as it stands allows multiple instances of ResizeFrame.
ResizeFrame basically does most of the work and calls methods to load
the Image - which has been opened in it - to be drawn in ResizePanel.
ResizeFrame is coded to 'dispose' on closing.
What I am trying to understand is what happens when a frame is opened,
then closed, and then a new frame is opened. Does the instance of
ResizeFrame (all named the same) that was initially opened, still
exist, or has it been over-written by the new version.
Am I making a mistake allowing several JFrames to be opened at once? I
know that when a frame is disposed that its claims on screen resourses
are freed up - but if it is still existing even after it has been
disposed it must still be using some memory resources?
Also, what are the implications of having several objects existing with
the same name?
Another thing I've noticed. My ResizeFrame has a method for loading a
panel and then is made visible within ResizeFrame. What I've noticed is
that if I load a ResizeFrame Image, then close it, then open up the
same image file - that the picture will appear much faster than if I
open up a different image. I'm not understanding how this is happening!
I could change my code so that it is only possible to have 1
ResizeFrame open at a time - however this would require a considerable
amount of simplification (i.e. beyond my hackish skills!). I would only
do it if I am convinced that the way I have done things is BAD with a
capital B (which it probably is - but then I am a very inexperienced
programmer).
Thanks for any advice.
Michael
//-----------------------------
if (obj == newdepth) {
File f = loadimage("depth\\", FileDialog.LOAD);
if (!(f == null)) {
File q = new File(f.getParent());
if (q.isDirectory()) {
String w = f.getPath();
p.LoadPic(w);
ResizeFrame jeff = new ResizeFrame((w + " - Depth Map"), new
Color(205, 219, 227), false);
jeff.LoadPic(w);
jeff.addpanel();
}
else {
status.setText("invalid directory");
}
}
}
//--------------------------------
//--I've included the full code for ResizeFrame and ResizePanel hoping
for constructive critism. Also, it might help to make my questions
clearer.
//-----------ResizeFrame----------
import java.awt.*;
import javax.swing.*;
import myroot.frames.*;
import java.awt.event.*;
import java.io.*;
import java.awt.image.*;
import osbaldeston.image.BMP;
public class ResizeFrame extends JFrame implements ImageObserver {
public Image myimage;
public ResizePanel mypanel;
public Color col;
public boolean resizing;
public void LoadPic(String inpic){
myimage = null;
int typepic = getTypePic(inpic);
if (typepic == 1) {
BMP dave = new BMP(new File(inpic));
myimage = dave.getImage();
}
if (typepic == 2) {
myimage = Toolkit.getDefaultToolkit().getImage ( inpic);
}
WaitImage(myimage);
}
public int getTypePic(String in) {
if (in.length() > 4) {
String test = in.substring(in.length() - 4, in.length());
test = test.toLowerCase();
if (test.equals(".bmp")) return 1;
if (test.equals(".gif")|| test.equals(".png") ||
test.equals(".jpg") || test.equals("jpeg")) return 2;
}
return 0;
}
public void WaitImage(Image im) {
boolean wait = true;
wait = ImageUtilities.waitForImage(im, this);
}
public void addpanel() {
if (resizing == true)
setExtendedState(Frame.MAXIMIZED_BOTH);
mypanel = new ResizePanel(myimage, col);
JScrollPane scroller = new JScrollPane(mypanel,
//JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
scroller.getVerticalScrollBar().setUnitIncrement( 16 );
getContentPane().add(scroller);
if (resizing == false) {
int w;
int h;
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
if ((myimage.getWidth(this) +40) > d.width)
w = d.width;
else
w = myimage.getWidth(this) + 40;
if ((myimage.getHeight(this) +60) > (d.height -30))
h = d.height -30;
else
h = myimage.getHeight(this) + 60;
setSize(w,h);
}
setVisible(true);
//mypanel.repaint();
}
public void setSize(){
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
setSize(d.width, d.height);
}
public ResizeFrame(String title, Color c, boolean res) {
super(title);
resizing = res;
col = c;
if (resizing == true) {
setSize();
}
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE );
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
dispose();
}
});
}
}
//-------------------------
//---------ResizePanel--------
import java.awt.*;
import javax.swing.*;
import java.awt.image.*;
public class ResizePanel extends JPanel{
public Image myimage;
public Color col;
public ResizePanel(Image im, Color c) {
myimage = im;
col = c;
repaint();
}
public Dimension getPreferredSize(){
return (new Dimension(myimage.getWidth(this),
myimage.getHeight(this)));
}
public void paint(Graphics g) {
int h =0, v = 0;
h = (this.getWidth()-myimage.getWidth(this))/2;
v = (this.getHeight()-myimage.getHeight(this))/2;
if (h< 0)
h = 0;
if (v<0) v = 0;
g.setColor(col);
g.fillRect(0,0,this.getWidth(),this.getHeight());
g.drawImage(myimage, h,v, this);
}
}
//--------------------------
- 11
- J2EE Log File Monitoring SolutionI would like to build/use a J2EE solution to run on WebLogic 8.1 that will
monitor certain log files, extract data based on certain rules, and to
display them on a webpage.
The solution would probably have a front-end (JSPs/servlet(s)) that
communicates with one or more Servlets to specify the what data needs to be
extracted, and then the front-end would format this.
For example, I may be monitoring the log file from my application server
which may contain Java stack traces, and I may be interested in a particular
exception that occurred. In this case, I would want the front-end to tell me
when the error occurred, and possibly allow me to drill down to see the
relevant section of the log file.
In another case, I would be monitoring an XML file, and I would want to
extract certain bits of information from it, but with the option to extend
the monitoring system to display more pieces of information. I.e. today, I
may be interested in XML elements X,Y and Z, but tomorrow, the format of the
XML may change, and I would want to be able to adjust my front-end to deal
with this.
There will probably be no more than 10 log files being monitored, each of
which will not be more than 50MB. Usually, they will be more around the
1-10MB size. As mentioned, the monitoring system will need to run on
WebLogic 8.1, so any J2EE 1.4 or WebLogic 8.1-specific libraries can be
used.
Can anyone suggest some architectural approaches that could be used to
achieve this? Pointers to tools, libraries etc. would also be useful.
Thanks.
C3
- 12
- video lectures on C, C++, Java and other programming and Computer science.Hi Friends,
Check here http://freevideolectures.com/computerscience.html for
video lectures on Programming languages like C, C++, Java, COBOL
etc.., OS, Algorithms, Data Structures, RDBMS,
Web designing, etc..........
It also has amazing collection of video lectures and animations on all
Engineering and Medical Sciences. I am sure you will be surprised to
see such great collection.
Do you like it???
- 13
- what did i install wrong?Ive been working on a space invaders game at school, i took it home today,
and tried installing jcreator, upon execution of my game class i got this
error.
http://www.geocities.com/xpirimint/cs3/error.JPG
any help would be apreciated
- 14
- SimpleDateFormat problemHi, I'm beating my head against this with no avail.
Can someone tell me why this fails? The parsed date's getTime() has some
extra highorder bits set.
DateFormat df = new SimpleDateFormat("mm:ss:SSS");
String s = df.format(new Date(500));
assertTrue(df.parse(s).equals(new Date(500)));
Thanks!
- 15
- How do I finding the current static type?Dear Java Gurus,
I need to find out what the static type (a.k.a. compile time type) of
a given object is at runtime[1]. What I want to achieve is this:
public interface ClassA { public void f(); }
public interface ClassB extends ClassA {}
ClassA classA;
ClassB classB = new ClassBImpl();
classA = classB;
classB.f(); // does something
classA.f(); // does something else
classB and classA are referencing the exact same object and on this
object f() is called but they should not do the same since the static
types are different (ClassA for classA and ClassB for classB).
So, ClassBImpl should look something like:
public class ClassBImpl implements ClassB {
public void f() {
if (
static type in caller of this
is proper subtype of ClassA
) {
//do something
} else {
//do something else
}
}
}
I'm sure you're wondering now why the heck he wants to do something
stupid like that. The reason is that I'm working on a Eiffel to Java
compiler at the moment and there are situations where the f() from
ClassA denotes a completely different method as the f() in ClassB,
they just have the same signature. I can't convince Java that they are
not the same and Java does therefore always bind dynamically to the
most recent implementation which may be the wrong one in some cases.
I'm thinking about this problem like for two weeks now and I'm
completely stuck. You'll make my month if you have any idea how to
solve it no matter how far fetched the idea may be.
Thanks for your time,
Benno
[1] I know, objects do not have a static type, what I mean is the type
of the last variable that was referencing that object.
|
|
|