 |
 |
Index ‹ java-programmer
|
- Previous
- 1
- 4
- How to add a button next to title at the JTabbedPaneHi,
I want to add a small button next to the title of each tabbed pane and
receive user's mouse click event at the small button.
And finally, the selected pane will be removed.
How to add other object, button, into Title part of JTabbedPane ?
Any ideas?
- 6
- OutOfMemoryError - Any Way to Exit JVM?Hi all,
We're having a major problem keeping Java calculators (that were
written by a third party vendor) alive. They leak memory and
eventually cause OutOfMemoryErrors. We cannot address the problem
directly until the vendor does, so we need to manage these dying
calculators.
Unfortunately, they are all started in separate processes and an
OutOfMemory error seems to kill *only* the thread, NOT the JVM. Is
there a way to ensure that the JVM dies as well?
My real hope is that some JVM has a command line option to kill the
whole thing when it has an allocation error. Otherwise, perhaps we can
add another thread to the process that watches it, but that's harder.
Any help would be greatly appreciated.
Thanks,
Steve Lieberman
- 6
- Refusing TCP connections - ServerSocketI want to create a ServerSocket.
I want it to accept one connection.
If another connection request comes in, I want it to be refused, not queued.
Even if I set backlog to 1, on the OS I'm testing on (Linux) I'm able to
queue up a bunch more connections (5 or 6).
I know the actual backlog size is OS dependent even if I explicitly set it
in the ServerSocket constructor.
So, how do I refuse all subsequent connections after I accept that first one?
--
Steve Sobol, Victorville, CA PGP:0xE3AE35ED www.SteveSobol.com
Geek-for-hire. Details: http://www.linkedin.com/in/stevesobol
- 7
- JBoss e eccezioni...Ciao a tutti, ho un problema con JBoss! Ogni volta che entra in errore
la mia applicazione, JBoss s'impalla e rimango in pending 10 minuti
prima che mi lanci fuori un eccezione. Avete idea se ci sono variabili
da settare perch?non rimanga cos?tanto in attesa? Grazie.
- 8
- Finding path of running classFile currentDir = new File(System.getProperty("user.dir"));
I need to know the path to a class that is running and have had
partial success. The code shown above finds the folder where the JVM
is running.
If I start my app from a terminal window or a native executable IDE,
the JVM will run in the folder where my class is located and
currentDir points to the folder that I need. But if I start the app
from an IDE written in Java, I get the folder where the IDE is located
rather than the folder where the app that I was running is located.
My app will be used in a classroom setting by people who will NOT have
command prompt permissions. They will have to run it from an IDE.
I'd really like to stick with the one that we're currently using
(written in Java).
Apparently, both the IDE and my application are running in the same
JVM. Is there any way to get the application to run in its own JVM so
user.dir points to that folder?
If not, any other suggestions?
TIA
tom
- 8
- cannot call a paint function across classes?Just wondering if this is possible, as im having no luck working it out, no
matter what ive tried so far..
I have 2 classes, lets call them gP and kP. in gP ive got this function:
public void paint55(java.awt.Graphics graphics) {
Dimension d=getSize();
graphics.setColor(Color.RED);
graphics.fillRect(0, 0, (int)d.getWidth(), (int)d.getHeight());
graphics.setColor(Color.BLACK);
//call another function here
}
now, in the kP class, im using a jComboBox, the combo box works fine, but i
want to try and call that function from it
Ive tried
gP.paint55();
ive tried referencing it as gP paint55();
Just cant work it out, any ideas?
Thanks
- 9
- junit test in eclipse
code from some tutorial
---------
import junit.framework.TestCase;
public class SampleTest extends TestCase {
...
}
---------
code from another tutorial
---------
import org.junit.*;
import static org.junit.Assert.*;
public class SampleTest {
...
}
---------
Second one is working well. I think second one is simpler, so I like it.
But I can't use them with TestSuite.
"
The method addTest(Test) in the type TestSuite is not applicable for the
arguments
(Class<ArmorTypeWrapperTest>)
"
---------
import junit.framework.Test;
import junit.framework.TestSuite;
public class AllTests {
public static Test suite() {
TestSuite suite = new TestSuite("Test for vanguard.wardrobe");
//$JUnit-BEGIN$
suite.addTest(ArmorTypeTest.class);
suite.addTest(ArmorTypeWrapperTest.class);
//$JUnit-END$
return suite;
}
}
---------
Thank you
Sean
- 9
- iulivarzariuda.. invites you to Going.comHey! Check out this cool new site Going.com. They'll keep you posted
on What's Happening and Who's Going around town.
- Be in the know about fun events, concerts, parties and see who's
going.
- Keep up with your friends and share what you are up to.
- Get invited to exclusive Going.com sponsored special events.
I figured you would want in on it too. Check it out at:
http://going.com/join_me/SsPiUUVYFC
iulivarzariuda..
This email was sent by the person in the from line and the subject
line. Please email them directly if you have any questions.
Going is compliant with the Can-Spam Act of 2003. For more
information, read our privacy policy at
http://going.com/privacy_policy.php.
Going, Inc - 8 Winter Street, Boston, MA 02108, USA
email***@***.com
- 9
- Any good GUI design/prototyper tools?I'm looking for a tool that will let me quickly design/prototype Swing
GUI layouts so I can get screenshots for review by end users. The
emphasis is on design, not building as such - I'm not interested in
*using* any generated code at this stage, although the tool needs to
be able to save and load layouts, and preview the layouts.
What is really required is something that works like a drawing program
but with Swing components. Ideally it would:
o Allow absolute positioning and sizing, because at this stage I'm
essentially doing graphic design and don't want to be worrying about
implementation of layout managers
o Allow easy moving and alignment of elements or groups of elements
o Have a Property Editor, but with configuration of defaults so that I
don't have to, for example, change the font on every element.
o Have a quick build/preview so I can get screenshots easily.
I have looked at a few IDEs and GUI builder tools, but so far nothing
seems really orientated towards making this particular task quick and
easy. Does anyone know of anything that's appropriate... or should I
be thinking about coding something myself?
- 9
- How to get you Extenal/Real IP (Router)Hi All,
I am writing a code as a Java Application (not Applet or Servlet) and I
am trying to find out what is my real IP address (not 192.168. one). I
am behind my LinkSys router and everything I try I still get 192.168.
I have tried:
- InetAddress: Always returns 192.168 address (unless I am missing
something).
- Open Socket to www.cnn.com,80 and read local address (still 192.168).
- I am reading about Upnp but not sure if that's the way I can ask my
Router about my real IP.
- Calling http://www.whatismyip.com and parse the result seems too
strange.
Any idea?
Thanks in advance,
Homer
- 10
- sending raw data to a printer driverIn Windows I have some win32 code that I use in VC++ programs to send
raw data to the printer driver. I would like to do the same thing in
Java; does anyone know how to do this. Specifically, I need to send
printer codes or language commands to a printer. Specifically in the
case I am trying to write is to be a able to send command codes to an
Intermec barcode printer through a text file which has IPL (Intermec
Printer Language) code in it. It is just text, but it instructs the
printer what to do. Of course the printer code is not restricted to
just printer codes. If I could figure out how to send raw data to the
printer driver, this would help a lot.
Z.K.
- 10
- 16
- close() of active socket does not work on FreeBSD 6On Wednesday 13 December 2006 04:49, Daniel Eischen wrote:
> On Tue, 12 Dec 2006, Poul-Henning Kamp wrote:
> > In message <email***@***.com>, Bruce Evans writes:
> >> On Mon, 11 Dec 2006, Daniel Eischen wrote:
> >>
> >> It's probably a nightmare in the kernel too. close() starts looking
> >> like revoke(), and revoke() has large problems and bugs in this area.
> >
> > There is the distinctive difference that revoke() operates on a name
> > and close() on a filedescriptor, but otherwise I agree.
>
> Well, if threads waiting on IO are interruptable by signals,
> can't we make a new signal that's only used by the kernel
> and send it to all threads waiting on IO for that descriptor?
> When it gets out to actually setup the signal handler, it
> just resumes like it is returning from an SA_RESTART signal
> handler (which according to another posting would reissue
> the IO command and get EBADF).
Stop using signal, it is slow for threaded process, first you don't
know which threads are using the descriptor, second, you have
to run long code path in kernel signal code to find and deliver
the signals to all interested threads, that is too expensive for
benchmark like apache benchmark.
David Xu
_______________________________________________
email***@***.com mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-java
To unsubscribe, send any mail to "email***@***.com"
- 16
- Positioning scrollable dataI have pasted a bare bones program below which demonstrates the
problem I am trying to solve.
I have a JTextArea on a JScrollPane, and the number of lines to be
displayed exceeds the display area. Thus scrolling is activated, and
the starting screen shows from line 1 onwards with the scrollbars
available for scrolling. So far so good.
Now I want to redisplay another screen. Once again the number of lines
exceeds the display area, This time around though, the END of the
lines are displayed. Instead of (for instance) lines 1 to 10 of 100
lines being displayed, lines 90 to 100 are being displayed.
I don't want this. Each time I want to data on the JTextArea to be
displayed from line 1 onwards.
Some research that I did indicated that getViewport().setViewPosition
would be my friend. However, as you can see in the code below, I DID
code this, but it would not work.
Does anybody have an idea how to change the code below so that I can
get the display that I want?
Thanks!
/*
* Example code to demonstrate the problem:
* The first time the data in the JTextArea is displayed,
* the data is positioned at the first line.
* Subsequently (after clicking the Next button), the data
* is positioned such that the last line is displayed.
* I want to reposition the data in the JTextArea such
* that each time after a refresh, the first line of the data
* should be displayed.
***********************************************/
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
class Example extends JFrame implements ActionListener
{
JTextArea textArea;
JScrollPane js;
JButton nextButton = new JButton( "Next" );
JButton endButton = new JButton( "End" );
int counter = -1;
Example()
{
setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
textArea = new JTextArea( 15, 50);
textArea.append( " " );
js = new JScrollPane( textArea );
nextButton.addActionListener( this );
endButton.addActionListener( this );
JPanel pane = new JPanel();
pane.setLayout( new FlowLayout() );
pane.add( nextButton );
pane.add( endButton);
pane.add( js );
setContentPane( pane );
setLines();
setTitle("Example");
setSize(600,400);
setVisible(true);
} //end constructor
public void actionPerformed( ActionEvent evt )
{
Object source = evt.getSource();
if( source == nextButton )
{
setLines();
}
else if( source == endButton )
{
System.exit(0);
}
repaint();
}
void setLines()
{
textArea.setText( "" );
counter++;
for( int n=0; n<100; n++ )
{
textArea.append( counter + " " + n + "This line is filler
data to demonstrate problem\n" );
}
// Attempt to position to top of data... but it does not work :(
js.getViewport().setViewPosition( new Point( 0,0 ) );
}
public static void main( String[] args )
{
new Example();
}
}
|
| Author |
Message |
theodosisx

|
Posted: 2004-8-2 22:39:00 |
Top |
java-programmer, customize JScrollBar
Hello,
I want to scroll up/down by pressing buttons
other than the standards of JScrollBar(These
simple up und down arrows).
Is it possible?
|
| |
|
| |
 |
zoopy

|
Posted: 2004-8-2 23:04:00 |
Top |
java-programmer >> customize JScrollBar
On 2-8-2004 16:38, Theodosis Ekizoglos wrote:
> Hello,
>
> I want to scroll up/down by pressing buttons
> other than the standards of JScrollBar(These
> simple up und down arrows).
>
> Is it possible?
Create a button that sets the value of the scroll bar:
<http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/JScrollBar.html#setValue(int)>
<http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/JScrollPane.html#getHorizontalScrollBar()>
<http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/JScrollPane.html#getVerticalScrollBar()>
Some components have methods to scroll to a specific item (e.g. a node in a JTree) or to a specific
Rectangle: see <http://java.sun.com/docs/books/tutorial/uiswing/components/scrollpane.html#otherAPI>
Regards,
Z.
|
| |
|
| |
 |
| |
 |
Index ‹ java-programmer |
- Next
- 1
- Table Mode & ThreadI understand all updates to any components state should be executed
from with the event-dispatching thread only. What about updates to
TableModel and other Model class?
If update to Model class should also be handled in thread safe manner
(I believe), then why is DefaultTableModel implemented by Vector?
If updating your table model will be handled in a thread safe manner,
why does DefaultTableModel uses a Vector of Vector for its default
implementation? Isn't that an overkill? Am I wrong in making this
observation?
Thanks a lot for any help
- 2
- Bug#305847: ITP: libservlet2.4-java -- Servlet 2.4 and JSP 2.0 Java classes and documentationPackage: wnpp
Severity: wishlist
* Package name : libservlet2.4-java
Version : 2.4
Upstream Author : Apache Jakarta Group
* URL or Web page : http://jakarta.apache.org/tomcat/index.html
* License : Apache 2.0
Description : Servlet 2.4 and JSP 2.0 Java classes and documentation
For more information about Java servlets please take a look at the Tomcat
home page at http://jakarta.apache.org/tomcat/index.html.
.
The official Servlet 2.4 and JSP 2.0 specifications can be found at
http://java.sun.com/products/servlet/ and http://java.sun.com/products/jsp/.
This is a split of tomcat5 source package (this one will be package later)
--
Arnaud Vandyck
Java Trap: http://www.gnu.org/philosophy/java-trap.html
--
To UNSUBSCRIBE, email to email***@***.com
with a subject of "unsubscribe". Trouble? Contact email***@***.com
- 3
- Which WebSphere productsHi,
I want to develop some portal application with WebSphere. There are
quite a few modules/plugins for WebSphere. I don't know which ones are
useful. I downloaded the following WebSphere related products:
- WebSphere Application Community Edition Version 2 (for Solaris 10)
- Eclipse SDK (3.3.1.1) for Windows
- RAD_V7.0_Part(1-10)
I don't know how useful is RAD_V7.0.
I also found IBM website also have a product called "WebSphere Portal
V6.0". I am confused which products I need to download? The
requirement of my development is shown as below:
Mandatory:
- Develop Portal and Portlets.
- Interact with MySQL database engine (3.0)
Optionally:
- UML (able to reverse engineering).
Can anyone please tell me what modules I need to download? and where
can I download it?
I may be need to give a call to IBM to get a trail version of CDs that
include these application. But I want to know how I need in this
development.
Thank you very much in advance.
- 4
- Struts: How do I validate data from an edit form?Hello!
In my Struts app - after submit - I want to validate fields that were
filled with values from a database beforehand. To fill the fields with
the old values I write the existing data into a bean and use it in my
JSP as follows:
<jsp:useBean id="formData" scope="request" class="com.xyz"/>
<html:text name="formData" property="test"/>
So far so good.
When a validation error occurs the user is redirected to the same JSP.
The problem now is that the fields are empty because the bean defined
in the JSP doesn't exist anymore. In fact I actually don't want this
bean to be used. The form-bean which is containing the new data should
be used.
How can I acchieve that?
Regards,
Stefan
- 5
- Potentially dumb questionCould anyone tell me where I might download the latest version of the
Java Development Kit? I have an old Java book and I thought I might
play with it but I need a kit that works with Win XP.
TIA
-Lex
- 6
- java dont have #includes, it sucks !!!http://java.sun.com/docs/books/tutorial/java/concepts/class.html
how can i link diferent modules in one single .class in that lousy
object-wacko language ??? java sucks !!!!!
hahahahahahahahahahahahahahahahaha
either have pointers or #defines !!!! its a C abortion !!!! who
cares ???
C RUUUUUUUULEEEEEZZZZZZZZZ DAMMIT !!!!
- 7
- Using firePropertyChangeIf I have x number of properties, all of which have public getters and
setters methods, is it a good idea to have a
firePropertyChange(fieldName, oldValue, newValue) method inside those
individual setters?
I understand that it only applies to "bound property". What constitute
a "bound"?
- 8
- JTextArea.setLineWrap(true); not working properly with JSplitPane ??Hi,
I have a very strange behavior ...
Placing a JTextArea which is set to: setLineWrap(true); in a JPanel and
the JPanel in a JSplitPane causes the JSplitPane to get stuck (it can't
be moved ...).
It happens with all the layouts that I've tried: BorderLayout,
BoxLayout, with the GridBagLayout it happens when setting the
GridBagConstraints.fill to GridBagConstraints.HORIZONTAL or
GridBagConstraints.BOTH (it doesn't happen when setting it to
GridBagConstraints.NONE or GridBagConstraints.VERTICAL).
However, placing the JTextArea in a JScrollPane works fine (but it's
not a good solution for me).
Does anyone have any idea why it happens and how it can be solved?
Thanks.
- 9
- WHICH J2ME Development Tool?Hello,
After researching the J2ME development tools, I finally decided on NetBeans
and I downloaded it today, with the mobility pack. I found NetBeans be very
powerful, yet I am just starting with Java. NetBeans overwhelmed me, even
with the simple NetBeans-generated "Hello World" MIDLet. I need a simpler
and less powerful development tool. Which development tool do you use for
J2ME? Thank you very much.
Best Regards,
T.I.
- 10
- 11
- toString() or Renderer(s) for BizObjects shown in GUI ComponentsHi There,
What do people prefer for populating GUI Components (Swing) with
Business Objects ?
overriding the toString() method of those Business Objects ? or
creating renderers for each type of component ? (or something else ?)
overriding the toString() method seems easiest, and seems to work --
even seems like thats how the Swing designers intended it (since
components like JComboBox, JList, etc take Objects to populate the
model),
but of course - it may be that in one instance you want your Person
BusinessObject to show up as LastName, FirstName, and in another
component you want to see FirstName, LastName - so a single toString()
method won't cut it.
using renderers instead of toString seems to work too -- but means
potentially writing renderers for almost every component and business
object combination (assuming no use of the toString() method on the
business objects).
Does anybody have any thoughts on this ? a better approach ?
Many Thanks
T
- 12
- Loop to handle many field condition statementsI have some code that works great in my Bean class that looks like the
below where I have around 15 fields. For example I condensed it to 2
fields:
//bean model part
HashMap errors = new HashMap();
String firstname = "Joe";
String lastname = "Miller";
if (firstname.equals(""))
{
errors.put("firstname","missing firstname".);
}
if (lastname.equals(""))
{
errors.put("lastname","missing lastname");
}
//Each field is then called like this in a View page:
errors.get("firstname"));
errors.get("lastname"));Anyway I can create a loop to go through all
15 fields or how is the best way to do this??
//use Array or Iterator or List or what to get the 15 fields then
loop?
for(int i= 0;i < 15;i++)
{
/*
how would I make this part work?
if (firstname.equals(""))
{
errors.put("firstname","missing firstname".);
}
if (lastname.equals(""))
{
errors.put("lastname","missing lastname");
}
/*
}
Please advise.
- 13
- doubts regarding j2meI am new in j2me...I have some doubts...
1. How to insert an image into a servlet?
2. How to access it from a mobile using j2me?
3. How to send an image file from a mobile to a servlet?
Please help me...
- 14
- IllegalStateException...Writer being already used by this servletHi All,
I am faceing a problem (ofcourse thats what makes all of us come
here)..what I am trying to do is , create a image offscreen in a
servlet , then using PixelGrabber serialize the int[] and then the
applet reads it, ..so far fairly straight, now here...
...
...
ObjectOutputStream out = new
ObjectOutputStream(res.getOutputStream());
System.out.println("Inside isReq after out obj");
out.writeInt(w);
out.writeInt(h);
out.writeObject(pixels);
}
/**
try{
res.setContentType("text/html");
printer=res.getWriter();
printer.println("Object Writing done");
printer.close();
}catch(Exception ex){}
}
else{
printer.println("Object Writing <b>Not</b> done");
printer.close();
}**/
After Object writing is being done , I wish to display a html page
(with applet embedded) but using the above code it is giving me a
error "IllegalStateException: Writer being already used by the
servlet..."
Can anyone help me out...
Regards
Ray
- 15
- Bug#297574: upstream test case
Similar problem (jar to native compilation) reported in
http://gcc.gnu.org/PR18931
(closed)
the _exact_ bug is reported in
http://gcc.gnu.org/PR19505
(open)
test case PR19505.class still fails with gcj-snapshot (20050227)
GNU Java version 4.1.0 20050227 (experimental) (i486-linux-gnu)
compiled by GNU C version 4.1.0 20050227 (experimental).
GGC heuristics: --param ggc-min-expand=47 --param ggc-min-heapsize=32066
...
Note comment #2 on http://gcc.gnu.org/PR19505 : gcj fails to compile
bytecode produced by Sun's javac, but not when compiling bytecode
produced by gcj (with -C) or ecj.
comment #2 is posted in 2005-01-25 (same as the failing gcj I am
using), but I am compiling a .jar produced by gcj (I guess bug was
introduced some time between 2004-12-28 and 2005-01-25)
I am testing again:
gcj-snapshot -O2 -Wl,-Bsymbolic -shared -fPIC -fjni -findirect-dispatch -o /tmp/jdt.jar.so /usr/share/eclipse/plugins/org.eclipse.jdt.ui_3.0.1/jdt.jar
now. It take long time, but problem with gcj 4.0 20050125 happen soon,
I still do not see problem, by now. The jar is compiled with gcj 4.0
20050125
--
To UNSUBSCRIBE, email to email***@***.com
with a subject of "unsubscribe". Trouble? Contact email***@***.com
|
|
|