Swing gui code generator

Since I find Swing LayoutManagers very hard to learn, I would like to know if there is something like a swing gui code generator....
kevin

All of the IDEs have WYSIWYG GUI editors where you can interactively change a layout manager and see the effect instantly.
Check out: Forte, JBuilder or VisualCafe - and, no doubt, a multitude of others.

Similar Messages

  • Hand made or generated GUI code, what do proffesional use?

    Hello!
    I am currious about what programs people that work as a programmer use? Is it common that they use programs that generats code like Netbeens for instance? I tryed that program in design mode to make a gui, but when I looked at the code it had generated I could not understand it. When I have seen simple example of gui code that has been hand written I have no trouble to understand the code.
    My opinion is that code is something that others than yourself can read and understand. Wich ofcource is not as simple as it sounds :) The reason I could not understand Netbeens generated code can ofcource be that I am a java beginner.
    So, what I am asking is that:
    1. Is it common that proffesional programmers use programs like Netbeens to generate GUI code ?
    2. The problem that others cant read or understand the code, is it more common that the programmer have used generated code or does the problem as easly occur when the code is hand written?
    Regards
    Martin
    Edited by: onslow77 on Nov 4, 2009 8:02 AM

    gimbal2 wrote:
    but I prefer hand made code; that generated crap is unreadable (all imho of course) and I don't understand it eitherSeconded. Code generation not only creates messy, undocumented code, but it also leads to hidden mistakes which are the worst kind. I'd rather spend a little more time writing the stuff by hand and not only having full control over the outcome, but also have full knowledge of its inner workings.Thirded. For my money, if you're building rich GUIs that are anything other than trivial, it's probably worth investing some effort in writing a layer of code to simplify building those GUIs. Working with vast amounts of raw Swing, for example, is a painful experience. For our Swing products, we've got a whole library of controls we built specific to our apps. We also wrote a layer of abstraction over the whole of Swing itself, but that's another story. Another alternative is to use a Rich Client Platform like Eclipse RCP, which provides a lot of common, rich components, and a framework for deploying them in, out of the box. Both the Eclipse and NetBeans IDEs are built upon their own respective RCP packages, which are available for you to use for your own apps. All those nice editors, drag-n-drop views, trees, menus, shortcuts and what-not, all just there for you to use without having to write any tiresome window-resizing code. Lovely. I don't know about IntelliJ, but I wouldn't be surprised if it, too, did so. Spring RCP is another such package.

  • How to generate GUI code from parsed XML file?

    hai,
    I have to generate GUI code after parsing any configuration XML file as input.Now i have parsed my XML file and got its attributed and i want to get some idea of how to map the parsed XML attributes to the java code to build GUI code.

    Hello,
    1. I like to create data type from a XML file structure, which contains the data structure ?
    XML fields will need to be taken note of to see which is repeating or not. You can also load the XML into a third-party tool such as Altova XML Spy and then generate an XSD from there. You will need to import the XSDs into PI under external definitions. However, this does not guarantee business interoperability, as such, it is always best to ask the provider for the XSDs or WSDL. It will also save you a lot of time from guessing which fields are needed or not.
    2. How to create custom node function in graphical mapping editor ?
    In your graphical mapping editor, on the lowest left corner, there is an icon there that says Create New Function. You must take into account their return types:
    1. Single Values = String
    2. Queue/Context (no return type) thus resultList is used.
    Hope this helps,
    Mark

  • Modify code generated by Form Editor

    Hello,
    I'm wondering how I can add the methode
    setLocationRelativeTo()
    to the code generated by the Form Editor in JDeveloper12.
    Or what do I have to do, to create a Project with Swing GUI, using a visual editor, which let's me modify the code???
    Maybe this is a very odd question, but I'm just a little bit confused. I'm quite sure, that I was able to modify my code using the Visual Editor in JDeveloper10. Or am I on the wrong way and have to write the code by totaly by myself, if I want to have the possibility of modification?
    Thanks
    chrissy

    Hi Timo,
    that's the way I think it should work, but all code for components created with visual GUI Editor is blocked. What also makes sense, because the Form Editor will overwrite it, everytime I change something with the GUI Editor.
    My start up was to create a new Application (Java Desktop Application) with a project. I think it is just using NetBeans (with which I have never worked before). Creating now a JFrame Form is using the Form Editor for visual stuff. What's nice to have, because a lot of code is auto-generated, but I also need to do some modifications, like setting the window appear in the middle of the screen with setLocationRelativeTo(). Is there a chance to do it, or do I have to start up another way, i.e. just creating a Custom Application and writing all the code by myself and use no visual editor?
    Thanks
    chrissy

  • Learning swing gui by hand or gui builder?

    Hello,
    Which is a better way of start learning writing swing gui based apps? by hand or using gui builder?
    Do you know any useful web links? or do you consider buying books?
    Thanks.

    >>
    Hmm, the differences:
    1) The GUI builder app resizes correctly.-->>falseJust stating it is false doesn't make it so. I never have any issues with my GUI builder apps resizing correctly. I do have issues making my coded by hand apps resize correctly. Ignorance on my part? Possibly
    I used to use a GUI builder just for complicated layouts and use GridBagLayout for simple dialogs inside an app, but I find myself just using a GUI builder now. Just much quicker and much less hassle.
    As far as maintaining the code if you use the GUI builder for maintanence where is the issue?
    i have never seen a GUI builer that uses
    layoutmangers please point me to the one that you are
    using i would love to take a look
    secondly have you seen tried the little exersise you
    will be suprised at how complex the code is compared
    to the one done by hand!!!!IntelliJ's GUI builder appears to use a custom GridLayout manager, the code it generates appears pretty straightforward to me, doesn't seem overly complicated:
    private void $$$setupUI$$$() {
            mainPanel = new JPanel();
            mainPanel.setLayout(new com.intellij.uiDesigner.core.GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
            final JSplitPane splitPane1 = new JSplitPane();
            splitPane1.setContinuousLayout(true);
            splitPane1.setDividerLocation(142);
            mainPanel.add(splitPane1, new com.intellij.uiDesigner.core.GridConstraints(0, 0, 1, 1, com.intellij.uiDesigner.core.GridConstraints.ANCHOR_CENTER, com.intellij.uiDesigner.core.GridConstraints.FILL_BOTH, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_SHRINK | com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_GROW, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_SHRINK | com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_GROW, null, new Dimension(200, 200), null));
            fileListing = new JTree();
            splitPane1.setLeftComponent(fileListing);
            tabPane = new JTabbedPane();
            splitPane1.setRightComponent(tabPane);
            renameTab = new JPanel();
            renameTab.setLayout(new com.intellij.uiDesigner.core.GridLayoutManager(2, 7, new Insets(0, 0, 0, 0), -1, -1));
            tabPane.addTab("Untitled", renameTab);
            final JLabel label1 = new JLabel();
            label1.setHorizontalAlignment(4);
            label1.setText("Current Filename");
            renameTab.add(label1, new com.intellij.uiDesigner.core.GridConstraints(1, 0, 1, 1, com.intellij.uiDesigner.core.GridConstraints.ANCHOR_WEST, com.intellij.uiDesigner.core.GridConstraints.FILL_NONE, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_FIXED, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_FIXED, null, null, null));
            imageScrollPane = new JScrollPane();
            imageScrollPane.setHorizontalScrollBarPolicy(30);
            imageScrollPane.setVerticalScrollBarPolicy(20);
            renameTab.add(imageScrollPane, new com.intellij.uiDesigner.core.GridConstraints(0, 0, 1, 7, com.intellij.uiDesigner.core.GridConstraints.ANCHOR_CENTER, com.intellij.uiDesigner.core.GridConstraints.FILL_BOTH, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_SHRINK | com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_WANT_GROW, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_SHRINK | com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null));
            currentFilenameField = new JTextField();
            renameTab.add(currentFilenameField, new com.intellij.uiDesigner.core.GridConstraints(1, 1, 1, 1, com.intellij.uiDesigner.core.GridConstraints.ANCHOR_WEST, com.intellij.uiDesigner.core.GridConstraints.FILL_HORIZONTAL, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_WANT_GROW, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null));
            final JLabel label2 = new JLabel();
            label2.setText("New Filename");
            renameTab.add(label2, new com.intellij.uiDesigner.core.GridConstraints(1, 2, 1, 1, com.intellij.uiDesigner.core.GridConstraints.ANCHOR_WEST, com.intellij.uiDesigner.core.GridConstraints.FILL_NONE, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_FIXED, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_FIXED, null, null, null));
            newFilenameField = new JTextField();
            renameTab.add(newFilenameField, new com.intellij.uiDesigner.core.GridConstraints(1, 3, 1, 1, com.intellij.uiDesigner.core.GridConstraints.ANCHOR_WEST, com.intellij.uiDesigner.core.GridConstraints.FILL_HORIZONTAL, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_WANT_GROW, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null));
            renameButton = new JButton();
            renameButton.setText("Rename");
            renameTab.add(renameButton, new com.intellij.uiDesigner.core.GridConstraints(1, 4, 1, 1, com.intellij.uiDesigner.core.GridConstraints.ANCHOR_CENTER, com.intellij.uiDesigner.core.GridConstraints.FILL_HORIZONTAL, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_SHRINK | com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_GROW, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_FIXED, null, null, null));
            previousButton = new JButton();
            previousButton.setText("");
            renameTab.add(previousButton, new com.intellij.uiDesigner.core.GridConstraints(1, 5, 1, 1, com.intellij.uiDesigner.core.GridConstraints.ANCHOR_CENTER, com.intellij.uiDesigner.core.GridConstraints.FILL_HORIZONTAL, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_SHRINK | com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_GROW, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_FIXED, null, null, null));
            nextImageButton = new JButton();
            nextImageButton.setText("");
            renameTab.add(nextImageButton, new com.intellij.uiDesigner.core.GridConstraints(1, 6, 1, 1, com.intellij.uiDesigner.core.GridConstraints.ANCHOR_CENTER, com.intellij.uiDesigner.core.GridConstraints.FILL_HORIZONTAL, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_SHRINK | com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_GROW, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_FIXED, null, null, null));
            htmlGeneratorTab = new JPanel();
            tabPane.addTab("Untitled", htmlGeneratorTab);
        }

  • 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.

  • How do I make this code generate a new pro when the "NEXT" button is pushed

    How do I make this code generate a new set of problem when the "NEXT" Button is pushed
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    /* Figure out how to create a new set of problms
    * Type a list of specifications, include a list of test cases
    * DONE :]
    package javaapplication1;
    import java.awt.GridLayout;
    import java.awt.Window;
    import javax.swing.*;
    import java.awt.event.*;
    * @author Baba Akinlolu -
    class Grid extends JFrame{
        int done = 0;
        final int score = 0;
        final int total = 0;           
            //Create Panels
            JPanel p2 = new JPanel();
            JPanel p3 = new JPanel();
            final JPanel p1 = new JPanel();
            //Create Radio buttons & group them
            ButtonGroup group = new ButtonGroup();
            final JRadioButton ADD = new JRadioButton("Addition");
            final JRadioButton SUB = new JRadioButton("Subtraction");
            final JRadioButton MUL = new JRadioButton("Multiplication");
            final JRadioButton DIV = new JRadioButton("Division");
            //Create buttons
            JButton NEXT = new JButton("NEXT");
            JButton END = new JButton("End");
            //Create Labels
            JLabel l1 = new JLabel("First num");
            JLabel l2 = new JLabel("Second num");
            JLabel l3 = new JLabel("Answer:");
            JLabel l4 = new JLabel("Score:");
            final JLabel l5 = new JLabel("");
            JLabel l6 = new JLabel("/");
            final JLabel l7 = new JLabel("");
            //Create Textfields
            final JTextField number = new JTextField(Generator1());
            final JTextField number2 = new JTextField(Generator1());
            final JTextField answer = new JTextField(5);
        Grid(){
            setLayout(new GridLayout(4, 4, 2 , 2));
            p2.add(ADD);
            p2.add(SUB);
            group.add(ADD);
            group.add(SUB);
            group.add(MUL);
            group.add(DIV);
            p2.add(ADD);
            p2.add(SUB);
            p2.add(DIV);
            p2.add(MUL);
            //Add to panels
            p1.add(l1);
            p1.add(number);
            p1.add(l2);
            p1.add(number2);
            p1.add(l3);
            p1.add(answer);
            p1.add(l4);
            p1.add(l5);
            p1.add(l6);
            p1.add(l7);
            p3.add(NEXT);
            p3.add(END);
            //Add panels
            add(p2);
            add(p1);
            add(p3);
            //Create Listners
            Listeners();
    void Listeners(){
          NEXT.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {
             int answer1 = 0;
             //Grab the numbers entered
             int numm1 = Integer.parseInt(number.getText());
             int numm2 = Integer.parseInt(number2.getText());
             int nummsanswer = Integer.parseInt(answer.getText());
             //Set the score and total into new variabls
             int nummscore = score;
             int nummtotal = total;
             //Check if the add radio button is selected if so add
             if (ADD.isSelected() == true){
                 answer1 = numm1 + numm2;
             //otherwise check if the subtract button is selected if so subtract
             else if (SUB.isSelected() == true){
                 answer1 = numm1 - numm2;
             //check if the multiplication button is selected if so multiply
             else if (MUL.isSelected() == true){
                 answer1 = numm1 * numm2;
             //check if the division button is selected if so divide
             else if (DIV.isSelected() == true){
                 answer1 = numm1 / numm2;
             //If the answer user entered is the same with th true answer
             if (nummsanswer == answer1){
                 //add to the total and score
                 nummtotal += 1;
                 nummscore += 1;
                 //Convert the input back to String
                 String newscore = String.valueOf(nummscore);
                 String newtotal = String.valueOf(nummtotal);
                 //Set the text
                 l5.setText(newscore);
                 l7.setText(newtotal);
             //Otherwise just increase the total counter
             else {
                 nummtotal += 1;
                 String newtotal = String.valueOf(nummtotal);
                 l7.setText(newtotal);
      //Create End listener
    END.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // get the root window and call dispose on it
            Window win = SwingUtilities.getWindowAncestor(p1);
            win.dispose();
    //new Grid();
    String Generator1(){
         int randomnum;
         randomnum = (1 + (int)(Math.random() * 100));
         String randomnumm = String.valueOf(randomnum);
         return randomnumm;
    public class Main {
         * @param args the command line arguments
        public static void main(String[] args) {
            // TODO code application logic here
            JFrame frame = new Grid();
            frame.setTitle("Flashcard Testing");
            frame.setSize(500, 200);
            frame.setLocationRelativeTo(null);
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.setVisible(true);
    }Edited by: SirSaula on Dec 7, 2009 10:17 AM

    Not only are you continuing to post in the wrong forum but now you are multiposting: [http://forums.sun.com/thread.jspa?threadID=5418935]
    If people haven't answered you other posting its probably because we don't understand the question. Quit cluttering the forum by asking the same question over and over and then next time you have a new question post it in the proper forum. Your first posting was moved becuase you didn't post it properly.

  • Spliting GUI code to multiple classes

    Hi All...
    I am trying to design a large scale GUI, and after reading several MVC articles I still have some question on writing the GUI code.
    for flexability I split the code to classes:
    1) How can I notify on event(exp: actionPerformed), to other widgets located in separated classes which not visible(I attached a code describing this issue, every class would be in separated class)
    Note
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.*;
    class BaseComp1 implements ActionListener{
        JButton button1;
        public void actionPerformed(ActionEvent e){
            // notify DrawingArea instance, an action performed
    class BaseComp2 implements ActionListener{
        JButton button2;
        public void actionPerformed(ActionEvent e){
            // notify DrawingArea instance, an action performed
    public class MainComp{ 
        BaseComp1 base1 ;
        BaseComp2 base2;
        public MainComp(){
            base1 = new BaseComp1();
            base2 = new BaseComp2();
    public class drawingArea{
        public void drawStuff(){  // draw stuff when actionPerform in one of BaseComp* instance
    public class GUI{
        drawingArea drawing;
        MainComp mainComp;
        public GUI(){       // need to connect BaseComp* instances in MainComp instance to
                            // notify drawingArea on actionPerform event
            drawing = new drawingArea();
            mainComp = new MainComp();
    }2) If a solution is available but not recommended, is the preferred coding design for large GUI is to write all of it in the same class ?? any suggestion will excepted joyfully..
    I would like to thanks in advance for any help
    Best Regards
    YyYo
    Edited by: YyYo on May 25, 2010 12:35 PM
    Edited by: YyYo on May 25, 2010 12:36 PM

    First of all, I think your code would improve if you don't have GUI classes implement Action or control interfaces. You may wish to have your controls in separate classes.

  • 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

  • Gui code design question ...

    Hi
    I need some designtip. Im doing a gui with tabs. Due to lots of lines of code when setting up each tab, the gui class rows is now heading towards infinity. Additionally the actionperformed method from all the buttons, jtexts and textareas on the tabs ... is also growing towards infinity.
    Simply put: I need design tips from the javamasters. Im quite bad at these kinds of design issues.
    A subquestion is also if there is any tutorials/books/howtos on how to come up with excellent designs, making the coding sweet.
    Thanks in advance !!!

    Hello,
    the topic of this thread is basically Gui code design. So, first of all, i recommend to understand the MVC-pattern, as it is the first step to get an understanding of reusable gui code. The Observer-pattern is no substitute for the MVC-pattern, but the MVC-pattern implies the Observer-pattern. Any MVC related topic will lead you in a second step to the Observer-pattern (see also The Core Java Technologies Tech Tip of January 13, 2006: http://java.sun.com/developer/JDCTechTips/2006/tt0113.html).
    Here are three classes (compiled with Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_10-b03)), which demonstrate the Observer-pattern in a very simplified way due to the shortness of code:
    The SubjectPanel which notifies the registered ObserverPanel:
    import java.awt.BorderLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.JPanel;
    import javax.swing.JTextField;
    import javax.swing.event.ChangeEvent;
    import javax.swing.event.ChangeListener;
    public class SubjectPanel extends JPanel {
      private JTextField textfield = new JTextField("<Type some text>");
      private ChangeListener listener;
      public SubjectPanel(ChangeListener l) {
        listener = l;
        setLayout(new BorderLayout());
        add(textfield, BorderLayout.CENTER);
        textfield.setSelectionStart(0);
        textfield.setSelectionEnd(textfield.getText().length());
        textfield.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent evt) {
            // notify the listener about the changed text
            listener.stateChanged(new ChangeEvent(textfield));
    }The ObserverPanel which wants to be notified when a change in SubjectPanel occures:
    import java.awt.BorderLayout;
    import javax.swing.BorderFactory;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.JTextField;
    import javax.swing.event.ChangeEvent;
    import javax.swing.event.ChangeListener;
    public class ObserverPanel extends JPanel implements ChangeListener {
      private JLabel label = new JLabel();
      public ObserverPanel() {
        label.setBorder(BorderFactory.createEtchedBorder());
        setLayout(new BorderLayout());
        add(label, BorderLayout.CENTER);
      // Implementation of ChangeListener. This method is called by SubjectPanel
      // if the text has changed.
      public void stateChanged(ChangeEvent e) {
        label.setText(((JTextField)e.getSource()).getText());
    }The main class which contains SubjectPanel and ObserverPanel (Note, that this class doesn't know anything about the communication between the embedded panels):
    import java.awt.GridLayout;
    import javax.swing.JFrame;
    import javax.swing.WindowConstants;
    public class AppFrame extends JFrame {
      private SubjectPanel subjectPanel;
      private ObserverPanel observerPanel;
      public AppFrame() {
        setTitle("Observer");
        observerPanel = new ObserverPanel();
        // By passing the ObserverPanel to the SubjectPanel
        // a "one way communication line" is established
        subjectPanel = new SubjectPanel(observerPanel);
        getContentPane().setLayout(new GridLayout());
        getContentPane().add(subjectPanel);
        getContentPane().add(observerPanel);
      public static void main(String[] args) {
        AppFrame frame = new AppFrame();
        frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        frame.pack();
        frame.setVisible(true);
    }Please, be aware of the fact, that due to the simplification this example lacks the model which is part of the MVC-pattern. The SubjectPanel represents the Controller and the ObserverPanel the View.

  • Deadlock in gui code

    My gui code hung and wouldn't respond so I took a thread dump.
    I noticed this:
    Found one Java-level deadlock:
    =============================
    "AWT-EventQueue-0":
    waiting for ownable synchronizer 0x00000007c4535e78, (a java.util.concurrent.locks.ReentrantLock$NonfairSync),
    which is held by "AWT-XAWT"
    "AWT-XAWT":
    waiting to lock monitor 0x0000000041cd7938 (object 0x00000007c44d9418, a java.lang.Object),
    which is held by "AWT-EventQueue-0"
    Java stack information for the threads listed above:
    ===================================================
    "AWT-EventQueue-0":
         at sun.misc.Unsafe.park(Native Method)
         - parking to wait for <0x00000007c4535e78> (a java.util.concurrent.locks.ReentrantLock$NonfairSync)
         at java.util.concurrent.locks.LockSupport.park(LockSupport.java:158)
         at java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:811)
         at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireQueued(AbstractQueuedSynchronizer.java:842)
         at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquire(AbstractQueuedSynchronizer.java:1178)
         at java.util.concurrent.locks.ReentrantLock$NonfairSync.lock(ReentrantLock.java:186)
         at java.util.concurrent.locks.ReentrantLock.lock(ReentrantLock.java:262)
         at sun.awt.SunToolkit.awtLock(SunToolkit.java:236)
         at sun.awt.X11GraphicsDevice.getDoubleBufferVisuals(Native Method)
         at sun.awt.X11GraphicsDevice.makeDefaultConfiguration(X11GraphicsDevice.java:210)
         at sun.awt.X11GraphicsDevice.getDefaultConfiguration(X11GraphicsDevice.java:184)
         - locked <0x00000007c44d9418> (a java.lang.Object)
         at java.awt.MouseInfo.areScreenDevicesIndependent(MouseInfo.java:87)
         at java.awt.MouseInfo.getPointerInfo(MouseInfo.java:70)
         at java.awt.Component$2.run(Component.java:1313)
         at java.security.AccessController.doPrivileged(Native Method)
         at java.awt.Component.getMousePosition(Component.java:1310)
         at org.jdesktop.swingx.rollover.RolloverProducer.updateRollover(RolloverProducer.java:173)
         at org.jdesktop.swingx.rollover.RolloverProducer.componentResized(RolloverProducer.java:161)
         at java.awt.AWTEventMulticaster.componentResized(AWTEventMulticaster.java:142)
         at java.awt.Component.processComponentEvent(Component.java:6115)
         at java.awt.Component.processEvent(Component.java:6069)
         at java.awt.Container.processEvent(Container.java:2041)
         at java.awt.Component.dispatchEventImpl(Component.java:4652)
         at java.awt.Container.dispatchEventImpl(Container.java:2099)
         at java.awt.Component.dispatchEvent(Component.java:4482)
         at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:644)
         at java.awt.EventQueue.access$000(EventQueue.java:85)
         at java.awt.EventQueue$1.run(EventQueue.java:603)
         at java.awt.EventQueue$1.run(EventQueue.java:601)
         at java.security.AccessController.doPrivileged(Native Method)
         at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
         at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:98)
         at java.awt.EventQueue$2.run(EventQueue.java:617)
         at java.awt.EventQueue$2.run(EventQueue.java:615)
         at java.security.AccessController.doPrivileged(Native Method)
         at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
         at java.awt.EventQueue.dispatchEvent(EventQueue.java:614)
         at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
         at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
         at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
    "AWT-XAWT":
         at sun.awt.X11GraphicsDevice.getDefaultConfiguration(X11GraphicsDevice.java:184)
         - waiting to lock <0x00000007c44d9418> (a java.lang.Object)
         at sun.awt.X11.XWindowPeer.checkIfOnNewScreen(XWindowPeer.java:602)
         at sun.awt.X11.XDecoratedPeer.handleConfigureNotifyEvent(XDecoratedPeer.java:809)
         at sun.awt.X11.XBaseWindow.dispatchEvent(XBaseWindow.java:1129)
         at sun.awt.X11.XBaseWindow.dispatchToWindow(XBaseWindow.java:1086)
         at sun.awt.X11.XToolkit.dispatchEvent(XToolkit.java:513)
         at sun.awt.X11.XToolkit.run(XToolkit.java:619)
         at sun.awt.X11.XToolkit.run(XToolkit.java:543)
         at java.lang.Thread.run(Thread.java:662)
    Found 1 deadlock.
    It looks like a deadlock in the library code. I can't reproduce it.
    Has anyone else come across something similar?
    Edit: Unbuntu - Java 6 Update 24
    Thanks, Nick.
    Edited by: Boomah on Jun 23, 2011 10:46 AM

    I see the similar (probably same) problem in my GUI.
    Here is my EDT and XAWT deadlock under RHEL 5u7 64-bit, JDK 6u30 64-bit:
    java version "1.6.0_30"
    Java(TM) SE Runtime Environment (build 1.6.0_30-b12)
    Java HotSpot(TM) 64-Bit Server VM (build 20.5-b03, mixed mode)
    2012-01-10 09:19:05
    Full thread dump Java HotSpot(TM) 64-Bit Server VM (20.5-b03 mixed mode):
    Found one Java-level deadlock:
    =============================
    "AWT-EventQueue-0":
    waiting for ownable synchronizer 0x00000000e3ffb940, (a java.util.concurrent.locks.ReentrantLock$NonfairSync),
    which is held by "AWT-XAWT"
    "AWT-XAWT":
    waiting to lock monitor 0x000000004d1c06d8 (object 0x00000000e40448c8, a java.lang.Object),
    which is held by "AWT-EventQueue-0"
    Java stack information for the threads listed above:
    ===================================================
    "AWT-EventQueue-0":
    at sun.misc.Unsafe.park(Native Method)
    - parking to wait for <0x00000000e3ffb940> (a java.util.concurrent.locks.ReentrantLock$NonfairSync)
    at java.util.concurrent.locks.LockSupport.park(LockSupport.java:156)
    at java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:811)
    at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireQueued(AbstractQueuedSynchronizer.java:842)
    at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquire(AbstractQueuedSynchronizer.java:1178)
    at java.util.concurrent.locks.ReentrantLock$NonfairSync.lock(ReentrantLock.java:186)
    at java.util.concurrent.locks.ReentrantLock.lock(ReentrantLock.java:262)
    at sun.awt.SunToolkit.awtLock(SunToolkit.java:234)
    at sun.awt.X11GraphicsDevice.getNumConfigs(Native Method)
    at sun.awt.X11GraphicsDevice.makeConfigurations(X11GraphicsDevice.java:113)
    at sun.awt.X11GraphicsDevice.getConfigurations(X11GraphicsDevice.java:104)
    - locked <0x00000000e40448c8> (a java.lang.Object)
    at com.sun.awt.AWTUtilities.isWindowTranslucencySupported(AWTUtilities.java:312)
    at com.sun.awt.AWTUtilities.isTranslucencySupported(AWTUtilities.java:111)
    at javax.swing.RepaintManager.updateWindows(RepaintManager.java:720)
    at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:820)
    at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:714)
    at javax.swing.RepaintManager.prePaintDirtyRegions(RepaintManager.java:694)
    at javax.swing.RepaintManager.access$700(RepaintManager.java:41)
    at javax.swing.RepaintManager$ProcessingRunnable.run(RepaintManager.java:1636)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:646)
    at java.awt.EventQueue.access$000(EventQueue.java:84)
    at java.awt.EventQueue$1.run(EventQueue.java:607)
    at java.awt.EventQueue$1.run(EventQueue.java:605)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:616)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
    "AWT-XAWT":
    at sun.awt.X11GraphicsDevice.getDefaultConfiguration(X11GraphicsDevice.java:184)
    - waiting to lock <0x00000000e40448c8> (a java.lang.Object)
    at sun.awt.X11.XWindowPeer.checkIfOnNewScreen(XWindowPeer.java:602)
    at sun.awt.X11.XDecoratedPeer.handleConfigureNotifyEvent(XDecoratedPeer.java:809)
    at sun.awt.X11.XBaseWindow.dispatchEvent(XBaseWindow.java:1129)
    at sun.awt.X11.XBaseWindow.dispatchToWindow(XBaseWindow.java:1086)
    at sun.awt.X11.XToolkit.dispatchEvent(XToolkit.java:513)
    at sun.awt.X11.XToolkit.run(XToolkit.java:619)
    at sun.awt.X11.XToolkit.run(XToolkit.java:543)
    at java.lang.Thread.run(Thread.java:662)
    Found 1 deadlock.
    Heap
    PSYoungGen total 25344K, used 8899K [0x00000000e3b60000, 0x00000000e57a0000, 0x0000000100000000)
    eden space 21760K, 40% used [0x00000000e3b60000,0x00000000e4410f88,0x00000000e50a0000)
    from space 3584K, 0% used [0x00000000e5420000,0x00000000e5420000,0x00000000e57a0000)
    to space 3584K, 0% used [0x00000000e50a0000,0x00000000e50a0000,0x00000000e5420000)
    PSOldGen total 57984K, used 0K [0x00000000ab200000, 0x00000000aeaa0000, 0x00000000e3b60000)
    object space 57984K, 0% used [0x00000000ab200000,0x00000000ab200000,0x00000000aeaa0000)
    PSPermGen total 21248K, used 15669K [0x00000000a6000000, 0x00000000a74c0000, 0x00000000ab200000)
    object space 21248K, 73% used [0x00000000a6000000,0x00000000a6f4d7f8,0x00000000a74c0000)
    Is someone at Oracle looking into this issue?

  • 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();
              

  • Java Swing GUI Button Image

    Hi, I really need help with this one, I have tried many things and looked at many pages for this but to no avail as of yet.
    I have a Swing GUI in which I want to display an image. The way I am displaying it at the moment is as a button icon as I do not need to be able to alter the images. I can also use the button functionality as displaying something when the image is clicked. So I have an array of image paths which are accesed to load an image into the button and a "Next" button to change the image as required.
    My problem is that when I load an image into the button it moves from it's original location. When there is no image displayed the button is where I want it to be, but when I load an image it moves, this cannot happen. Any ideas.
    Also, when I am trying to click thru the array of images, it starts at the 1st image in the array but then skips to the last image in the array. Here is the code for that.
    // Handle events that arise from the "Next" button being clicked
    private void jButton5MouseClicked(java.awt.event.MouseEvent evt) {
    if (jComboBox1.getSelectedIndex() == 1)
         for (int i = 1; i < juniorImageIndex.length; i++)
         jButton8.setIcon(new javax.swing.ImageIcon(juniorImageIndex));
    else if (jComboBox1.getSelectedIndex() == 2)
         for (int i = 1; i < seniorImageIndex.length; i++)
         jButton8.setIcon(new javax.swing.ImageIcon(seniorImageIndex[i]));
    juniorImageIndex and seniorImageIndex are obviuosly the arrrays with the file paths for the images. The reason I start at index 1 is that I use the 0 index image as the starting image for each part.
    Any help gratefully appreciated, I really hope someone can help, Thanks.

    // Handle events that arise from the "Next" button
    being clicked
    private void
    jButton5MouseClicked(java.awt.event.MouseEvent evt) {
      myImageIndex =(myImageIndex + 1) % imageArray.size();
      resetButtonImage();
    private void resetButtonImage() {
    if (jComboBox1.getSelectedIndex() == 1)
    {//take this out
    //> for (int i = 1; i < juniorImageIndex.length; i++)
    //> {
    jButton8.setIcon(new//> javax.swing.ImageIcon(array[myImageIndex]));
    //> }
    else if (jComboBox1.getSelectedIndex() == 2)
    {//this too
    //> for (int i = 1; i < seniorImageIndex.length; i++)
    //> {
    jButton8.setIcon(new
    javax.swing.ImageIcon(array2[myImageIndex]));//> }

  • Freezing Swing GUI...

    Hi!
    I am having problems with my swing GUI. It's freezing when I'm trying to disable a JButton in it. Could anybody tell me y it happens and what can be done to remedy it?
    My piece of code:
    stopButton.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    // stop!
    simulator.blinker = null;
    label.setText("Stopped!");
    playPauseButton.setEnabled(false);
    stepButton.setEnabled(false);
    showNamesButton.setEnabled(false);
    speedUpButton.setEnabled(false);
    speedDownButton.setEnabled(false);
    stopButton.setEnabled(false);
    When I press the stopButton, my GUI freezes. Same happens with this piece of code when simSpeed = 50:
    speedUpButton.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    if (simulator.simSpeed > 300 && simulator.simSpeed <= 500){
    simulator.simSpeed -= 100;
    System.out.println("sim speed = " + simulator.simSpeed);
    else if (simulator.simSpeed > 50 && simulator.simSpeed <= 300){
    simulator.simSpeed -= 50;
    System.out.println("sim speed = " + simulator.simSpeed);
    else {//if (simulator.simSpeed == 50){
    System.out.println("caution: sim speed = " + simulator.simSpeed);
    speedUpButton.setEnabled(false);
    Strangely, this one does not make the GUI freeze when simSpeed = 1500:
    speedDownButton.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    if (simulator.simSpeed < 1500){
    simulator.simSpeed += 100;
    System.out.println("sim speed = " + simulator.simSpeed);
    else if (simulator.simSpeed == 1500)
    speedDownButton.setEnabled(false);
    I'd greatly apreciate any help!
    Thx in advance!
    Owrwe

    I have gone thru some experimentations and come to this conclusion:
    when i try to disable buttons at the extremity of a row of buttons, the GUI freezes!
    for example:
    buttonPanel.add(speedUpButton);
    buttonPanel.add(speedDownButton);
    buttonPanel.add(playPauseButton);
    buttonPanel.add(stepButton);
    buttonPanel.add(showNamesButton);
    buttonPanel.add(stopButton);
    this is the order of buttons in a layout (flow layout by default, isn't it?). The GUI freezes when I try to disable: speedUpButton and stopButton (from inside their ActionListener method).
    Changing the layout to:
    buttonPanel.add(speedDownButton);
    buttonPanel.add(speedUpButton);
    buttonPanel.add(playPauseButton);
    buttonPanel.add(stepButton);
    buttonPanel.add(showNamesButton);
    buttonPanel.add(stopButton);
    The GUI freezes when I try to disable: speedDownButton (as compared to speedUpButton from above) and stopButton (from inside their ActionListener method).
    Changing the layout to:
    buttonPanel.add(playPauseButton);
    buttonPanel.add(speedDownButton);
    buttonPanel.add(speedUpButton);
    buttonPanel.add(stepButton);
    buttonPanel.add(stopButton);
    buttonPanel.add(showNamesButton);
    The GUI freezes when I try to disable: all of them (from inside the stopButton ActionListener). The speedUpButton and speedDownButton are properly disabled when the limits are reached without freezing the GUI. If I disable all buttons (thru the stopButton when it's not at the extremity of the row) except one of them, the GUI doesn't freeze!
    any suggestions?

  • Multi-Client TCP Server /w Swing GUI

    Hi everybody,
    i have to develop a Multi-Client TCP Server with a Swing GUI. The GUI mainly consists of a JTable which shows various trace messages from processes running on other computers. As the data needs to be filtered i�m using a custom TableModel derived from AbstractTableModel. I�m creating a new thread for every client that connects as shown in http://java.sun.com/developer/onlineTraining/Programming/BasicJava2/socket.html
    Now every client thread reads data from its TCP connection and puts it into the JTable by calling the method addRow of the model. But i�m getting strange NullPointerExceptions and IndexOutOfBoundExceptions when data arrives (i�m using ArrayList in the model). These exceptions never show in a single-threaded Swing app (i�ve tested this already, so i don�t think it�s a bug in my model), so i think this is a problem with Swing�s thread unsafety? Do you have any hints on how to get away with it? Also general design tips for a Multi-Client TCP Server /w Swing GUI are greatly appreciated.
    Thanks in advance!
    Best regards,
    Disposable_Hero

    Of course, but i don�t think it is the model (as said before it works fine in a single thread swing app)
    Here�s the code:
    public class LogTableModel extends AbstractTableModel{
    private Vector dataVector;
    private Vector filterVector;
    private String[] columnIdentifiers;
    private Vector filteredbyProcess;
    private Vector filteredbyLoglevel;
    private boolean bEnableRefresh;
    /** Creates a new instance of LogTableModel */
    public LogTableModel() {
    dataVector=new Vector(0);
    columnIdentifiers=new String[]{"LogTime","HostName","IP","ProcessName","LogLevel","Handle","PID","TID","LogData"};
    filteredbyProcess=new Vector(0);
    filteredbyLoglevel=new Vector(0);
    filterVector=new Vector(0);
    bEnableRefresh=true;
    public synchronized void enableRefresh(boolean bEnableRefresh){
    this.bEnableRefresh=bEnableRefresh;
    if(bEnableRefresh){
    this.buildIndexListBasedOnFilter();
    public synchronized void addRow(LogLine row){
    dataVector.add(row);
    if(bEnableRefresh)
    this.buildIndexListBasedOnFilter();
    public synchronized void addFilter(Filter filter){
    filterVector.add(filter);
    if(filter.isActive())
    this.buildIndexListBasedOnFilter();
    public synchronized void setFilterActive(String name,boolean active){
    int i;
    for(i=0;i<filterVector.size();i++)
    if(((Filter)filterVector.elementAt(i)).getName().equals(name))
    break;
    Filter tmp=(Filter)filterVector.elementAt(i);
    tmp.setActive(active);
    if(active)
    this.buildIndexListBasedOnFilter();
    public synchronized void setFilterLoglevel(String name,int Loglevel){
    int i;
    for(i=0;i<filterVector.size();i++)
    if(((Filter)filterVector.elementAt(i)).getName().equals(name))
    break;
    Filter tmp=(Filter)filterVector.elementAt(i);
    tmp.setLoglevel(Loglevel);
    if(tmp.isActive()==false)
    this.buildIndexListBasedOnFilter();
    private void buildIndexListBasedOnFilter(){
    filteredbyProcess.clear();
    filteredbyLoglevel.clear();
    applyProcessFilter();
    applyLoglevelFilter();
    if(bEnableRefresh)
    this.fireTableDataChanged();
    private void applyProcessFilter(){
    LogLine line=null;
    Filter filter=null;
    for(int i=0;i<dataVector.size();i++){
    for(int j=0;j<filterVector.size();j++){
    filter=(Filter)filterVector.elementAt(j);
    line=(LogLine)dataVector.elementAt(i);
    if(filter.isActive()&&(filter.getName().equals(line.getProcessName()))){
    line.setHidden(true);
    break;
    else{
    line.setHidden(false);
    if(line.getHidden()!=true)
    filteredbyProcess.add(new Integer(i));
    private void applyLoglevelFilter(){
    for(int i=0;i<filteredbyProcess.size();i++){
    int index=((Integer)filteredbyProcess.get(i)).intValue();
    LogLine line=(LogLine)dataVector.elementAt(index);
    for(int j=0;j<filterVector.size();j++){
    if(((Filter)filterVector.elementAt(j)).getName().equals(line.getProcessName())){
    Filter filter=(Filter)filterVector.elementAt(j);
    if((filter.getLoglevel()&line.getLogLevelAsInt())!=line.getLogLevelAsInt())
    line.setHidden(true);
    else
    filteredbyLoglevel.add(new Integer(index));
    break;
    public synchronized String getColumnName(int columnIndex){
    return columnIdentifiers[columnIndex];
    public synchronized void clearData(){
    dataVector.clear();
    filteredbyProcess.clear();
    filteredbyLoglevel.clear();
    public synchronized int getColumnCount() {
    return columnIdentifiers.length;
    public synchronized int getRowCount() {
    return filteredbyLoglevel.size();
    public synchronized Object getValueAt(int rowIndex, int columnIndex) {
    int iIndex=((Integer)filteredbyLoglevel.get(rowIndex)).intValue();// hier krachts warum???
    LogLine tmp=(LogLine)dataVector.elementAt(iIndex);
    switch(columnIndex){
    case 0:
    return tmp.getLogTime();
    case 1:
    return tmp.getHostName();
    case 2:
    return tmp.getIP();
    case 3:
    return tmp.getProcessName();
    case 4:
    return tmp.getLogLevel();
    case 5:
    return tmp.getHandle();
    case 6:
    return tmp.getProcessID();
    case 7:
    return tmp.getThreadID();
    case 8:
    return tmp.getLogData();
    default:
    return null;

Maybe you are looking for

  • Cfmail w/attachments issues

    Hi there, I have a basic html form where the user can add attachments. The action form uses cfmail to send an email to an address with the form contents as well as the attachment. However, I am having issues with this part and am at a loss. Do i need

  • Exchange rate Fluctation  for Import

    HI Expert i would like to know standard exchange rate fluctuation if its occur while import purchase and other charges like CHA, transporter, wharfage we dnt know at the time of creation of PO. So for this how u people map this scenario correctly Rem

  • Planning doubt

    Hi all, I have a scenario where I have many employees assigned to a cost center and that cost center is part of a org unit. I am in charge of planning for both the org units as shown below. I should be able to see the Excel input schedule as shown be

  • Display will not come back up after waking up Pro

    Several weeks ago I increased the Pro's memory from 2 to 4GB. Since that time when I wake up the Mac, the display, (Westinghouse) will be all white. I then must turn it off and back on after that it looks OK. The increased memory might not have anyth

  • Intel graphics drivers performance improvement

    Just a heads up for people looking to get a little more performance from the Intel on CPU graphics... I noticed that Lenovo has updated the Intel graphics drivers to version 8.15.10.2418: http://download.lenovo.com/lenovo/content/ddfm/MIGR-77280.html