comp.lang.java.programmer http://groups-beta.google.com/group/comp.lang.java.programmer [EMAIL PROTECTED]
Today's topics: * Problem with Java application on Windows - 2 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/5ca9514f3df9a940 * Is JasperReport for producttion ? - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/74c818cbd365d681 * Relayout of JFrame? - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/b187f0e6674dae98 * Socket I/O Question! - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/fb8f4597465778d2 * Anybody familiar with the Triangle Comipiler? - 3 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/fbcaab1f73c71be2 * Can Java Programmer Learn C++ Quickly? - 3 messages, 3 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/7c7a28aa864e41ec * Struts - Cant pass attribute to page from Action class - 4 messages, 3 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/5215e3a6faf51bc2 * swing JInternalFrame focus management - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/4a071968367d7dcc * reading binary file. - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/cc960a0baa9ed6ab * This group is new? - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/9a9e7de1fff77726 * JTextArea question - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/3b5070301a6779b * A little optimization question: Local var allocation - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/a6b24661ed590053 * Scrollable JPanel having GridLayout. - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/1b22abc8446a6dd0 * OpenLDAP + java + changing user's passwords - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/aabcc64718ab59bc ============================================================================== TOPIC: Problem with Java application on Windows http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/5ca9514f3df9a940 ============================================================================== == 1 of 2 == Date: Tues, Dec 7 2004 8:24 pm From: "tox" I ran the application from the command prompt and got the following error message: no `server' JVM at `C:\Program Files\Java\j2re1.4.2_06\bin\server\jvm.dll'. So I went to look for jvm.dll. There was a \client\jvm.dll but no \server\jvm.dll so I made a copy of \client\jvm and renamed it to \server\jvm.dll. The batch files seemed to work fine after that. I had assumed that upon installation of "Java 2 SDK, Standard Edition 1.4.2_06" (j2sdk-1_4_2_06-windows-i586-p.exe), the \server\jvm.dll directory would have been created but apparently not. Does this mean that my Java SDK installation was not thorough and will this cause me some problems later? Should I attempt to reinstall it or will I be fine for now (I mainly plan to run applications for the present and may only get into development much further down the line)? Thanks very much and I greatly appreciate your help!!! Sincerely, tox. == 2 of 2 == Date: Tues, Dec 7 2004 8:27 pm From: "tox" I ran the application from the command prompt and got the following error message: no `server' JVM at `C:\Program Files\Java\j2re1.4.2_06\bin\server\jvm.dll'. So I went to look for jvm.dll. There was a \client\jvm.dll but no \server\jvm.dll so I made a copy of \client\jvm and renamed it to \server\jvm.dll. The batch files seemed to work fine after that. I had assumed that upon installation of "Java 2 SDK, Standard Edition 1.4.2_06" (j2sdk-1_4_2_06-windows-i586-p.exe), the \server\jvm.dll directory would have been created but apparently not. Does this mean that my Java SDK installation was not thorough and will this cause me some problems later? Should I attempt to reinstall it or will I be fine for now (I mainly plan to run applications for the present and may only get into development much further down the line)? Thanks very much and I greatly appreciate your help!!! Sincerely, tox. ============================================================================== TOPIC: Is JasperReport for producttion ? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/74c818cbd365d681 ============================================================================== == 1 of 1 == Date: Tues, Dec 7 2004 8:32 pm From: [EMAIL PROTECTED] Hi All, I am looking for a free java reporting tool and I heard about JasperReport. Is JasperReport stable enough for production ? Can JasperReport be used from JSP ? or it only can be used from Java Application ? Thank you for any help, Krist ============================================================================== TOPIC: Relayout of JFrame? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/b187f0e6674dae98 ============================================================================== == 1 of 2 == Date: Tues, Dec 7 2004 8:43 pm From: Knute Johnson I've got a JFrame app that has several components laid out with GridBagLayout. One of the components is a JPanel that I draw an image on. This component occaisionally can change size. After I resize my JPanel, I invalidate it, repaint it and then call pack() on the JFrame. Is there a way to cause the JFrame to relayout the components but not shrink to fit the layout as it does with pack() but still grow if necessary? Thanks, -- Knute Johnson email s/nospam/knute/ == 2 of 2 == Date: Wed, Dec 8 2004 12:42 pm From: Babu Kalakrishnan Knute Johnson wrote: > I've got a JFrame app that has several components laid out with > GridBagLayout. One of the components is a JPanel that I draw an image > on. This component occaisionally can change size. After I resize my > JPanel, I invalidate it, repaint it and then call pack() on the JFrame. > Is there a way to cause the JFrame to relayout the components but not > shrink to fit the layout as it does with pack() but still grow if > necessary? > I'm afraid nothing that does it automatically. But you can always query the panel for its preferredSize and set the size of the frame appropriately - making it bigger if required, but not shrinking it if that is the case. BK ============================================================================== TOPIC: Socket I/O Question! http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/fb8f4597465778d2 ============================================================================== == 1 of 2 == Date: Wed, Dec 8 2004 5:02 am From: "Ken Adams" Basically all I want to know is that after a client/server is set up using sockets and say you start by setting the input and output streams to say PrintWriter(or whatever) can you just go ahead and set the stream to be another type such as ObjectOuputStream to to send and object? This is of course assuming both server and client do these steps in the same order. Basically what I want my client to do is connect to the server, send a string representing the name of the client then send some Command messages to the server. Or do you think a better method is to just set up and object stream and just cast the first object as a string? Thanks a bunch. == 2 of 2 == Date: Tues, Dec 7 2004 11:40 pm From: Gordon Beaton On Wed, 08 Dec 2004 05:02:21 GMT, Ken Adams wrote: > Basically all I want to know is that after a client/server is set up > using sockets and say you start by setting the input and output > streams to say PrintWriter(or whatever) can you just go ahead and > set the stream to be another type such as ObjectOuputStream to to > send and object? This is of course assuming both server and client > do these steps in the same order. You can't "set the stream to be another type". You connect streams to each other to get various types of data conversions. Don't try to wrap an ObjectOutputStream around any kind of Writer, which expects *text*. If you want to send Objects, wrap the stream around an OutputStream, which expects *bytes*. By the same token, wrap the corresponding ObjectInputStream around an an InputStream (not a Reader) at the other end. > Basically what I want my client to do is connect to the server, send > a string representing the name of the client then send some Command > messages to the server. Or do you think a better method is to just > set up and object stream and just cast the first object as a string? If you only want to send Strings, don't use ObjectStreams at all. Wrap a Reader and Writer around the InputStream and OutputStream. If you use a BufferedReader for input, you can easily read the data one line at a time. Here is an introduction to this topic: http://java.sun.com/docs/books/tutorial/essential/io/overview.html /gordon -- [ do not email me copies of your followups ] g o r d o n + n e w s @ b a l d e r 1 3 . s e ============================================================================== TOPIC: Anybody familiar with the Triangle Comipiler? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/fbcaab1f73c71be2 ============================================================================== == 1 of 3 == Date: Tues, Dec 7 2004 9:08 pm From: [EMAIL PROTECTED] (Diphay Z) The triangle compiler, which was described in the "Programming Language Processors In Java" --by Watt & Brown. Could anybody discuss with me? One of my exercise needs me to extend the compiler to support the following statement: for I from E1 to E2 do C, where I is an identifier, E1 and E2 are expressions will be evaluated as integers, C is a command. The difficult part of this expansion was in the code generator part. This statement is hard to formulate a template. e.g. For a while command: while E do C the template can be written as follows: JUMP h g: excute C h: evaluate E JUMP(1) g but for the ForCommand, I cannot find out a method to formulate its template. Anybody can help me? Thanks a lot == 2 of 3 == Date: Wed, Dec 8 2004 7:52 am From: Daniel Sjöblom Diphay Z wrote: > The triangle compiler, which was described in the "Programming > Language Processors In Java" --by Watt & Brown. Could anybody discuss > with me? > > One of my exercise needs me to extend the compiler to support the > following statement: > > for I from E1 to E2 do C, where I is an identifier, E1 and E2 are > expressions will be evaluated as integers, C is a command. > > The difficult part of this expansion was in the code generator part. > This statement is hard to formulate a template. > e.g. > For a while command: while E do C > the template can be written as follows: > JUMP h > g: excute C > h: evaluate E > JUMP(1) g > > but for the ForCommand, I cannot find out a method to formulate its > template. Anybody can help me? Thanks a lot You haven't specified the exact semantics of the for loop, but assuming that E1 and E2 will be evaluated only once, and I will be incremented by one after each iteration, and the loop will continue until I > value of E2: init: i <- eval E1 j <- eval E2 jmp test next: do C i <- i + 1 test: cmp i, j jna next But really, you need to tell us what exactly the for statement is supposed to do. -- Daniel Sjöblom Remove _NOSPAM to reply by mail == 3 of 3 == Date: Tues, Dec 7 2004 10:47 pm From: "Diphay Z" Firstly, thanks for you reply. As described on the textbook, the for loop is executed as follows. First, the expressions E1 and E2 are evaluated, yielding the integers m and n (say), respectively. Then the subcommand C is executed repeatedly, with identifier I bound in successive iterations to each integer in the range m through n. If m > n, C is not executed at all. (The scope of I is C, which may use the value of I but may not update it. The types of E1 and E2 must be Integer.) Here is an example: for n from 2 to m do if prime(n) then putint(n) thx! ============================================================================== TOPIC: Can Java Programmer Learn C++ Quickly? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/7c7a28aa864e41ec ============================================================================== == 1 of 3 == Date: Wed, Dec 8 2004 4:24 pm From: Ian T Chris Smith wrote: > IMHO, this is far more confusing than pointer arithmetic ever > was, but it's still not prohibitive to understand. Devoting months to > getting it is, frankly, ludicrous. > Please point out where I said it would take months to 'get' pointer arithmetic. > >>>It's been ages (something like fifteen years) since I've used a null >>>terminated character string in C++ other than at a C interface. In >>>fact, if someone starts talking about null terminated character strings >>>in C++, I pretty much take it as a sign that he doesn't know C++. >> >>As you don't offer up your alternative, I'll just take that as a >>personal slur. > > > I think it pretty much goes without saying. C++ has a std::string class > (actually a template specialization rather than a class per se, but > that's immaterial). You should use it if you're writing C++. > > #include <string> > So if an (for example) Winapi call required that you pass a reference to a char array you would use string a; HANDLE = AnExampleAPI(a.c_str()); ?? It's been a while but a seem to recall a problem with using 'string' that way. I will go back and see if I can find the specific example. Ian == 2 of 3 == Date: Wed, Dec 8 2004 12:50 am From: Sudsy Rhino wrote: <snip> You've received some well-considered opinions from some of the heavy- weights on this ng. I must admit to being impressed at the care with which their responses were crafted. I'd just like to add to my earlier posting. While other have confirmed the difficulty of templates and the JSTL, there were many mentions made of the pitfalls of pointers. I was trying out C++ coming from a C background, down to the kernel layer, so I was already intimately familiar with the language elements which make C so powerful. It's a double-edged sword, but single and double indirection were second nature to me when I approached C++ for the second time. So I'll clarify and suggest that, if you already have a background in C and have learned Java, "merging" the two and picking up C++ is still something which can be done in a weekend. You won't be an experienced practitioner, but you'll probably do better than many who skipped Java and went directly from C to C++. As to whether you should apply for jobs requiring C++ expertise... It's my opinion that a good programmer can pick up what they need in short order. It's the thought process behind the coding which makes the difference. Just hope you can find a potential employer who agrees! As always, YMMV. -- Java/J2EE/JSP/Struts/Tiles/C/UNIX consulting and remote development. == 3 of 3 == Date: Wed, Dec 8 2004 7:03 am From: "Ann" "Rhino" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I realize that this is not entirely a Java question but I am hoping that > some of the people reading this newsgroup are Java programmers who went on > to learn C++. > > I am giving some thought to applying for some jobs that want people with > Java and C++ experience. I have been writing Java for several years and am > fluent enough that I don't have to post questions here very often. I have no > real C++ experience and not much C experience for that matter. Did you consider C# instead of C++? > However, the core Java statements are "borrowed" from C and C++ has often > been called "C with classes". It seems to me that it shouldn't take very > long to get up to speed on C++ if I am already fluent with Java and have at > least some knowledge of C. Then again, I understand that Java and C++ use > classes a bit differently; for instance C++ allows multiple inheritance > while Java allows only single inheritance but allows for multiple interfaces > as compensation. I'm not sure how long it would take to get fluent with > multiple inheritance after several years with Java. > > I'd be very curious to know how long it took people here who were fluent in > Java to get fairly fluent in C++ if they started with approximately the same > skills I have today. > > -- > Rhino > --- > rhino1 AT sympatico DOT ca > "There are two ways of constructing a software design. One way is to make it > so simple that there are obviously no deficiencies. And the other way is to > make it so complicated that there are no obvious deficiencies." - C.A.R. > Hoare > > ============================================================================== TOPIC: Struts - Cant pass attribute to page from Action class http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/5215e3a6faf51bc2 ============================================================================== == 1 of 4 == Date: Tues, Dec 7 2004 9:38 pm From: "Anonymous" When I click submit on orderForm.jsp and submit.do redirects me to confirm.jsp, I get the output "Thank you null" no matter what I type in the name as. However, The name and the name attribute is however successfully printed out in the System output (I can see them in the console) in OrderAction.java. Perhaps we get sent to confirm.jsp before OrderAction has finished setting the attribute "name"? But you can clearly see in the code that it does this before returning ActionForward. Maybe their running in different threads or something? how do I fix this? code is below... Here are my files (including sruts-config.xml down the bottom) orderForm.jsp <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %> <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %> <html:form action="/submit.do"> Name:<html:text property="name" /> <html:submit/> <html:reset/> </html:form> confirm.jsp <BODY> <P>Thank you <%=request.getAttribute("name")%></P> </BODY> OrderForm.java package net.mshome.orderweb.resources; import javax.servlet.http.HttpServletRequest; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionMapping; /** * Form bean for a Struts application. * Users may access 1 field on this form: * <ul> * <li>name - [your comment here] * </ul> * @version 1.0 * @author */ public class OrderForm extends ActionForm { private String name = null; /** * Get name * @return String */ public String getName() { return name; } /** * Set name * @param <code>String</code> */ public void setName(String n) { this.name = n; } public void reset(ActionMapping mapping, HttpServletRequest request) { // Reset values are provided as samples only. Change as appropriate. name = null; } public ActionErrors validate( ActionMapping mapping, HttpServletRequest request) { ActionErrors errors = new ActionErrors(); // Validate the fields in your form, adding // adding each error to this.errors as found, e.g. // if ((field == null) || (field.length() == 0)) { // errors.add("field", new org.apache.struts.action.ActionError("error.field.required")); // } return errors; } } OrderAction.java package net.mshome.orderweb.resources; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.struts.action.Action; import org.apache.struts.action.ActionError; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; /** * @version 1.0 * @author */ public class OrderAction extends Action { public ActionForward execute( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { ActionErrors errors = new ActionErrors(); ActionForward forward = new ActionForward(); // return value OrderForm orderForm = (OrderForm) form; try { // Getting the value from the form String name = orderForm.getName(); System.out.println("The name is: " + name); request.setAttribute("name", name); System.out.println("Name attribute is now:" + request.getAttribute("name").toString()); } catch (Exception e) { // Report the error using the appropriate name and ID. e.printStackTrace(); System.out.println(e.getMessage()); } // If a message is required, save the specified key(s) // into the request for use by the <struts:errors> tag. if (!errors.isEmpty()) { saveErrors(request, errors); } // Write logic determining how the user should be forwarded. forward = mapping.findForward("success"); // Finish with System.out.println("Forwarding"); return (forward); } } struts-config.xml <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd"> <struts-config> <!-- Data Sources --> <data-sources> </data-sources> <!-- Form Beans --> <!-- Global Exceptions --> <form-beans> <form-bean name="orderForm" type="net.mshome.orderweb.resources.OrderForm"> </form-bean> </form-beans> <global-exceptions> </global-exceptions> <!-- Global Forwards --> <global-forwards> </global-forwards> <!-- Action Mappings --> <action-mappings> <action path="/submit" type="net.mshome.orderweb.resources.OrderAction" name="orderForm" scope="session" validate="false"> <forward name="success" path="confirm.jsp" redirect="true" contextRelative="false"> </forward> </action> </action-mappings> <!-- Message Resources --> <message-resources parameter="net.mshome.orderweb.resources.ApplicationResources"/> </struts-config> == 2 of 4 == Date: Wed, Dec 8 2004 1:06 am From: Sudsy Anonymous wrote: > When I click submit on orderForm.jsp and submit.do redirects me to > confirm.jsp, <snip> You've already answered your own query with the use of the word "redirect". If you don't forward then you lose all of the form attributes as you're requiring the browser to make a second request to the server. Since the attributes only have request scope... -- Java/J2EE/JSP/Struts/Tiles/C/UNIX consulting and remote development. == 3 of 4 == Date: Wed, Dec 8 2004 1:11 am From: Sudsy Anonymous wrote: <snip> > <BODY> > <P>Thank you <%=request.getAttribute("name")%></P> > </BODY> <snip> Since orderForm is defined as having session scope, the following might work: <%= orderForm.name %> Don't have time to check it out right now, it's late, etc... -- Java/J2EE/JSP/Struts/Tiles/C/UNIX consulting and remote development. == 4 of 4 == Date: Wed, Dec 8 2004 6:15 am From: "Murray" "Anonymous" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > <forward name="success" path="confirm.jsp" redirect="true" > contextRelative="false"> > </forward> Here is your problem. When you use redirect="true" this issues a client side redirect (status 302 - Moved Temporarily). Hence this will be a new request and any request attributes you set in the Action will no longer be available in the jsp. Either don't use redirect (preferable) or stick the value in the session to make it available across multiple requests. ============================================================================== TOPIC: swing JInternalFrame focus management http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/4a071968367d7dcc ============================================================================== == 1 of 1 == Date: Tues, Dec 7 2004 9:56 pm From: [EMAIL PROTECTED] I am doing a lot of work with a JInternalFrame based gui. I have one desktoppane and hundreds of possible JInternalFrames that can be opened and closed within it. There are often layers of JInternalFrames sitting on top of each other, many are derived from each other. My problem is that when a JInternalFrame is disposed or hidden then the JInternalFrame below it is visible but it does not automatically gain focus. My application is very keyboard friendly and enables the user to do most things by typing and hotkeys. But when a JInternalFrame closes and then nothing has focus they have to take their mouse and manual click on it before they can start typing again. So I am wondering if there is a reasonable way to manage it so when a jinternalframe is closed the layer beneath automatically gains focus? thanks ryan ============================================================================== TOPIC: reading binary file. http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/cc960a0baa9ed6ab ============================================================================== == 1 of 2 == Date: Wed, Dec 8 2004 5:56 am From: "El Durango" I have to write Java to read a binary file and I am not getting the values I am looking for. The format of the file is: String 4bytes String 20bytes String 32bytes double 8bytes double 8bytes double 8bytes double 8bytes double 8bytes Here is a snippet of my code: fis = new FileInputStream(inputFile); dis = new DataInputStream(fis); while(retCode != -1){ retCode = dis.read(caseNameBuf,offset,CASENAMESIZE); System.out.println(new String(caseNameBuf)); if(retCode == -1){ throw new EOFException(); } retCode = dis.read(nullBuf,offset,12); System.out.println(new String(nullBuf)); if(retCode == -1){ throw new EOFException(); } retCode = dis.read(eventNameBuf,offset,EVENTNAMESIZE); System.out.println(new String(eventNameBuf)); if(retCode == -1){ throw new EOFException(); } d = dis.readDouble(); System.out.println(d); d = dis.readDouble(); System.out.println(d); d = dis.readDouble(); System.out.println(d); d = dis.readDouble(); System.out.println(d); d = dis.readDouble(); System.out.println(d); } ... I am getting the correct String data however I cannot get the proper data for the double values. Can anyone inform me of what mistake I am making here. thank you, Durango. == 2 of 2 == Date: Wed, Dec 8 2004 8:24 am From: Gordon Beaton On Wed, 08 Dec 2004 05:56:59 GMT, El Durango wrote: > I have to write Java to read a binary file and I am not getting the > values I am looking for. > > The format of the file is: > String 4bytes > String 20bytes > String 32bytes > double 8bytes > double 8bytes > double 8bytes > double 8bytes > double 8bytes > [...] > I am getting the correct String data however I cannot get the proper > data for the double values. Can anyone inform me of what mistake I > am making here. How was the file created? How are the doubles represented in the file? Try reading the 8 byte doubles as bytes, then display each byte individually. Now read the descriptions of Double.DoubleToLongBits() and Double.longBitsToDouble(): http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Double.html Can you see the relationship between the bytes you read and the format expected by DataInputStream.readDouble(), which you're using to read the file? > d = dis.readDouble(); /gordon -- [ do not email me copies of your followups ] g o r d o n + n e w s @ b a l d e r 1 3 . s e ============================================================================== TOPIC: This group is new? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/9a9e7de1fff77726 ============================================================================== == 1 of 1 == Date: Tues, Dec 7 2004 10:40 pm From: "Diphay Z" lots of person ============================================================================== TOPIC: JTextArea question http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/3b5070301a6779b ============================================================================== == 1 of 1 == Date: Wed, Dec 8 2004 12:13 pm From: Babu Kalakrishnan Ryan Tan via JavaKB.com wrote: > Hi, I have a question regarding JTextArea. > > I need to place a JTextArea on my frame to display application messages. Is > there a way to make it non-editable but users still can select text in it and > copy to clipboard using the keyboard shortcut? > > I tried .setEditable(false) but this disables the "Copy to clipboard" > functionality of JTextArea. > Are you sure ? Which JDK version is this ? I find that I can select as well as copy text on JDK 1.4.2 / Linux even on a TextArea that isn't editable. BK ============================================================================== TOPIC: A little optimization question: Local var allocation http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/a6b24661ed590053 ============================================================================== == 1 of 1 == Date: Wed, Dec 8 2004 7:10 am From: "Ann" "Daniel Sjöblom" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Chris Berg wrote: > > #1: > > String st; > > while (true){ > > st=dis.readLine(); > > if (st==null) break; > > < do something else > > > } > > > > > > #2: > > while (true){ > > String st=dis.readLine(); > > if (st==null) break; > > < do something else > > > } > > > In this case the two approaches compile to identical bytecode (which you > could have verified yourself), so there is not much to discuss. Even if > they didn't, worrying about this kind of microoptimization is utterly > futile. A better improvement to #1, #2 would be a more readable version: > > String str; > while ((str = dis.readLine()) != null) > { > ... something > } > > -- > Daniel Sjöblom How about this one --- for(int i=0; i<100; i++) { Int j = new Int(i); } --- ============================================================================== TOPIC: Scrollable JPanel having GridLayout. http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/1b22abc8446a6dd0 ============================================================================== == 1 of 1 == Date: Wed, Dec 8 2004 12:35 pm From: Babu Kalakrishnan Shuaib wrote: > I have been trying to solve this problem for some time but haven't > found a solution yet. > > Here is what I wanna do: A scrollable JPanel having GridLayout to > which I add images of any size which are also in JPanel(s). The image > size should be maintained and when I need to see the part not visible > in the screen I can use the scrollbar. > > Here is the simplified form of what I am currently doing: > > JPanel p = new JPanel(); > JScrollPane sp = new JScrollPane(p); > sp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); > p.setLayout(new GridLayout(1,2)); > > JPanel p1 = new JPanel(); > ImageIcon icon1 = new ImageIcon(url1); > JLabel image1 = new JLabel(icon1); > p1.add(image1, BorderLayout.CENTER); > p.add(p1); > > JPanel p2 = new JPanel(); > ImageIcon icon2 = new ImageIcon(url2); > JLabel image2 = new JLabel(icon2); > p2.add(image2, BorderLayout.CENTER); > p.add(p2); > > For single image, it does appear in the panel but its top and bottom > are chopped off if it is in portrait orientation with no vertical > scrollbar. For two images, it tries to fit both by chopping them off > from the sides too. Both appear together in the viewport without > horizontal and vertical scrollbars. > Any help will be highly appreciated. > Cannot reproduce this on my machine. As far as I can see from the code, the JScrollPane should display the panel properly with scrollbars as appropriate to scroll the images fully. Couple of comments about your code though : When creating a GridLayout, never specify the rows and column values. Only one of them will be honored, and the second parameter will only confuse someone who reads your code. The arguments (1,2) will give you a layout that will always create a GridLayout with 1 row - and as many number of columns as required - not 2. If you want 2 columns, specify the constructor arguments as (0,2). You're adding the JLabels to the panel using a constraint BorderLayout.CENTER. This is incorrect because you never set a BorderLayout as the JPanel's layoutmanager. A constraint of specification of BorderLayout.CENTER will not make any sense to a FlowLayout which is the default layout manager for a JPanel. Also in the example code above, the intermediate panels (to which you're adding the JLabels) aren't really required. You can add the JLabels directly to the outer panel instead. BK ============================================================================== TOPIC: OpenLDAP + java + changing user's passwords http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/aabcc64718ab59bc ============================================================================== == 1 of 1 == Date: Tues, Dec 7 2004 11:15 pm From: [EMAIL PROTECTED] (Eric Gutierrez) I've got a -working- (work-in-progress) test program below that changes a non-encrypted attribute to some other non-encrypted value (change non-encrypted password program) of a Linux OpenLDAP server. Yes/No Questions: (need to ask, cause my soon-to-be new LDAP server -Sun Directory Server will likely use SSHA1 for user's passwords) 1. Will the user be able login with the new password from the program below if LDAP server is expecting the password to be encrypted in SSHA1 (or some other method)? 2. Will LDAP automatically encrypt the new plain text password for me when I run the program below? --how I wish... 3. Will I need to write code to encrypt the plain text password to SSHA1 before giving it to the LDAP server? If yes, where do I start - any API's out there to do this fast? Thanks for any tips. eric ==================== JAVA CODE: ==================== import java.util.*; import netscape.ldap.*; .... LDAPConnection ld = new LDAPConnection(); ld.connect (hostname, 389); ld.authenticate ("cn=Manager,dc=cet,dc=co","secret"); .... LDAPModificationSet mod = new LDAPModificationSet(); LDAPAttribute an = new LDAPAttribute ("attrib_password","somenewtxtpassword"); mod.add (LDAPModification.REPLACE,an); ld.modify ("uid=sometestuser,ou=people,dc=cet,dc=co",mod); .... ld.disconnect(); ==================== ============================================================================== You received this message because you are subscribed to the Google Groups "comp.lang.java.programmer" group. To post to this group, send email to [EMAIL PROTECTED] or visit http://groups-beta.google.com/group/comp.lang.java.programmer To unsubscribe from this group, send email to [EMAIL PROTECTED] To change the way you get mail from this group, visit: http://groups-beta.google.com/group/comp.lang.java.programmer/subscribe To report abuse, send email explaining the problem to [EMAIL PROTECTED] ============================================================================== Google Groups: http://groups-beta.google.com
