JTextArea setCaretPosition(0); not the behavior I expected.

Unfortunately I can't post any code from my app because I'm at work and the computer I'm posting on does not support my USB card, with that said I will make a feeble attempt at explaining my problem(as trivial as it may seem). I've got a chat program that takes in an argument from the command line that checks to see if the app acts as a server or a client. The server uses a serverSocket and the client uses a socket. I'm using TCP connection to transmit my data. In my GUI I have two JTextAreas one for outgoing messages and one for all incoming messages as well as outgoing messeges from the user(like AIM or MSN where you see your text and whoever your chatting with in a Text Area). To the point, when I hit Enter when the "sendTextArea" has focus or when I push the "send" button the data is transmitted, at this point I want the cursor to go back to 0,0 in the "sendTextArea". I have placed a "sendTextArea.setCaretPosition(0)" in both the enter and send button event handlers. When I hit enter the cursor still goes to the next line, and when I hit send instead of being in position 0 of the area I think it's in 1 or 2. Thanks in advance and sorry for the lackluster of a post w/out code, will have Monday for sure.

Great feedback camickr, thanks for the excellent advice. I'm still at work but I'm almost certain I am using the keyPressed event. I do see what you mean, I brough my compouter to work with me today so I will be able to try this tonight and let you know how it went. I read in another post where you had given some advice on using a documentListener, would that apply here or just the ordinary actionListener. I'll try and answer my own question later when I have the opportunity, again thanks for the advice.
Message was edited by:
m1keclancy

Similar Messages

  • There are two layers in Lightroom - just not the way you expect.

    Layers of a sort are possible, but it is more a use of files to frame images in the Print and Slideshow Modules.
    Transparent PNG Items are what they are called.
    What are Transparent PNG Items?
    Transparent PNG Items (TPIs) are images that may be used as a layer over, or sometimes under an image to enhance the appearance of the image.
    ?The TPI image is a PNG file that has transparency.
    This type of file can be made inside of Photoshop.
    What can I use TPIs for?
    Framing images on output or in the slideshow, but not in all places an Identity plate can be used.
    See how you can do this at LightroomExtra.com

    You're welcome.
    It's not that cold here right now. About 0°C. And not much snow either. The most have melted away. We only have the remnants of a 5x6x1,5 meter snow airplane that me and my four year old son Max built a couple of weeks ago.
    The best part were then we spray painted the whole thing with blue food dye!
    You should have seen the looks on the neighbors faces when they passed by ;-)
    But the nights are dark and are a perfect time to run LR through it's paces

  • Not the results I expected

    Dear all
    I've purchased an airport express with the hope of extending the poor coverage from my bt wireless router . I've set the express up as an addition to my existing wireless network apparently successfully . As expected I only get a green light when the express is plugged in within the range of my existing network however when using my pad and phone I can still only achieve the same wifi range as before as before . have I missed something ?
    Cheers
    Andy

    Shame indeed!
    If you connect the AX to the wired router by Ethernet, you can configure both routers for a "roaming" network. With this type of network, you could literally roam with your wireless-enabled laptop from room to room and still be connected to the "same" wireless network.
    Setup the AX as a bridge.
    o AirPort Utility > Select the AX > Manual Setup > Internet > Internet Connection > Connection Sharing: Off (Bridge Mode)
    For both routers:
    o Connect them both by Ethernet.
    o Provide a unique Base Station Name
    o The Network Name (or SSID) should be identical
    o If using security, use the same encryption type (WEP, WPA, etc.) and password.
    o Make sure that the radio channel is set at least three channels apart to prevent Wi-Fi interference between radios.

  • ELF file's phentsize not the expected size - ERROR on Linux

    I followed all the steps shown on the javasoft/tutorial on JNI and created the following files
    ThreadTool.c
    ~~~~~~~~~~~~~~~~~~
    #include <jni.h>
    #include "ThreadTool.h"
    #include <jvmdi.h>
    JNIEXPORT jint JNICALL Java_ThreadTool_getThreadStatus
    (JNIEnv *env, jclass clazz, jobject thread)
    jint threadStatus;
    jint suspendStatus;
    jvmdiError error = JVMDI_GetThreadStatus (env, thread, &threadStatus, &suspendStatus);
    return (threadStatus);
    ThreadTool.h
    ~~~~~~~~~~
    /* DO NOT EDIT THIS FILE - it is machine generated */
    #include <jni.h>
    /* Header for class ThreadTool */
    #ifndef IncludedThreadTool
    #define IncludedThreadTool
    #ifdef __cplusplus
    extern "C" {
    #endif
    #undef ThreadTool_THREAD_STATUS_UNKNOWN
    #define ThreadTool_THREAD_STATUS_UNKNOWN -1L
    #undef ThreadTool_THREAD_STATUS_ZOMBIE
    #define ThreadTool_THREAD_STATUS_ZOMBIE 0L
    #undef ThreadTool_THREAD_STATUS_RUNNING
    #define ThreadTool_THREAD_STATUS_RUNNING 1L
    #undef ThreadTool_THREAD_STATUS_SLEEPING
    #define ThreadTool_THREAD_STATUS_SLEEPING 2L
    #undef ThreadTool_THREAD_STATUS_MONITOR
    #define ThreadTool_THREAD_STATUS_MONITOR 3L
    #undef ThreadTool_THREAD_STATUS_WAIT
    #define ThreadTool_THREAD_STATUS_WAIT 4L
    #undef ThreadTool_SUSPEND_STATUS_SUSPENDED
    #define ThreadTool_SUSPEND_STATUS_SUSPENDED 1L
    #undef ThreadTool_SUSPEND_STATUS_BREAK
    #define ThreadTool_SUSPEND_STATUS_BREAK 2L
    * Class: ThreadTool
    * Method: getThreadStatus
    * Signature: (Ljava/lang/Thread;)I
    JNIEXPORT jint JNICALL Java_ThreadTool_getThreadStatus
    (JNIEnv *, jclass, jobject);
    #ifdef __cplusplus
    #endif
    #endif
    ThreadTool.java (This is my test class)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    public class ThreadTool {
    public static final int THREAD_STATUS_UNKNOWN = -1;
    public static final int THREAD_STATUS_ZOMBIE = 0;
    public static final int THREAD_STATUS_RUNNING = 1;
    public static final int THREAD_STATUS_SLEEPING = 2;
    public static final int THREAD_STATUS_MONITOR = 3;
    public static final int THREAD_STATUS_WAIT = 4;
    public static final int SUSPEND_STATUS_SUSPENDED = 1;
    public static final int SUSPEND_STATUS_BREAK = 2;
    public static native int getThreadStatus (Thread t);
    static {
    String currpath = System.getProperty("java.library.path");
    String newpath = currpath+":/home/apota/";
    System.setProperty("java.library.path", newpath);
    System.loadLibrary ("ThreadTool");
    public static void main(String[] args) {
    Reaper rp = new Reaper(1000, "apota");
    Reaper rp1 = new Reaper(2000, "drice");
    rp.start();
    rp1.start();
    while (true) {
    System.out.println("Apota thread "+ThreadTool.getThreadStatus(rp));
    System.out.println("Drice thread "+ThreadTool.getThreadStatus(rp1));
    I use the following command to compile on Linux
    gcc -I/usr/local/java/include -I/usr/local/java/include/linux ThreadTool.c -c -o libThreadTool.so
    When I run the java program to test it, I get the following
    Exception in thread "main" java.lang.UnsatisfiedLinkError: /usr/home/apota/libThreadTool.so: /usr/home/apota/libThreadTool.so: ELF file's phentsize not the expected size
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1419)
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1343)
    at java.lang.Runtime.loadLibrary0(Runtime.java:749)
    at java.lang.System.loadLibrary(System.java:820)
    at ThreadTool.<clinit>(ThreadTool.java:21)
    Whats going on?
    (FYI: I am trying ot get the status of a Thread in Java using the JVMDI C API)

    aldus99 wrote:
    I use the following command to compile on Linux
    gcc -I/usr/local/java/include -I/usr/local/java/include/linux ThreadTool.c -c -o libThreadTool.so
    I could be wrong, but it looks like you're invoking gcc all wrong.
    1) You're using the -c flag which tells the compiler to only compile, yet you're trying to also link.
    2) The last time that I used gcc, I believe you had to use a special flag to tell it that you wanted a shared library... something like -G. (It's not smart like Kai's KCC or Forte).
    3) On top of all that, you may have to use a -thread option to make sure you are generating multi-thread safe code.
    I suggest taking a second look at the man pages for gcc.
    God bless,
    -Toby Reyelts

  • Extract Pages- and the Split- not doing what I expect them to

    I have a document created in Illustrator (CS4) which has multiple artboards. I want it split into multiple documents, one art board—> one document with only that artwork. When I use the Extract PAges… and the Split… comands to generate multiple documents, I get the multiple docs (same number of docs created as pages in original doc).
    Only thing is every doc has all the artboards and all the artwork as the original doc. I could understand all the artwork being there but all the artboards also?? What's going on?
    Appreciate any pointers on this.
    Trying to write a JSX to run in AI but struggling so far. Thread for AI solution started here: AS) export single page PDFs from multi-artboards

    I don't expect mind reading but I'l settle for careful reading
    I tried to explain how pages and artboards are qualitatively different objects only to be told they are the same thing and that's all I needed to say.
    I tried to explain that opening the very same file in Illustrator showed a lot more objects than it did in Acrobat. You probably don't remember because you breezed over something that you didn't think you needed to know because you were, at each stage, a step ahead of me (slow down already!).
    From my second post:
    I can't remember if Splitting gave enumerate files or the one file but either way ALL the artwork was in the enumerate files if they got made [.…] I ended up saving as CS3 .ai files which gives a Save artboards to seperate files option and, unlike the artboard range option on Save As PDF, it actually works.
    From my third post
    An artboard is not a page as far as Acrobat and Illustrator apps are concerned. I was trying to highlight the distinctly different way the two apps handle them. I can watch a one page with just one shape document in Acrobat become a 20 artboard, 40+ objects layout in Illustrator. Same document interpreted as one Page in Acrobat and 23 artboards in AI.
    I was on this forum because even a manual Document Menu> Split… command is not doing what I expected with the AI generated 23pp PDF file. I expected the 23 individual 'artboards' and content to each make a separate file.
    Thom Parker wrote:
    I don't remember you mentioning that you re-imported the PDF files into Illustrator.  This is an important detail. You also posted to an Acrobat scripting forum and never said you were not interested in an Acrobat Script.  You also never explained the problem you were seeing.  You were never clear.
    Covered that but note Illustrator doesn't import PDF files. .ai .eps and .pdf are all native files for Illustrator and just open, sometimes with an additional dialogue to choose a page from multiple pages. It imports .dwg, .svg and that sort of thing relying on translator plugins. This is the fourth time I'm saying I should have posted in Acrobat Win or Mac not scripting, apologies I was scripting when I made OP and probably frustrated. You were more clear it's true, clearly ignoring what I was getting at in each post re artboard cf. page objects.
    You see, in a PDF file each page has it's own content stream, i.e., a stream of vector graphics operators.  Graphics can be drawn anywhere in the coordinate space, but the page view is clipped by a crop rectangle.  So graphics can exist in the stream, but never be visible to the user because they are outside the crop.  I get the impression that in Illustrator the Artboards all exist in a single coordinate space? And that the conversion to PDF places this entire coordinate space into a single content stream. Then each page would be a different crop of the same content stream.  If this is the case then I believe there are PDF optimization operations in Acrobat that would fix your problem by removing all content outside the crop. 
    Yeah I've hacked lots of PDF files in AI. They use more than one clipping rect per page from memory. Correct, the artboards are defined in a single co-ord space it would seem — artboards are discretely and independently located on the document canvas and can even overlap each other. Yes those operations might work, I never though of that, I came across an Illustrator based solution early on in this thread. There's no conversion going on in Acrobat though I think, the file stays native PDF from AI to Acrobat and back to AI. As I've noted it's the way Acrobat displays or parses the data that in effect hides all the 'off-page' objects but open the same file in AI and it's all still there. 
    You know, we can't read minds, you actually have to explain what it is you need.
    I didn't know it, but I needed to get a confirmation on the artboardRange property bug in Illustrator CS4 and/or a confirmation that artboards are not treated as page objects, and I ended up having to lecture you on something you may have no interest in, sorry if I've been a pain. This is part of bigger bug elsewhere that I've been trying to get resolved or around on and off for a month. Every turn another bug, it gets confusing and frustrating at times

  • I click on a link, get a new blank page, not the info expected. Use AVG Free Ed, Windows 7 professional.

    I click on a link, and get a new blank page, not the info expected. I use AVG Free Edition, Windows 7 Professional. I have tried "open link in new tab" - no joy. Not all links are affected. It is not possible to say when a link is going to fail or work - it seems random.
    == This happened ==
    Every time Firefox opened
    == It just started to happen about 2 weeks ago

    I get the address as it should be as in attachment when I hover over the "FLIXTER" add on the right of screen. When I click it just comes out in a new window but BLANK. Open in IE then shows me the correct view. Puzzling. I have tried disapbling ans enabling java script in my options and sometimes this works then sometimes not??

  • The product I bought its not working as i expected, it doesn´t translate the exact information from pdf to excel, how can you help me or how can you return my money back....

    how can you help me

    What about adobé export PDF. ?
    Enviado desde mi iPhone
    El 07/05/2014, a las 23:00, Claudio González <[email protected]> escribió:
    The product I bought its not working as i expected, it doesn´t translate the exact information from pdf to excel, how can you help me or how can you return my money back....
    created by Claudio González in Adobe Reader - View the full discussion
    If you bought Reader, you were swindled, because it's a free program. And it has never been able of converting PDF files to any other format.
    Please note that the Adobe Forums do not accept email attachments. If you want to embed a screen image in your message please visit the thread in the forum to embed the image at https://forums.adobe.com/message/6363992#6363992
    Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page:
    To unsubscribe from this thread, please visit the message page at . In the Actions box on the right, click the Stop Email Notifications link.
    Start a new discussion in Adobe Reader by email or at Adobe Community
    For more information about maintaining your forum email notifications please go to http://forums.adobe.com/thread/416458?tstart=0.

  • HT201302 I am trying to import photos taken on my iPod Touch to my computer. I read the support article and when I connect my iPod the auto play dialogue box does not appear so I followed the steps to enable the behavior but my iPod is not listed. What ca

    Am trying to import photos taken with my iPod touch to my windows 7 computer. When I plug in my iPod the Auto play dialogue box doesn't come up. I read the related article and tried to enable the behavior but when I go to the autoplay section and to devices the iPod does not appear in the devices menue . What can I do next? Thanks

    So you tried here:
    iOS: Importing personal photos and videos from iOS devices to your computer
    Have you looked here:
    iOS: Unable to import photos or device not recognized as a camera

  • I just test drove a Lexus ES with the Entune system, and it not only didn't play the music I expected, it caused the iPod to become totally unresponsive, even my computer doesn't recognize it?  Is there a fix for this?

    I just test drove a Lexus ES with the Entune system, and it not only didn't play the music I expected, it caused the iPod to become totally unresponsive, even my computer doesn't recognize it?  Is there a fix for this?

    This problem sort of solved itself.  The iPod kept running until the battery went dead, and when I plugged it in to power this morning, it behaved normallyh.

  • How do i configure a FOR loop to have the behavior of the step Loop Type: Pass/Fail count?

    Hello,
    I'm using the Pass/Fail count set to one Pass to capture an event generated by my DUT.  I originally used a numerical compare step with the Looping type of Pass/Fail count to accomplish this.  Unfortunately the implementation changed and now I need to execute a few steps that can not be combined within one code module as before. Nor can these steps be put into a subroutine.  One of the steps executes a .NET asembly and I haven't figured out how to pass the reference to the subroutine.  When the subroutine is intered the reference is lost and the methode does not execute correctly.
    I have an evaluation function the exits the loop when the expected conditions are met. Everything works except for the Overall Pass/Fail result of the For loop.  If the loop exits due to the first numerical compare test passing, I want the loop overall execution to report as "Passed".  If the loop reaches it's predetermined number of iterations, the overall result needs to report as "Failed".  It would also be nice to have the radio button functionality of "Record Result of Each iteration".  Some conditions require a wait over a minute for the event to occur and I don't want to generate needless data for the report.
    Currently I get the pass/fail status for each For loop iteration, but only "Done" for each loop iteration.  I don't want the initial few failures to cause the test to fail.
    Does anyone know how to do this? Suggestions?
    Thanks,

    I have 2 steps in the loop that can not be combined into one step. This forces me to implement the behavior in some form of loop.  A While Loop could be an option.  I would need to pass the Step.Result.Status from the Multiple Numerical compaire step to the condition of the While Loop.  I tried to use the Step.TS.ID without success.  Some form of reference to the numerical compare step would be needed. I'm using a For Loop as I do want to limit the number of iterations of the loop.  In the case where the loop iterations are reached, the event I am trying to detect did not occur at the correct time and a failure needs to be reported.
    I came up with something based on my comments in the second post:
    1) To start with I configured a Locals.ForLoop_5 variable.  This is used to set the limit on the loop iterations and for comparison after the loop has finished executing. More on that later.
    2) The first step inside the loop invokes a method within a .NET assembly that has been packed in a DLL This method gets the required data from the DUT and stores it to a text file.
    3) The next step is the Multiple Numeric Limit step.  This step invokes a VI that extracts the data from the text file.  This step has been customized in several ways.
      i)  In Run Options, the Results Recording Option was disabled.  This prevents recording of "Failed" while the loop executes when waiting for the event to happen.
      ii) In Run Options, the Step Failure Causes Sequence Failure is unchecked.  Same reasoning as i)  These steps are not true failures.
      iii) A Post Action is configured to go to the nexxt step after the For Loop End step On Condition True with the logic of Step.Result.Status == "Passed".  This causes the loop to exit when the first "Passed" is encountered which corrolates with the event I'm trying to detect. On Conditon Fail remains set to default.
    4)  The step after the For Loop End is an expression step with everythin set to default except for the Status Expression logic set to: Locals.Loopindex < Locals.ForLoop_5 ? (Step.Result.Status = "Passed") : (Step.Result.Status = "Failed"). This step performs the overall Pass/Fail reporting for the For Loop.  If the number of loop iterations is less than the maximum it could have only gotten there by the previous logic triggered by the numerical compare passing, therefore "Passed".  If the loop index has reached the limit, then the event was not detected, therefore Failed.
    I have tested this work around with success, it just a pain to now have to implement this on my 40 some odd For Loops.
    If there is a better way, I'd still like to hear it.

  • Confused by the behavior on importing simple tagged text

    I have a tagged text file with the following content beween the dashed lines. (the lines are not part of the file). Both IText and BText are predefined paragraph sytles.
    <ASCII-WIN>
    Price <ParaStyle:IText>AA<cPosition:Superscript>aa<cPosition:> - <ParaStyle:BText>BB<cPosition:Superscript>bb<cPosition:>
    Once imported,  the result is not what I expected. Specifically,
    1. All text are imported with the BText paragraph style.
    2. It shows the "bb" as superscripted, but not the "aa".
    Why is that? And how can I have different styles for the AAaa part versus the BBbb part?
    This can be reproduced on CS5 and CS5.5. Didn't try any older versions.
    Thanks.

    When I think of it, the first behavior makes sense, because the text were specified as a continuous line without line break, they are treated as a single paragraph. And for a paragraph, only one paragraph can be used, and the one that is specified later, BText in this example, wiins.
    But still, why does the import routine ignores the superscript character style on "aa"  before the second  paragraph style tag?

  • Currently have JTextArea, but would like the output to be in a JTable...

    Hi there. I asked this question in the database section, but I ended up getting more questions and separating code, etc. Needless to say, my initial question went unanswered. So, for the purposes of this question, let me get this one thing out of the way:
    Yes, I know this is one big file, and that I should have the GUI and DB separated. However, this is for a small project that I'm working on, and for the moment, I'm not too worried about separating class files. As long as the program works as I want it too, so much the better for me.
    Now, on to the question at hand. Currently, I have a project that connects to a MySQL DB, and it displays the output from an SQL command in a JTextArea. It looks horribly ugly, as all the columns are not formatted properly. Take a look:
    http://img508.imageshack.us/img508/2193/testxe4.jpg
    Sure I can see columns, but I would love for the output to be displayed in a neat JTable, which is also much easier on the eyes.
    Here is the current code:
    package classes;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.border.*;
    import java.sql.*;
    import java.util.*;
    public class SQLClient extends JApplet {
         private Connection connection;
         private Statement statement;
         private JTextArea jtasqlCommand = new JTextArea();
         private JTextArea jtaSQLResult = new JTextArea();
         JTextField jtfUsername = new JTextField();
         JPasswordField jpfPassword = new JPasswordField();
         JButton jbtExecuteSQL = new JButton("Execute SQL Command");
         JButton jbtClearSQLCommand = new JButton("Clear");
         JButton jbtConnectDB1 = new JButton("Connect to Database");
         JButton jbtClearSQLResult = new JButton("Clear Result");
         Border titledBorder1 = new TitledBorder("Enter a SQL Command");
         Border titledBorder2 = new TitledBorder("SQL Execution Result");
         Border titledBorder3 = new TitledBorder("Enter Database Information");
         JLabel jlblConnectionStatus1 = new JLabel("");
         JLabel jlblConnectionStatus2 = new JLabel("Not Connected");
         public void init() {
              JScrollPane jScrollPane1 = new JScrollPane(jtasqlCommand);
              jScrollPane1.setBorder(titledBorder1);
              JScrollPane jScrollPane2 = new JScrollPane(jtaSQLResult);
              jScrollPane2.setBorder(titledBorder2);
              JPanel jPanel1 = new JPanel(new FlowLayout(FlowLayout.RIGHT));
              jPanel1.add(jbtClearSQLCommand);
              jPanel1.add(jbtExecuteSQL);
              JPanel jPanel2 = new JPanel();
              jPanel2.setLayout(new BorderLayout());
              jPanel2.add(jScrollPane1, BorderLayout.CENTER);
              jPanel2.add(jPanel1, BorderLayout.SOUTH);
              jPanel2.setPreferredSize(new Dimension(100, 100));
              JPanel jPanel3 = new JPanel();
              jPanel3.setLayout(new BorderLayout());
              jPanel3.add(jlblConnectionStatus1, BorderLayout.CENTER);
              jPanel3.add(jbtConnectDB1, BorderLayout.EAST);
              JPanel jPanel4 = new JPanel();
              jPanel4.setLayout(new GridLayout(4, 1, 10, 5));
              jPanel4.add(jtfUsername);
              jPanel4.add(jpfPassword);
              JPanel jPanel5 = new JPanel();
              jPanel5.setLayout(new GridLayout(4, 1));
              jPanel5.add(new JLabel("Username"));
              jPanel5.add(new JLabel("Password"));
              JPanel jPanel6 = new JPanel();
              jPanel6.setLayout(new BorderLayout());
              jPanel6.setBorder(titledBorder3);
              jPanel6.add(jPanel4, BorderLayout.CENTER);
              jPanel6.add(jPanel5, BorderLayout.WEST);
              JPanel jPanel7 = new JPanel();
              jPanel7.setLayout(new BorderLayout());
              jPanel7.add(jPanel3, BorderLayout.SOUTH);
              jPanel7.add(jPanel6, BorderLayout.CENTER);
              JPanel jPanel8 = new JPanel();
              jPanel8.setLayout(new BorderLayout());
              jPanel8.add(jPanel2, BorderLayout.CENTER);
              jPanel8.add(jPanel7, BorderLayout.WEST);
              JPanel jPanel9 = new JPanel();
              jPanel9.setLayout(new BorderLayout());
              jPanel9.add(jlblConnectionStatus2, BorderLayout.EAST);
              jPanel9.add(jbtClearSQLResult, BorderLayout.WEST);
              this.add(jPanel8, BorderLayout.NORTH);
              this.add(jScrollPane2, BorderLayout.CENTER);
              this.add(jPanel9, BorderLayout.SOUTH);
              jbtExecuteSQL.addActionListener(new ActionListener() {
              public void actionPerformed(ActionEvent e) {
              executeSQL();
              jbtConnectDB1.addActionListener(new ActionListener() {
              public void actionPerformed(ActionEvent e) {
              connectToDB();
              jbtClearSQLCommand.addActionListener(new ActionListener() {
              public void actionPerformed(ActionEvent e) {
              jtasqlCommand.setText(null);
              jbtClearSQLResult.addActionListener(new ActionListener() {
              public void actionPerformed(ActionEvent e) {
              jtaSQLResult.setText(null);
         private void connectToDB() {
              String driver = "com.mysql.jdbc.Driver";
              String url = "jdbc:mysql://localhost:3306/petstore2002";
              String username = jtfUsername.getText().trim();
              String password = new String(jpfPassword.getPassword());
              try {
                   Class.forName(driver);
                   connection = DriverManager.getConnection(url, username, password);
                   jlblConnectionStatus2.setText("Connected To Database");
              catch (java.lang.Exception ex) {
                   ex.printStackTrace();
         private void executeSQL() {
              if (connection == null) {
                   jtaSQLResult.setText("Please connect to a database first");
                   return;
              else {
                   String sqlCommands = jtasqlCommand.getText().trim();
                   String[] commands = sqlCommands.replace('\n', ' ').split(";");
                   for (String aCommand: commands) {
                        if (aCommand.trim().toUpperCase().startsWith("SELECT")) {
                             processSQLSelect(aCommand);
                        else {
                             processSQLNonSelect(aCommand);
         private void processSQLSelect(String sqlCommand) {
              try {
                   statement = connection.createStatement();
                   ResultSet resultSet = statement.executeQuery(sqlCommand);
                   int columnCount = resultSet.getMetaData().getColumnCount();
                   String row = "";
                   for (int i = 1; i <= columnCount; i++) {
                        row += resultSet.getMetaData().getColumnName(i) + "\t";
                   jtaSQLResult.append(row + '\n');
                   while (resultSet.next()) {
                        row = "";
                        for (int i = 1; i <= columnCount; i++) {
                             row += resultSet.getString(i) + "\t";
                        jtaSQLResult.append(row + '\n');
              catch (SQLException ex) {
                   jtaSQLResult.setText(ex.toString());
         private void processSQLNonSelect(String sqlCommand) {
              try {
                   statement = connection.createStatement();
                   statement.executeUpdate(sqlCommand);
                   jtaSQLResult.setText("SQL command executed");
              catch (SQLException ex) {
                   jtaSQLResult.setText(ex.toString());
         public static void main(String[] args) {
              SQLClient applet = new SQLClient();
              JFrame frame = new JFrame();
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              frame.setTitle("Interactive SQL Client");
              frame.getContentPane().add(applet, BorderLayout.CENTER);
              applet.init();
              applet.start();
              frame.setSize(800, 600);
              Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
              frame.setLocation((d.width - frame.getSize().width) / 2,
              (d.height - frame.getSize().height) / 2);
              frame.setVisible(true);
    }Right now it works fine, and I am planning on using this as an initial prototype for the presentation. Can I get some help on getting the output displayed into a JTable? How would I go abouts doing the conversion? I'm fairly new to Java (taking a course on it), and I'm worried that if I change one line of code the whole thing will get ruined and I'll need to start from scratch.

    -> It sounds like you're getting annoyed with the amount of people asking perfectly legitimate questions
    Your expectations are not legitimate. We attempt to understand your problem and give you the resources to solve the problem. Many times those resources are in the form of a tutorial or a reference to the API. We are not here to write code for you.
    I pointed you in the right direction. Its up to you do to some learning on your own. You have not made the slightest effort to understand how to use a JTable. You have not made the slightest effort to search the forum to see if you question has been asked before (it has).
    Your attitude and effort determines how much effort we make. Frankly you have made no effort whatsoever to solve you problem so as far as I am concerned you are on you own. Apparently I am not the only one who thinks you should be making more of an effort based on all the other advice you have received.

  • Saved VI file size changes when data is visible on a graph but not the default value

    If a VI is saved when data is visible on a graph, the file size is larger; even though the default is set to be a blank graph.  I have tested this in LabVIEW 8.6 and 2009.  If you load the larger file, the graph is blank as expected.  If this behavior is by design, it appears odd to me.
    To duplicate the issue:
    Create a blank VI.
    Add a Sine Waveform VI and set the number of samples to 1,000,000.
    Add a Waveform Graph VI that spans the entire monitor and connect it to the output of the Sine Waveform VI.
    Save the VI and note the file size.
    Run the VI.
    Save the VI and compare the size to the original size.
    The VI file size is larger.
    In the Waveform Graph, select “Reinitialize to default value.
    The VI file size returns to It’s original size.

    Your obeservation is correct, and expected behavior.
    This behavior is useful when you have inputs that you would like to set as defaults for the user.
    Obviously, if there is a value to be saved, it will require some memory to store the value.
    If the input is left empty by default, that memory is made available again.
    It may not be easy to think of a good use for this for a graph, but think about for numeric or string controls.
    What if the user isnt sure how they should input a certain parameter or value?
    You could store a default value so they could see how they should input their value.
    Message Edited by Cory K on 09-15-2009 11:12 AM
    Cory K

  • Xslt mystery.  Works in one environment, not the other

    Has anyone come across the following?
    First, clarification: The environments, though physically different are essentially the same. same os, libs, version of java, application server, etc. The difference is the one in which it works is at my workstation, and where it doesn't is our lab. All the simple explanations have been investigated (no view private files being picked up vs version controlled, library versions, etc).
    I don't believe I even need to explain the functionality. Basically:
    <xsl:template match="/name1/name2">
    works (ie matches the node) at my desk while it doesn't in the lab.
    Everything else is the same. The xslt executes in the lab. There are no exceptions. Debug statements verify the xml being parsed is the one being processed. But this template is never invoked, so it falls back to the
    <xsl:template match ="@*|node()">
    template.
    I checked the System.property javax.xml.transform.TransformerFactory to see if maybe they had a different implementation than at my workstation, but the value was the same; no value, which means we are both running the default transformer. We are also running the same java (1.5.0_06_b05).
    Any ideas of what/where to look? I realize that I haven't given alot of info, but that's because EVERYTHING is the same.

    Ok, I found the difference that is causing the xslt not to work. But this just makes it more confusing. The scenario where it DOESN'T work seems as if it should, and the scenario in which id DOES work seems as if it shouldn't!! Is there anyone who might be able to explain the behavior.
    First, the xslt's. In both environments they are exactly the same. Both have a default namespace defined: ie xmlns="some uri A"
    In Environment 1
    There is no default namespace defined in the xml; that is there is no xmlns="any uri". However, there is a prefix defined
    xmlns:xis="some uri A"
    (note, "some uri A" points to one of our own defined schemas and is the same in both the xslt and xml)
    In Environment 2
    There is a default namespace defined in the xml exactly as is defined in the xslt.
    So, when an xml document comes in that has
    <abc>
    <def/>
    </abc>
    And the template is
    <xsl:template match="/abc/def">
    I would think that environment 1 wouldn't match, because there is no default namespace defined, but the template does define a default namespace, "some uri A" which I think is applied to the /abc/def. But this is the case that works. I'd expect to have to use <xsl:template match="xis:/abc/def">
    I'd also think that environment 2 would match, because the xml and xslt both define the same default namespace, so /abc/def means /abc/def, but this is the case where it doesn't work.
    Can anyone set me straight on what is going on here? Sorry I don't cut and paste the source, but I can't. It's really this simple. In environment 1, if I remove the xis from the namespace definition in the xml, it "breaks" and works the same as in environment 2.

  • Click on app link goes to App Store but not the app

    Since I updated to iOS 6, clicking on a direct link to an app gets me to the store but not the particular app.
    Then I have to remember the exact name and search for it. In previous iOS I could get to the app directly.
    This is most annoying. How do I change this behavior?

    Well, it still is not working as I expected.
    Sometimes, if I click on the link, it will go to the app store and produce a blank white screen.
    If I go back to the link, in an email or web page, and try again, then the desired app will pop up when it goes to the app store. Sometimes the app store will just quit. Then if I go back to the store it will show the desired app.

Maybe you are looking for

  • I am not able to open docx files

    I have some docx files (on dvd) from days gone by (good-bye to Windows&Word), and I can't get Pages '09 to open them. It just stalls, it has the progress bar and the beach ball is spinning, but nothing happens. I have to go to the dock and force quit

  • Cannot download pre-ordered album

    After using the link in the iTunes Email i received, or using the 'search for available downloads' options in the store menu: it tries to connect to the store. After a while it stops and says 'the connection to the store was broken, try again later.'

  • How to get rid of new menu button on far right side of toolbar

    Honestly, I don't know why developers can't offer us new features which we can use or not use, by choice. Instead, things are forced upon us. Would someone please tell me how to get rid of the new menu button on the right side of the toolbar? There d

  • Can I use this in EJB

    I am using log4j in my project. like Logger.error(this, "Error occured"); I am told that in EJB using 'this' is not advisable. Is it so? why?

  • Customer Invoice Clearing against Advance

    Dear All, I have a scenario, in which for Eg: We have a customer advance of 100000 Rs. The 1st invoice is raised for 10000, and we clear it against this advance and remaining left is 90000 rs. Now is their any Tcode in which I can setoff these invoic