Swing GUI for Javadoc

Hi everyone,
I'm trying to learn some basic IO and Swing. My project is to make a Swing GUI for javadoc. It's supposed to run at least under W2K and XP.
The Swing part is going fine, but I can't seem to get IO-part working.
I tried working with the Runtime- and the Process-class, but I don't can't seem to execute javadoc or read any command-line output. Here's a sample of code that compiles ok, but doesn't do anything.
try {
Process p = Runtime.getRuntime().exec("javadoc");
InputStream in = p.getInputStream();
String s = in.toString();
System.out.println(s);
System.out.println();
System.out.println(process.waitFor());
System.out.println();
System.out.println(process.exitValue());
System.out.println();
System.out.println(""+process);
} catch (Exception e) {
System.out.println("error");
if anyone has any tips, suggestions or simple code samples, I would be very happy to hear from you.

Alright, I figured out how to read the inputstream, but
I still get an error:
Windows 2000
start
<ERROR>
javadoc: No packages or classes specified.
and the program doesn't terminate for some reason.
here's the new sourcecode:
import java.io.*;
public class JavaDocCommander {
     public static void main(String[] args) {
          System.out.println(System.getProperty("os.name"));
          System.out.println("start");
          new Test();
          System.out.println("slut");
class Test{
     public Test(){
          try {           
Runtime rt = Runtime.getRuntime();
Process proc = rt.exec("javadoc");
InputStream stderr = proc.getErrorStream();
InputStreamReader isr = new InputStreamReader(stderr);
BufferedReader br = new BufferedReader(isr);
String line = null;
System.out.println("<ERROR>");
while ( (line = br.readLine()) != null)
System.out.println(line);
System.out.println("</ERROR>");
int exitVal = proc.waitFor();
System.out.println("Process exitValue: " + exitVal);
} catch (Throwable t)
t.printStackTrace();
          

Similar Messages

  • Beginner Guide for developing GUI for Pocket PC

    Hi all,
    I have been developing Advanced Swing GUI for seven years now.
    The time has come to write some to Pocket PC, and it doesn't look good.
    I've searched the net for a mere beginners-guide and found nothing
    there is no single A-to-Z tutorial which will tell you what to download and how to write you first program.
    I am offering 15 Duke dollars for the kind member that will be kind enough to write a short "idiot's guide for writing a little gui app for pocket pc" post, including exactly what to download, how to configure, and what to write.
    Such post would help me and the rest greatly
    Thank you very much
    Eyal Katz

    Guide to installing and using CrE-ME JVM on a Handheld device:
    Step A: Where to download the CrE-ME JVM from?
    1. NSIcom.com has a 30-day free trail version of CrE-ME JVM and can be downloaded from the following link by clicking on �Download Free Evaluation�:
    http://www.nsicom.com/Default.aspx?tabid=159
    The version I downloaded was CrE-ME 4.1
    2. To download additional specific packages for applications that use SWING, RMI, etc. Click on �View all downloads� and download from the packages listed.
    Step B: Installing the JVM.
    1. Connect the device to a desktop.
    2. Install the CrE-ME version downloaded as you install any other application on your desktop.
    3. While installing, the installer program will ask if you want to install at the default location or to specify a path. (I guess installing to the default location will make life easier). Therefore, the JVM will be installed on the handheld device.
    4. Copy the additional packages downloaded to "\Windows\CrEme\lib" directory on the handheld device. Double click on the package (.CAB) file and it will configure itself.
    5. Test the sample applications given in �\Windows\CrEme\demos\� to check the proper installation of the JVM.
    Step C: Executing your applications.
    C.1 Method 1
    1. Write and compile the program in any IDE but remember to compile the programs with jdk1.4 as CrE-ME 4.1 supports JDK 1.4 or earlier.
    2. Create a jar file of your application.
    3. Write a link file (.lnk), specifying the classpath and the CrEme exe file in the following format:
    255#"\Windows\CrEme\bin\CrEme.exe" -Of -classpath <full JAR file path> <main class name>
    Ex: 255#"\Windows\CrEme\bin\CrEme.exe" -Of -classpath �\My Documents\Menu.jar� Menu
    -Of is used to redirect the console output to be redirected to jscpout.txt file located in the root directory of your device. Use -Ob if you are using a console based application.
    255 specifies the number of characters in the file, but instead of counting the characters you can use 255 which is the maximum (in general, it is seen that a higher value works but not a number less than the number of characters)
    Also note that the classpath is in single quotes
    4. Copy the link file to the handheld device and then double click on the link file to run the application and if the application doesn�t show up, you know where to look for the errors. The jscpout.txt file created in the root folder of your device due to the �Of parameter used in the link file, will contain the console output and thus the errors.
    C.2 Method 2
    1. Write and compile the program in any IDE but remember to compile the programs with jdk1.4 as CrE-ME 4.1 supports JDK 1.4 or earlier.
    2. Create an executable jar file of your application using the Manifest.mf file to specify the main class.
    Ex: Main-Class: <main class name>
    Also remember to hit the return (enter) key at the end of manifest file.
    3. Copy the jar file to the handheld device and double click on it to execute.
    4. In case the output doesn�t show up, it could mean that there were errors executing the application and to check for errors use Method 1.
    Useful link:
    1. CrEme FAQ, http://www.nsicom.com/Default.aspx?tabid=231

  • Java GUI for a shell script

    I have a file with passwd format.I made a script for this file that is working as I wanted it to work.I have a list of options and each time I give an option,the script is doing something(for example,if I press "b" it makes something and if I press "a" it makes something else).All the results are an output from the file.
    My question is how can I create a GUI in java for this script.For example if I want the script to do what it would do if I pressed the "a" button on my keyboard,but not by pressing "a",but by choosing from a drop down list or some other graphical feature(by ticking a check box,clicking a button etc).Can I do this with java?
    Lazaros

    Hi,
    I understand you can create a Java Swing gui for a bash shell script which takes both complex input and writes output to the stdout & files, to be specific. Is that correct?
    If yes, could you give a simple example. Say for the following shell script.
    #!/bin/sh
    printf "Enter input\n"
    i=0
    while [ $i -ne 1 ]; do
    read $inputVar
    if [  "$inputVar" == "y" ]; then
    printf "You typed yes\n"
    i=1
    elif [  "$inputVar" == "y"  ]; then
    printf "you typed no\n"
    i=1
    else
    printf "Enter a valid character\n"
    i=0
    fi
    done
    Could you also point to some URL's which might help? Googling for "Java Gui for shell script" returns this as the first page, others dont really help. Googling "GUI for shell script" returns all other gui toolkits for xes but thats not what I want. I want a cross platform (nixes, Win*, MacOS* ) gui for a shell script ( which I plan to run using cygwin etc).
    TIA
    Vinod

  • Recommended Tool for devloping Swing GUI's?

    Hello everyone.
    I was wondering what a good tool kit was for building swing gui's?
    I heard NetBean was one, any others you recommend?
    Currently I use Rational Software Architect to do all my java coding but I don't see any options in this IDE for creating drag and drop GUI development.
    Thanks!

    You have 2 very different answers to consider. Before making your final decision, I'd ask yourself, which of the two responders is a Swing expert and which isn't. That should put a whole lot of added weight to one of the recs. Just my two scheckel's worth.

  • Anything simple I can add to a GUI for some extra credit?

    I had to write a GUI for my COMP class this time, and if we add anything extra, we can get some extra points..which would be quite nice.
    I have the GUI made and working as we were shown how to do, and now I would like to add some extra things to make it better.
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class Tuition extends JFrame
        private JLabel stateResL, credsL, typeL, tuitFeeL, actFeeL;
        private JTextField stateResTF, credsTF, typeTF, tuitFeeTF, actFeeTF;
        private JButton calculateB, exitB;
        private CalculateButtonHandler cbHandler;
        private ExitButtonHandler ebHandler;
        public Tuition()
            stateResL = new JLabel ("Is Student a TN State Resident? 1 = yes, 0 = no ", SwingConstants.RIGHT);
            credsL = new JLabel ("Enter number of credits presently being taken: ", SwingConstants.RIGHT);
            typeL = new JLabel ("Is student an undergraduate = 0, or graduate student = 1? ", SwingConstants.RIGHT);
            actFeeL = new JLabel ("Activity Fee: ", SwingConstants.RIGHT);
            tuitFeeL = new JLabel ("Tuition amount owed = $", SwingConstants.RIGHT);
            //text fields
            stateResTF = new JTextField(10);
            credsTF = new JTextField(10);
            typeTF = new JTextField(10);
            actFeeTF = new JTextField(10);
            tuitFeeTF = new JTextField(10);
             //calculate button
            calculateB = new JButton ("Calculate Tuition");
            cbHandler = new CalculateButtonHandler();
            calculateB.addActionListener(cbHandler);
            //exit button
            exitB = new JButton ("Exit");
            ebHandler = new ExitButtonHandler();
            exitB.addActionListener(ebHandler);
            //set title of window
            setTitle("Tuition and extra Fees");
            //get container
            Container pane = getContentPane();
            //set layout
            pane.setLayout (new GridLayout (6, 2));
            //place components in pane
            pane.add (stateResL);
            pane.add (stateResTF);
            pane.add (credsL);
            pane.add (credsTF);
            pane.add (typeL);
            pane.add (typeTF);
            pane.add (tuitFeeL);
            pane.add (tuitFeeTF);
            pane.add (actFeeL);
            pane.add (actFeeTF);
            pane.add (calculateB);
            pane.add (exitB);
            setSize (WIDTH, HEIGHT);
            setVisible (true);
            setDefaultCloseOperation(EXIT_ON_CLOSE);
        private class CalculateButtonHandler implements ActionListener
            public void actionPerformed (ActionEvent e)
                //computes activity fee and tuition and sets them to respective variables
                double tuition = 0;
                double actFee = 0;
                int credits, stateRes, type;
                type = Integer.parseInt(typeTF.getText());
                stateRes = Integer.parseInt(stateResTF.getText());
                credits = Integer.parseInt(credsTF.getText());
                if (credits >= 6)
                       actFee = 44;
                else
                    actFee = 6 * credits;
                if (stateRes == 0)
                        if (type == 1 || type == 0)
                            tuition = ((448 * credits) + actFee);
                else if (stateRes == 1)
                        if (type == 0)
                            tuition = ((241 * credits ) + actFee);
                        else if (type == 1)
                            tuition = ((343 * credits ) + actFee);
                    actFeeTF.setText ("" + actFee);
                    tuitFeeTF.setText ("" + tuition);
            private class ExitButtonHandler implements ActionListener
                public void actionPerformed (ActionEvent e)
                    System.exit(0);
    }I don't care for something way out of my league (I'm only in my second semester of actually doing "tough" stuff. Maybe something that would change the colors of the text fields where the questions are, or change the color of the font printed, or change the font type, maybe add a logo or something for a school (it's a tuition calculator).
    I looked through the API but reading over class names doesn't do much for me, and I searched Google a bit but most of the stuff I found seemed pretty difficult/beyond my knowledge.

    alright...I fixed the messy issue, but I don't know how to setup the action listeners or whatever...
    I need my calculate tuition method to work using the radio buttons, and I don't know how to set up the listeners correctly.
    I can't find a single example on the internet that does anything like what I'm doing that I can use as a reference. I need something using radio buttons that calculates another number based on the results of the radio buttons...like what mine should do.
    This has got to be a noob question, but I just can't get it to work....
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class Tuition extends JFrame
        private JLabel stateResL, credsL, typeL, tuitFeeL, actFeeL;
        private JTextField stateResTF, credsTF, typeTF, tuitFeeTF, actFeeTF;
        private JButton gradB, calculateB, exitB;
        private CalculateButtonHandler cbHandler;
        private ExitButtonHandler ebHandler;
        private StateResButtonHandler srbHandler;
        private NonStateResButtonHandler nsrbHandler;
        private UndGradButtonHandler ugbHandler;
        private GradButtonHandler gbHandler;
        /** extra */
        JScrollBar scrollbar_h_1;
        JScrollBar scrollbar_v_1;
        JRadioButton undGradRB, gradRB, stateResRB, nonStateResRB;
        ButtonGroup radioGroup1, radioGroup2;
        static String stateResString = "Resident";
        static String nonResString = "Non-Resident";
        static String undGradString = "Undergraduate";
        static String gradString = "Graduate";
        public Tuition()
            getContentPane().setFont(new Font("Arial", Font.ITALIC, 12));
            getContentPane().setBackground(Color.blue);
            stateResL = new JLabel ("Is Student a TN State Resident? ", SwingConstants.RIGHT);
            credsL = new JLabel ("Enter number of credits presently being taken: ", SwingConstants.RIGHT);
            typeL = new JLabel ("Is student an undergraduate, or graduate student? ", SwingConstants.RIGHT);
            actFeeL = new JLabel ("Activity Fee: ", SwingConstants.RIGHT);
            tuitFeeL = new JLabel ("Tuition amount owed = $", SwingConstants.RIGHT);
            //text fields
            credsTF = new JTextField(10);
            actFeeTF = new JTextField(10);
            tuitFeeTF = new JTextField(10);
             //calculate button
            calculateB = new JButton ("Calculate Tuition");
            cbHandler = new CalculateButtonHandler();
            calculateB.addActionListener(cbHandler);
            //exit button
            exitB = new JButton ("Exit");
            ebHandler = new ExitButtonHandler();
            exitB.addActionListener(ebHandler);
            radioGroup1 = new ButtonGroup();
            JRadioButton stateResButton = new JRadioButton(stateResString);
            stateResButton.setMnemonic(KeyEvent.VK_B);
            stateResButton.setActionCommand(stateResString);
            stateResButton.setSelected(true);
            JRadioButton nonResButton = new JRadioButton(nonResString);
            nonResButton.setMnemonic(KeyEvent.VK_B);
            nonResButton.setActionCommand(nonResString);
            radioGroup1.add (stateResButton);
            radioGroup1.add (nonResButton);
            radioGroup2 = new ButtonGroup();
            JRadioButton undGradButton = new JRadioButton(undGradString);
            undGradButton.setMnemonic(KeyEvent.VK_B);
            undGradButton.setActionCommand(undGradString);
            undGradButton.setSelected(true);
            JRadioButton gradButton = new JRadioButton(gradString);
            gradButton.setMnemonic(KeyEvent.VK_B);
            gradButton.setActionCommand(gradString);
            radioGroup2.add(undGradButton);
            radioGroup2.add(gradButton);
            srbHandler = new StateResButtonHandler();
            stateResButton.addActionListener(stateResString);
            nrbHandler = new NonResButtonHandler();
            nonResButton.addActionListener(nonResString);
            ugbHandler = new UndGradButtonHandler();
            undGradButton.addActionListener(undGradString);
            gbHandler = new GradButtonHandler();
            gradButton.addActionListener(gradString);
            //set title of window
            setTitle("Tuition and extra Fees");
            //get container
            Container pane = getContentPane();
            //set layout
            pane.setLayout (new GridLayout (6, 2));
            JPanel radioPanel = new JPanel(new GridLayout(0, 1));
            radioPanel.add(stateResButton);
            radioPanel.add(nonResButton);
             JPanel radioPanel2 = new JPanel(new GridLayout(0, 1));
             radioPanel2 = new JPanel (new GridLayout(0, 1));
             radioPanel2.add (undGradButton);
             radioPanel2.add (gradButton);
            //place components in pane
            pane.add (stateResL);
            add(radioPanel);
            pane.add (credsL);
            pane.add (credsTF);
            pane.add (typeL);
            add(radioPanel2);
            pane.add (actFeeL);
            pane.add (actFeeTF);
            pane.add (tuitFeeL);
            pane.add (tuitFeeTF);
            pane.add (calculateB);
            pane.add (exitB);
            setSize (WIDTH, HEIGHT);
            setVisible (true);
            setDefaultCloseOperation(EXIT_ON_CLOSE);
            /** EXTRA - EXTRA - EXTRA */
            calculateB.setToolTipText("Click this button to calculate tuition and activity fee.");
            exitB.setToolTipText("Click this button to exit the program.");
        private class CalculateButtonHandler implements ActionListener
            public void actionPerformed (ActionEvent e)
                //computes activity fee and tuition and sets them to respective variables
                double tuition = 0;
                double actFee = 0;
                int credits, stateRes, type;
                type = Integer.parseInt(typeTF.getText());
                stateRes = Integer.parseInt(stateResTF.getText());
                credits = Integer.parseInt(credsTF.getText());
                if (credits >= 6)
                       actFee = 44;
                else
                    actFee = 6 * credits;
                if (stateRes == 0)
                        if (type == 1 || type == 0)
                            tuition = ((448 * credits) + actFee);
                else if (stateRes == 1)
                        if (type == 0)
                            tuition = ((241 * credits ) + actFee);
                        else if (type == 1)
                            tuition = ((343 * credits ) + actFee);
                    actFeeTF.setText ("" + actFee);
                    tuitFeeTF.setText ("" + tuition);
            private class ExitButtonHandler implements ActionListener
                public void actionPerformed (ActionEvent e)
                    System.exit(0);
            private class StateResButtonHandler implements ActionListener
                public void actionPerformed (ActionEvent e){
            private class NonStateResButtonHandler implements ActionListener
                public void actionPerformed (ActionEvent e){
            private class UndGradButtonHandler implements ActionListener
                public void actionPerformed (ActionEvent e) {
            private class GradButtonHandler implements ActionListener
                public void actionPerformed (ActionEvent e) {
    }the calculateB and exitB listeners work, but I have nothing setup for the others that works. And the calculate button doesn't work because it isn't getting any info from the buttons.
    I get addActionListener(Java.awt.event.ActionListener) in Javax.swing.AbstractButton cannot be applied to (java.lang.String). on the listeners I attempted to add within the constructor....

  • Loading large files in Java Swing GUI

    Hello Everyone!
    I am trying to load large files(more then 70 MB of xml text) in a Java Swing GUI. I tried several approaches,
    1)Byte based loading whith a loop similar to
    pane.setText("");
                 InputStream file_reader = new BufferedInputStream(new FileInputStream
                           (file));
                 int BUFFER_SIZE = 4096;
                 byte[] buffer = new byte[BUFFER_SIZE];
                 int bytesRead;
                 String line;
                 while ((bytesRead = file_reader.read(buffer, 0, BUFFER_SIZE)) != -1)
                      line = new String(buffer, 0, bytesRead);
                      pane.append(line);
                 }But this is gives me unacceptable response times for large files and runs out of Java Heap memory.
    2) I read in several places that I could load only small chunks of the file at a time and when the user scrolls upwards or downwards the next/previous chunk is loaded , to achieve this I am guessing extensive manipulation for the ScrollBar in the JScrollPane will be needed or adding an external JScrollBar perhaps? Can anyone provide sample code for that approach? (Putting in mind that I am writting code for an editor so I will be needing to interact via clicks and mouse wheel roatation and keyboard buttons and so on...)
    If anyone can help me, post sample code or point me to useful links that deal with this issue or with writting code for editors in general I would be very grateful.
    Thank you in advance.

    Hi,
    I'm replying to your question from another thread.
    To handle large files I used the new IO libary. I'm trying to remember off the top of my head but the classes involved were the RandomAccessFile, FileChannel and MappedByteBuffer. The MappedByteBuffer was the best way for me to read and write to the file.
    When opening the file I had to scan through the contents of the file using a swing worker thread and progress monitor. Whilst doing this I indexed the file into managable chunks. I also created a cache to further optimise file access.
    In all it worked really well and I was suprised by the performance of the new IO libraries. I remember loading 1GB files and whilst having to wait a few seconds to perform the indexing you wouldn't know that the data for the JList was being retrieved from a file whilst the application was running.
    Good Luck,
    Martin.

  • Front End (GUI) for Java Web Based Appl.

    Hi Gurus,
    I am new to Java. Can anybody tell me, what is the front end(GUI) used in Java web based applications? I was told that Swings/Applets are rarely used. Is there are a 3rd party took to design GUI for Java based applications?
    Chooti Baba

    sunilmp wrote:
    U mean to say, for JSP/Servlets, "Web based application" as well as "JSP/Servlet" usually implies that the client is a simple web browser.
    we cannot have swing as front end?You can use Swing inside an Applet inside a web application, but usually that's not needed, as you already have a client application that's quite powerful (the browser).

  • (Youtube-) Video in a Swing GUI

    Hey everyone,
    I'm currently trying to play a video in my Swing GUI with JMF but I really can't get it to work.
    With the help of google I got this far:
    import java.awt.BorderLayout;
    import java.awt.Component;
    import java.io.IOException;
    import java.net.MalformedURLException;
    import java.net.URL;
    import javax.media.CannotRealizeException;
    import javax.media.Manager;
    import javax.media.NoPlayerException;
    import javax.media.Player;
    import javax.swing.JFrame;
    public class MediaPanel extends JFrame {
        public MediaPanel() {
            setLayout(new BorderLayout()); // use a BorderLayout
            // Use lightweight components for Swing compatibility
            Manager.setHint(Manager.LIGHTWEIGHT_RENDERER, true);
            URL mediaURL = null;
            try {
                mediaURL = new URL("http://www.youtube.com/watch?v=Q7_Z_mQUBa8");
            } catch (MalformedURLException ex) {
                System.err.println(ex);
            try {
                // create a player to play the media specified in the URL
                Player mediaPlayer = Manager.createRealizedPlayer(mediaURL);
                // get the components for the video and the playback controls
                Component video = mediaPlayer.getVisualComponent();
                Component controls = mediaPlayer.getControlPanelComponent();
                if (video != null) {
                    add(video, BorderLayout.CENTER); // add video component
                if (controls != null) {
                    add(controls, BorderLayout.SOUTH); // add controls
                mediaPlayer.start(); // start playing the media clip
            } // end try
            catch (NoPlayerException noPlayerException) {
                System.err.println("No media player found");
            } // end catch
            catch (CannotRealizeException cannotRealizeException) {
                System.err.println("Could not realize media player");
            } // end catch
            catch (IOException iOException) {
                System.err.println("Error reading from the source");
            } // end catch
        } // end MediaPanel constructor
    }But all I get is errors:
    Warning: The URL may not exist. Please check URL
    No media player found
    Can you please please help me get this working? I would really appreciate a little walkthrough
    Best regards,
    Patrick
    Edited by: 954807 on Aug 24, 2012 6:52 AM

    Just use \ tags. People don't like to go to external sites.
    I really advise you to consider using JavaFX 2 here. Swing is old and not really supported anymore, JMF is also old and absolutely not supported anymore.                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • SAP GUI for Mac OS X 10.4

    I want to upgrade my Macs to Apples current operating system Mac OS X 10.4.1 Tiger. I had read few weeks ago, the JAVA-Implementation doesn't work with any SAP GUI for Java. SAP has recommended, to still work with Mac OS X 10.3.9 and SAP GUI for Java 6.30 Revision 8.
    When will be available a working SAP GUI for Mac OS X 10.4.1 Tiger ? Has someone informations ?

    Hello all,
    I completely understand the impact of the missing Mac support. I try to explain the reason for the current situation and give an outlook.
    Starting in summer 2004, the SAPGUI development team and test labs have dedicated a significant amount of time in testing on Mac OS X 10.4 preview versions, reporting bugs and pushing Apple to fix them. We opened more than 20 bug reports, which were not exclusively related to SAP GUI, just plain JFC/Swing issues. Unfortunately two show-stoppers for SAP GUI were left at the time Apple shipped Mac OS X 10.4.
    Since April this year we are running more tests on developer preview versions of the Java 1.4.2 Release 2, which is supposed to address these issues.
    With developer preview 3, there are no severe open issues left and we are just waiting for Apple to ship the final version of JRE 1.4.2 Release 2.
    Apple has not disclosed any shipment schedules in the past and so we have not been able to plan for something. If we would have known in advance, that the final version will be that long after developer preview 3, we would have started a beta seed based on a TEA (test and evaluation agreement) at the time developer preview 3 was available (beginning of August).
    Last week Apple has indicated that the final version of Java 1.4.2 Release 2 is expected to become available every day now. I hope Apple is right and this thread will be obsolete soon. SAP GUI for Java 6.40 rev 4 including the Mac OS X version is already waiting on the loading ramp.
    If there is no final version of Java 1.4.2 Release 2 by end of September we will provide an unsupported SAPGUI based on a test and evaluation agreement.
    Best regards
    Rolf-Martin

  • In this case, can I modify swing GUI out of swing thread?

    I know the Swing single thread rule and design (Swing is not thread safe).
    For time-consuming task, we are using other thread to do the task and
    we use SwingUtilities.invokeAndWait() or SwingUtilities.invokeLater (or SwingWorker) to update Swing GUI.
    My problem is, my time-consuming task is related to Swing GUI stuff
    (like set expanded state of a huge tree, walk through entire tree... etc), not the classic DB task.
    So my time-consuming Swing task must executed on Swing thread, but it will block the GUI responsivity.
    I solve this problem by show up a modal waiting dialog to ask user to wait and
    also allow user to cancel the task.
    Then I create an other thread (no event-dispatch thread) to do my Swing time-consuming tasks.
    Since the modal dialog (do nothing just allow user to cancel) is a thread spawn by
    Swing event-dispatch thread and block the Swing dispatch-thread until dialog close.
    So my thread can modify Swing GUI stuff safely since there are no any concurrent access problem.
    In this case, I broke the Swing's suggestion, modify Swing stuff out of Swing event-dispatch thread.
    But as I said, there are no concurrent access, so I am safe.
    Am I right? Are you agree? Do you have other better idea?
    Thanks for your help.

    If you drag your modal dialog around in front of the background UI, then there is concurrent access: paint requests in your main window as the foreground window moves around.

  • Creating Undo Menu on Swing GUI

    Undo Menu is to be Created on Swing GUI on the Graphics. In the Tutorial, Undo with Text is given. But on implementing the logic of Undo with Text , some Errors come.

    You can use javax.swing.undo.* stuff only with classes implementing
    javax.swing.text.Document interface.
    To add undo/redo functionality for some Graphic components you should program this mechanism by yourself.
    So create your own object model, track all changes and implement/add appropriate listeners.

  • Need help with threading in Swing GUI !!!

    I've written an app that parses and writes
    files. I'm using a Swing GUI. The app
    could potenially be used to parse hundreds or even
    thousands of files. I've included a JProgressBar
    to monitor progress. The problem is when I parse
    a large number of files the GUI freezes and only
    updates the values of the progress bar when the
    parsing and writing process is finished.
    I assume I need to start the process in a seperate thread. But, I'm new to threads and I'm not sure
    whether to start the Progressbar code in a seperate
    thread or the parsing code. As a matter of fact I really
    don't have any idea how to go about this.
    I read that Swing requires repaints be done in the
    event dispatch thread. If I start the parsing in a seperate
    thread how do I update the progressbar from the other
    thread? I'm a thread neophyte.
    I need a cigarette.

    In other words do this:
    Inside event Thread:
    handle button action
    start thread
    return from action listener
    Inside worker Thread:
    lock interface
    loop
    perform action
    update progress bar
    unlock interface
    return from worker ThreadDoesn't updating the progress bar (and locking/unlocking the interface components) from within the worker thread violate the rule that you shouldn't mess with Swing components outside the event thread? (Do I have that rule right?)
    In any case, is there any way to just post some kind of event to the progress bar to update it from within the worker thread, thereby insuring that the GUI progress bar update is being invoked from the event thread? This would also obviate the need to use a timer to poll for an update, which I think is a waste especially when the monitored progress is at a variable rate, (or for number crunching, is executing on different speed machines).
    Also, doesn't using invokeLater() or invokeAndWait() still block the event dispatching thread? I don't understand how having a chunk of code started in the event thread doesn't block the event thread unless the code's executed in a "sub-thread", which would then make it not in the event thread.
    I'm also looking to have a progress bar updated to monitor a worker thread, but also want to include a "Stop" button, etc. and need the event queue not to be blocked.
    The last thing I can think of is to implement some kind of original event-listener class that listens to events that I define, then register it with the system event queue somehow, then have the worker thread post events to this listener which then calls setValue() in the progress bar to insure that the bar is updated from the event queue and when I want it to be updated. I don't know yet if it's possible to create and register these kinds of classes (I'm guessing it is).
    Thanks,
    Derek

  • Java GUI for Unix not showing . files

    we have discovered a strange behaviour with sapgui 7.10 rev 8 on unix (AIX and Solaris). You can't see and browse to folders starting with a . (e.g. .abc) and also files with a . are not listed in the file open dialog (for attaching files via cv02n). Does anybody experience the same behaviour and probabely has found a setting to change it?
    Thanks for any help
    Axel

    Hi Axel,
    it sounds a bit odd that this CAD integration software is writing files to hidden folders but the user later is forced to navigate inside there.
    SAP GUI for Java inherits the file chooser dialog from the Swing framework part of Java. Sun seems to have decided, that by default, hidden files and folders should not be shown.
    I am hesitating to generally switch on showing hidden files and folders because it will irritate most end users.
    We are looking into a way to add the option to switch on showing hidden files and folders by the user.
    Btw, the user can navigate into a hidden folder by entering its name and hitting return, from there the user can navigate as usual. So it is not required to enter a complete path.
    Best regards
    Rolf-Martin

  • Visual Swing Designer (for Eclipse)

    Hi there
    We've developed a client software with JBuilder. Now we want to move
    the whole project to eclipse.
    Is there a good plugin for Eclipse to design Swing applications? I haven't found one so far.
    JBuilder has a Swing designer, and it is very usable for us. Eclipse
    hasen't such a Swing designer...
    It could also be a external tool, to design our Swing Panels. But it
    has to be a visual Designer tool for swing, like the one for VisualStudio and co.
    Does anybody know a good Designer WORKING Tool? Maybee as plugin for eclipse?
    Greetings,
    Adrian

    Hi,
    It would be good to have some feedback about Swing GUI builders for Eclipse, are they usable and good. I heard much good things on Eclipse and am curious to try (althought NetBeans are still very good for me), but I develop Swing application and porting to SWT is unacceptable for me (it is not so advanced as Swing and I need many features that are in Swing only).

  • Somewhat new to Java -- Given the task to create a GUI for a test.

    Hello there, I am a freshman student, in a Java class; the semester is coming to an end. In our project, we were assigned three parts to complete a program, that basically hands out a test. [I believe someone else has asked questions about a similar problem before, but not towards my situation.]
    The topic I chose to work with was the GUI for the program,and I'm already hitting snags. The issue is..well, probably the fact I get sort of lost when it comes to calling other methods, or just stupid mistakes to begin with. Some of the options we're faced with that we can put into the program are, for example, creating back/next buttons so the user can scroll through given questions, a progress meter [which I have no idea how to go about], Add an answer sheet in a separate window, and some others, but if possible, I will get to those when the time is right.
    Also, a small note about the majority of the code; Most of it is from a mold that was given to us as an example in class, and the 'setUp' method came from another class. [QuizDriver] As of now, the code remains untouched, but the if loops that remain empty or rather messed up is my fault, as I hit a snag and..to be honest, I am quite lost.
    As of now, my code for the GUI is this.
    import javax.swing.*;     
    import java.awt.*;     
    import java.awt.event.*;
    public class ProjGUI implements ActionListener {     
         // class constants      
         private static final int WINDOW_WIDTH = 700; 
         private static final int WINDOW_HEIGHT = 200; 
         private static final int TEXT_WIDTH = 50;   
         private static final FlowLayout LAYOUT_STYLE =     
              new FlowLayout();          
         static Test exam = new Test("Sample Exam", "Select the correct answer for each question");
         private JFrame window = new JFrame("Project GUI: Test");     
         private JTextArea results = new JTextArea("");
         int counter;
         private JLabel QTag = new JLabel("The Current Question:");     
         private JTextField QText = new JTextField(exam.displayQuestion(0));     
         private JLabel AnsTag = new JLabel("Your Answer:");
         private JTextField AnsText = new JTextField(TEXT_WIDTH);     
         private JButton SubButton = new JButton("Submit");     
         private JButton backButton = new JButton("Back");
         private JButton advButton = new JButton("Next");
         private JButton clearButton = new JButton("Reset Answer Choice");
         // constructor      
         public ProjGUI()
              // configure GUI      
              window.setSize(WINDOW_WIDTH, WINDOW_HEIGHT);     
              window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);     
              QText.setEditable(false);     
              QText.setBackground(Color.WHITE);     
              // register event listener      
              SubButton.addActionListener(this);     
              clearButton.addActionListener(this);
              backButton.addActionListener(this);
              advButton.addActionListener(this);
              // arrange components in GUI      
              window.getContentPane().setLayout(LAYOUT_STYLE);     
              window.getContentPane().add(QTag);     
              window.getContentPane().add(QText);     
              window.getContentPane().add(AnsTag);     
              window.getContentPane().add(AnsText);     
              window.getContentPane().add(SubButton);     
              window.getContentPane().add(backButton);
              window.getContentPane().add(clearButton);
              window.getContentPane().add(advButton);
              // display GUI      
              window.setVisible(true);     
         // actionPerformed(): run button action event handler
         public void actionPerformed(ActionEvent e) {     
              if (e.getActionCommand().equals("Submit"))
                   if(QText.equals(""))
                        QText = null;
                   if(e.getActionCommand().equals("Back"))
                        // Code for going back through the questions.
                   if(e.getActionCommand().equals("Next"))
                        // Code for advancing through the test
              // exam.answer(counter, ans);
              QText.setText(exam.displayQuestion(0+1));
              if (counter == exam.length())
                 exam.scoreExam(true);
                 results.setText("Your final score was " + exam.getScore() + "/" + exam.getMaxScore() + " points.");
                 results.setVisible(true);
              counter++;
         // main(): application entry point     
         public static void main(String[] args)
              setUp(exam);
              ProjGUI gui = new ProjGUI();     
         private static void setUp (Test t)
              TrueFalseQuestion x = new TrueFalseQuestion("The sky is blue.", "true", 2);
              t.addQuestion(x);
              x = new TrueFalseQuestion("The first FORTRAN compiler debuted in 1957", "true", 5);
              t.addQuestion(x);
              MultipleChoiceQuestion m = new MultipleChoiceQuestion("Which of the following is NOT a disk-scheduling algorithm?", "b", 4);
              m.addAnswerChoice("SSTF");
              m.addAnswerChoice("SJF");
              m.addAnswerChoice("FCFS");
              m.addAnswerChoice("All of the above are disk-scheduling algorithms");
              t.addQuestion(m);
               x = new TrueFalseQuestion("Spock was a Vulcan", "false", 3);
              t.addQuestion(x);
    }Feel free to tear it apart, as I am doing trying to figure out how exactly the buttons should work. Any feedback is appreciated.
    Edited by: Ereki on May 15, 2008 11:03 PM
    Edited by: Ereki on May 15, 2008 11:07 PM

    You may find java.awt.CardLayout and javax.swing.JProgressBar helpful.
    Generally if you have Swing-specific questions, you should ask on the Swing forum.

Maybe you are looking for