Adding JTree to JFrame using SpringLayout

I have created a JTree with various nodes and leafs. I want to place the JTree in a GUI that uses SpringLayout as the layout manager. What should I use to place the JTree in the JFrame? I assume I put it in a JScrollPane which serves as a container. Then how do I assign a layout manager to JScrollPane and register it with the JFrame? Does this make sense?

Twupack, my apologies. I was not receiving any responses in the other forum so I decided to take my questions to the beginner form which is probably more suitable given the complexity of my question. I also asked a different question - regarding the same topic. And my login, although different, was not intentional. This forum asked me to enter a different login name so I did. If I really wanted to hide my identity, I think I could have figured out something a little more creative.
Now, mods, if you could, remove this thread as I am not receiving any useful responses here.

Similar Messages

  • How to set a location of a JFrame using mouseListener?

    Hi,
    I was wondering how i could set the location of a JFrame using the mouseListener? I know when i want to show a JPopMenu i can do:
    pop.setLocation(e.getX(), e.getY());
    pop.setInvoker(null);
    By using .setInvoker(); I can show the jpopup on the position that i clicked my mouse but this method is not available to the JFrame.
    Should i do this with the Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); instead? I was wondering if there is an easier way to do this. If not i can code a workaround but thats not my first choice.
    Thanks

    CaptainMorgan08 wrote:
    deAppel wrote:
    CaptainMorgan08 wrote:
    Why do you need setInvoker() for a JFrame? What's wrong with just setLocation()?The problem is that i want to show my frame where i clicked my mouse but when i get the x,y from the mouselistener getX/Ymethods the frame doesn't show up on the location where i clicked with the mouse, instead it shows the frame in the location x,y NOT relative to the mouse.I see. Well if you're using Java 6, you can use the getXOnScreen() and the getYOnScreen() methods from MouseEvent.
    http://java.sun.com/javase/6/docs/api/java/awt/event/MouseEvent.html#getXOnScreen()
    Otherwise you'll need to add the x and y coordinates of whatever component you're clicking on.I'm using Java 6, I tried your suggestion but i get the same value with getX/Y and getX/YOnScreen()

  • Steps to Increase / adding New Table Space using BR TOOLS

    Hi
    Can Anyone Tell me the Step by Step Process for Increasing / Adding New Table Space using BRTOOLS.
    Any Demos/Blogs will be appreciated.
    Thanks in Advance.
    Rg
    Dan

    Hi Dan,
    <u><b>Adding a datafile using BRTOOLS</b></u>
    1) su – <b>ora<sid></b>
    2) start <b>brtools</b>
    3) Select option <b>2 -- Space management</b>
    4) Select option <b>1 -- Extend tablespace</b>
    5) Select option <b>3 --Tablespace name (specify tablespace name) and say continue(c- cont)</b>
    6) Select option <b>3 – New data file to be added and return</b>
    7) Select option <b>5 -- Size of the new file in MB (specify the size of the file) and say continue</b>
    regards,
    kanthi

  • Adding JApplet to JFrame

    Hi
    we can add an applet in JFrame(if it takes no parameters) e.g.
    jFrameObject.getContentPane( ).add(anAppletObject);
    but if an applet takes some parameters for initialization, then how i can pass parameters to that applet. means what is the code for passing parameters to an applet.
    Thanks in Advance
    Yahya Kamran

    Well the key to your problem is an interface called "AppletStub".
    What you need to do is define a own Class which implements AppletStub.
    Therefore define methods to retrieve parameters or a constructor doing that and the one to get the parameters in your custom AppletStub.
    The other methods must be implemented, too, but you can leave them blank, too. (eg. void foo() {} the empty braces are what makes the method implemented ;-) ).
    Now do follwing:
    // Creating the Applet you want to
    SillyApplet anAppletObject  = new SillyApplet();
    // Add it as you did
    jFrameObject.getContentPane().add(anAppletObject);
    // Now creating the parameters. This can be done how you like
    // (maybe an ArrayList maybe something more sophisticated)
    String[]  parameterList = new String[3];
    parameterList[0] = "one parameter";
    parameterList[1] = "another parameter" ;
    parameterList[2]  = "something special";
    parameterList[3] = "the last thing ever";
    // Assume your custom stub accepts a String[] of parameters int it's constructor
    // This is how to create such a mean Stub thing
    WeirdStub stub  = new WeirdStub(parameterList);
    // Handing the stub over to the applet
    anAppletObject.setStub(stub);
    // Now let the Applet get loose!
    anAppletObject.init();
    anAppletObject.start();Please note thus the Applet is added to the JFrame, you are still taklking to the same mean object!
    This is called reference semantics, since the variable actualy represents a pointer to the Object you are talking about.
    Another note this has to work a kind like that since the applet viewer is a java programm it self and various ide offer such a thing, too and are of course written in java, too.
    When stuck report in again.
    Greetings to your feetings,
    .o0|LIQID|0o.
    Found it in the java api source code.

  • Im a vine user and was wanting to know how to vine with no hands so i added a gesture to use on vine and now the gesture froze on the screen and i cant control my phone anymore. Its a blue circle and i want to know how to get rid of it.

    Im a vine user and was wanting to know how to vine with no hands so i added a gesture to use on vine and now the gesture froze on the screen and i cant control my phone anymore. Its a blue circle and i want to know how to get rid of it.

    never mind it finally went away

  • Firefox sync worked fine until I upgraded Firefox to version 5.0.1, then all my bookmarks added since I started use Firefox sync dissapeared

    Since I upgraded to Firefox 5.0.1 all bookmarks I added since I started use Firefox Sync dissapeared, only old bookmarks remain. Before upgrade syncing worked fine.

    Install the following Add-on until Google releases a new version of their toolbar that is compatible with Firefox 5. Google needs to test their toolbar with Firefox 5 and change one line in their code to make it compatilbe. Most Add-ons that worked with Firefox 4 should still work with Firefox 5, but the developers need to update a line in their Add-on's code to indicate with which versions of Firefox the Add-on is compatible. The following Add-on adds a "Compatibility" button in your Add-ons > Extensions that you may need to click after installing it and restarting Firefox.
    *Add-on Compatibility Reporter: https://addons.mozilla.org/en-US/firefox/addon/15003

  • Display JTree in browser using JSP

    i have a program that converts xml file in to tree structure(using Swing). When i run this using eclipse then it is working. Swing is an extension of applet , right. I want to embed this in an HTML page(JSP). so that i can display the tree structure. Its gives class not foung error.
    It is not posiible to embed it. I think if it extends an Applet then it will display. But i don't know how to convert that. It gives error if i convert.
    pls help
    CODE:
    package TreeGen;
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.parsers.ParserConfigurationException;
    import org.xml.sax.SAXException;
    import java.io.IOException;
    import org.w3c.dom.Document;
    // Basic GUI components
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.JTree;
    // GUI components for right-hand side
    import javax.swing.JSplitPane;
    import javax.swing.JEditorPane;
    // GUI support classes
    import java.awt.BorderLayout;
    import java.awt.Dimension;
    import java.awt.Toolkit;
    import java.awt.event.WindowEvent;
    import java.awt.event.WindowAdapter;
    // For creating borders
    import javax.swing.border.EmptyBorder;
    import javax.swing.border.BevelBorder;
    import javax.swing.border.CompoundBorder;
    // For creating a TreeModel
    import javax.swing.tree.*;
    import javax.swing.event.*;
    import java.util.*;
    public class TreeGen extends JPanel
         static Document document;
         boolean compress = false;
         static final int windowHeight = 660;
         static final int leftWidth = 300;
         static final int rightWidth = 640;
         static final int windowWidth = leftWidth + rightWidth;
         public TreeGen()
         EmptyBorder eb = new EmptyBorder(5,5,5,5);
         BevelBorder bb = new BevelBorder(BevelBorder.LOWERED);
         CompoundBorder cb = new CompoundBorder(eb,bb);
         this.setBorder(new CompoundBorder(cb,eb));
         JTree tree = new JTree(new DomToTreeModelAdapter());
         JScrollPane treeView = new JScrollPane(tree);
         treeView.setPreferredSize(
              new Dimension( leftWidth, windowHeight ));
         final
         JEditorPane htmlPane = new JEditorPane("text/html","");
         htmlPane.setEditable(true);
         JScrollPane htmlView = new JScrollPane(htmlPane);
         htmlView.setPreferredSize(
              new Dimension( rightWidth, windowHeight ));
         tree.addTreeSelectionListener(
              new TreeSelectionListener()
              public void valueChanged(TreeSelectionEvent e)
                   TreePath p = e.getNewLeadSelectionPath();
                   if (p != null)
                   AdapterNode adpNode =
                        (AdapterNode) p.getLastPathComponent();
                   htmlPane.setText(adpNode.content());
         JSplitPane splitPane =
              new JSplitPane( JSplitPane.HORIZONTAL_SPLIT,
                                  treeView,
                                  htmlView );
         splitPane.setContinuousLayout( false );
         splitPane.setDividerLocation( leftWidth );
         splitPane.setDividerSize(1);
         splitPane.setPreferredSize(
                   new Dimension( windowWidth + 10, windowHeight+10 ));
         this.setLayout(new BorderLayout());
         this.add("Center", splitPane );
         //return menuBar;
         } // constructor
         public static void main(String argv[])
              DocumentBuilderFactory factory =
                   DocumentBuilderFactory.newInstance();
              try {
              DocumentBuilder builder = factory.newDocumentBuilder();
              document = builder.parse("C:/Program Files/Apache Software Foundation/Tomcat 5.0/webapps/parser1/sample.xml");
                   makeFrame();
              } catch (SAXException sxe){
                   System.out.println("ERROR");
              Exception x = sxe;
              if (sxe.getException() != null)
                   x = sxe.getException();
              x.printStackTrace();
              } catch (ParserConfigurationException pce) {
                   pce.printStackTrace();
              } catch (IOException ioe) {
              ioe.printStackTrace();
         } // main
         public static void makeFrame()
              JFrame frame = new JFrame("DOM Echo");
              frame.addWindowListener(
              new WindowAdapter() {
                   public void windowClosing(WindowEvent e) {System.exit(0);}
              final TreeGen echoPanel =
              new TreeGen();
              frame.getContentPane().add("Center", echoPanel );
              frame.pack();
              Dimension screenSize =
              Toolkit.getDefaultToolkit().getScreenSize();
              int w = windowWidth + 10;
              int h = windowHeight + 10;
              frame.setSize(w, h);
              frame.setVisible(true);
         } // makeFrame
         static final String[] typeName = {
              "none",
              "Element",
              "Attr",
              "Text",
              "CDATA",
              "EntityRef",
              "Entity",
              "ProcInstr",
              "Comment",
              "Document",
              "DocType",
              "DocFragment",
              "Notation",
         static final int ELEMENT_TYPE = 1;
         static final int ATTR_TYPE = 2;
         static final int TEXT_TYPE = 3;
         static final int CDATA_TYPE = 4;
         static final int ENTITYREF_TYPE = 5;
         static final int ENTITY_TYPE = 6;
         static final int PROCINSTR_TYPE = 7;
         static final int COMMENT_TYPE = 8;
         static final int DOCUMENT_TYPE = 9;
         static final int DOCTYPE_TYPE = 10;
         static final int DOCFRAG_TYPE = 11;
         static final int NOTATION_TYPE = 12;
    static String[] treeElementNames = {
              "slideshow",
              "slide",
              "title", // For slideshow #1
              "slide-title", // For slideshow #10
              "item",
         boolean treeElement(String elementName) {
         for (int i=0; i<treeElementNames.length; i++) {
              //System.out.println(treeElementNames);
              if ( elementName.equals(treeElementNames[i]) )
              return true;
         return false;
         public class AdapterNode
         org.w3c.dom.Node domNode;
         public AdapterNode(org.w3c.dom.Node node)
              domNode = node;
         public String toString()
              String s = typeName[domNode.getNodeType()];
              String nodeName = domNode.getNodeName();
              if (! nodeName.startsWith("#"))
              s += ": " + nodeName;
              if (compress)
              String t = content().trim();
              int x = t.indexOf("\n");
              if (x >= 0) t = t.substring(0, x);
              s += " " + t;
              return s;
              if (domNode.getNodeValue() != null)
              if (s.startsWith("ProcInstr"))
                   s += ", ";
              else
                   s += ": ";
              // Trim the value to get rid of NL's at the front
              String t = domNode.getNodeValue().trim();
              int x = t.indexOf("\n");
              if (x >= 0) t = t.substring(0, x);
              s += t;
              return s;
         public String content()
              String s = "";
              org.w3c.dom.NodeList nodeList = domNode.getChildNodes();
              for (int i=0; i<nodeList.getLength(); i++)
              org.w3c.dom.Node node = nodeList.item(i);
              int type = node.getNodeType();
              //System.out.println(type);
              AdapterNode adpNode = new AdapterNode(node); //inefficient, but works
              if (type == ELEMENT_TYPE)
                   if ( treeElement(node.getNodeName()) ) continue;
                   s += "<" + node.getNodeName() + ">";
                   s += adpNode.content();
                   s += "</" + node.getNodeName() + ">";
              else if (type == TEXT_TYPE)
                   s += node.getNodeValue();
              else if (type == ENTITYREF_TYPE)
                   s += adpNode.content();
              else if (type == CDATA_TYPE)
                   StringBuffer sb = new StringBuffer( node.getNodeValue() );
                   for (int j=0; j<sb.length(); j++)
                   if (sb.charAt(j) == '<')
                        sb.setCharAt(j, '&');
                        sb.insert(j+1, "lt;");
                        j += 3;
                   else if (sb.charAt(j) == '&')
                        sb.setCharAt(j, '&');
                        sb.insert(j+1, "amp;");
                        j += 4;
                   s += "<pre>" + sb + "\n</pre>";
              return s;
         public int index(AdapterNode child)
              int count = childCount();
              for (int i=0; i<count; i++)
              AdapterNode n = this.child(i);
              if (child.domNode == n.domNode) return i;
              return -1; // Should never get here.
         public AdapterNode child(int searchIndex)
              org.w3c.dom.Node node =
                   domNode.getChildNodes().item(searchIndex);
              if (compress)
              int elementNodeIndex = 0;
              for (int i=0; i<domNode.getChildNodes().getLength(); i++)
                   node = domNode.getChildNodes().item(i);
                   if (node.getNodeType() == ELEMENT_TYPE
                   && treeElement( node.getNodeName() )
                   && elementNodeIndex++ == searchIndex)
                   break;
              return new AdapterNode(node);
         public int childCount()
              if (!compress)
              return domNode.getChildNodes().getLength();
              int count = 0;
              for (int i=0; i<domNode.getChildNodes().getLength(); i++)
              org.w3c.dom.Node node = domNode.getChildNodes().item(i);
              if (node.getNodeType() == ELEMENT_TYPE
              && treeElement( node.getNodeName() ))
                   ++count;
              return count;
         public class DomToTreeModelAdapter
         implements javax.swing.tree.TreeModel
         public Object getRoot()
              return new AdapterNode(document);
         public boolean isLeaf(Object aNode)
              AdapterNode node = (AdapterNode) aNode;
              if (node.childCount() > 0) return false;
              return true;
         public int getChildCount(Object parent)
              AdapterNode node = (AdapterNode) parent;
              return node.childCount();
         public Object getChild(Object parent, int index)
              AdapterNode node = (AdapterNode) parent;
              return node.child(index);
         public int getIndexOfChild(Object parent, Object child)
              AdapterNode node = (AdapterNode) parent;
              return node.index((AdapterNode) child);
         public void valueForPathChanged(TreePath path, Object newValue)
         private Vector listenerList = new Vector();
         public void addTreeModelListener(TreeModelListener listener)
              if ( listener != null
              && ! listenerList.contains( listener ) )
              listenerList.addElement( listener );
         public void removeTreeModelListener(TreeModelListener listener)
              if ( listener != null )
              listenerList.removeElement( listener );
         public void fireTreeNodesChanged( TreeModelEvent e )
              Enumeration listeners = listenerList.elements();
              while ( listeners.hasMoreElements() )
              TreeModelListener listener =
                   (TreeModelListener) listeners.nextElement();
              listener.treeNodesChanged( e );
         public void fireTreeNodesInserted( TreeModelEvent e )
              Enumeration listeners = listenerList.elements();
              while ( listeners.hasMoreElements() )
              TreeModelListener listener =
                   (TreeModelListener) listeners.nextElement();
              listener.treeNodesInserted( e );
         public void fireTreeNodesRemoved( TreeModelEvent e )
              Enumeration listeners = listenerList.elements();
              while ( listeners.hasMoreElements() )
              TreeModelListener listener =
                   (TreeModelListener) listeners.nextElement();
              listener.treeNodesRemoved( e );
         public void fireTreeStructureChanged( TreeModelEvent e )
              Enumeration listeners = listenerList.elements();
              while ( listeners.hasMoreElements() )
              TreeModelListener listener =
                   (TreeModelListener) listeners.nextElement();
              listener.treeStructureChanged( e );

    I actually had to do this a few months ago. There are ways to perform this kind display using various distributed object (i.e., using MS Word OLE objects to "interpret" the byte for you, etc.). But this soon got extremely difficult to manage (and I actually had to use Perl/CGI for the majority of it).
    The solution I went with was to implement a "cache" directory on the web server. Basically, the JSP/Servlet can simply check the cache and if file not there, create it from the database. Then send a redirect back to the browser to this newly-created file. The browser will then appropriately open the document. I tested this with both Netscape and IE browsers and common MIME types such as text files, MS Office docs, zip files, PDFs, RTFs.
    Not ideal, but unfortunately the best I came up with.

  • Adding JTree nodes from worker threads

    I'm trying to add a large number of nodes (> 1700) to a JTree, and I'm looking for a way to do this while allowing the user to continue working in the meantime.
    The nodes are retrieved from a database, which may be geographically distant and therefore possibly slow to access. I would like to have the process of processing the result-set and creating the Nodes run separately.
    I have considered processing the result-set in a separate Thread and creating the Nodes before then returning to the EDT to add them to the tree. This would cause the GUI to pause when adding the Nodes to the tree, but does at least separate the DB access out of the EDT.
    I would prefer to update the tree node by node as the result-set is processed, but I'm not sure whether this would incur too much overhead.
    I would appreciate any advice.

    I'm not sure overhead is the problemimport java.awt.*;
    import javax.swing.*;
    import javax.swing.tree.*;
    import java.util.Random;
    public class Test extends JFrame implements Runnable {
      JTree jt = new JTree();
      DefaultTreeModel dtm = (DefaultTreeModel)jt.getModel();
      public Test() {
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        Container content = getContentPane();
        content.add(new JScrollPane(jt), BorderLayout.CENTER);
        new Thread(this).start();
        setSize(500, 500);
        setVisible(true);
      public void run() {
        Random r = new Random();
        DefaultMutableTreeNode root = (DefaultMutableTreeNode)dtm.getRoot();
        for (int i=0; i<1700; i++) {
          DefaultMutableTreeNode item = (DefaultMutableTreeNode)root.getChildAt(r.nextInt(root.getChildCount()));
          while (r.nextInt(5)>0 && item.getChildCount()>0) {
            item = (DefaultMutableTreeNode)item.getChildAt(r.nextInt(item.getChildCount()));
          item.add(new DefaultMutableTreeNode("Node-"+i));
          dtm.nodeStructureChanged(item);
          try { Thread.sleep(500); } catch (Exception e) {}
      public static void main(String[] args) { new Test(); }
    }

  • Adding Jtree to Panel

    Hi all,
    I have a JTree in a scrollpane rendered with checkbox on each node. I
    When I try adding to JFrame its displaying with scrollbar as expected. like this
    frame.setContentPane(scrollPane); //working fineBut When I try adding to panel and try to display that its not working
    JPanel panel = new JPanel();
    panel.add(scrollPane);
    frame.setContentPane(panel); // displaying tree without scrollbarsthanks,
    sur

    scrollPane.setPreferredSize(new Dimension(x,y));where x,y can be the width/height of the frame

  • Centring items using SpringLayout

    I'm writing a dictionary program that uses Spring Layout to position things in exactly the way I want them.
    However, some elements, such as the results table, or the masses of buttons to perform searches, don't stay centred and I don't know how to do this using Spring Layout.
    Snippets of my code below. Centred Dictionary Window just sets the size, background colour, etc. There are 5 of each element (eg "Not" ComboBoxes, etc) except Operator ComboBoxes, of which there are 4. and yeah I understand that I can use 'object arrays' to shorten my code and avoid duplication but I've not worked out exactly how to do that yet >.<
    import javax.swing.*;
    import javax.swing.border.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    import java.lang.*;
    import java.io.*;
    public class searchWindowFrame extends CentredDictionaryWindow {
    //Title image
              JLabel searchImage = new JLabel(new ImageIcon("resources/SearchImage.jpg"));
              boxFont = new Font("Tahoma", Font.PLAIN, 12);
              //First 'Not' ComboBox
              String[] notItems = { "", "NOT" };
              notCombo = new JComboBox(notItems);
              notCombo.setPreferredSize(new Dimension(95, 40));
              notCombo.setBackground(new Color(241, 239, 240));
              notCombo.setForeground(new Color(93, 58, 64));
              notCombo.setFont(boxFont);
              notCombo.setEnabled(true);
              //First 'Dictionary Type' ComboBox
              String[] dictTypeItems = { "<Dictionary Type>", "Orthography", "Pronunciation" };
              dictTypeCombo = new JComboBox(dictTypeItems);
              dictTypeCombo.setPreferredSize(new Dimension(135, 40));
              dictTypeCombo.setBackground(new Color(241, 239, 240));
              dictTypeCombo.setForeground(new Color(93, 58, 64));
              dictTypeCombo.setFont(boxFont);
              dictTypeCombo.setEnabled(true);
              //First 'Search Type' ComboBox
              String[] searchTypeItems = { "<Search Type>", "Contains", "Starts With",
                   "Ends With", "Minimal Pairs" };
              searchTypeCombo = new JComboBox(searchTypeItems);
              searchTypeCombo.setPreferredSize(new Dimension(125, 40));
              searchTypeCombo.setBackground(new Color(241, 239, 240));
              searchTypeCombo.setForeground(new Color(93, 58, 64));
              searchTypeCombo.setFont(boxFont);
              searchTypeCombo.setEnabled(true);
              //First 'Query' TextField
              searchTermField = new JTextField("<Query>", 10);
              searchTermField.setBorder(new EtchedBorder(EtchedBorder.LOWERED));
              searchTermField.setPreferredSize(new Dimension(100, 40));
              searchTermField.setBackground(new Color(249, 249, 249));
              searchTermField.setForeground(new Color(93, 58, 64));
              searchTermField.setFont(boxFont);
              //First 'Operator' ComboBox
              String[] operatorItems = { "", "AND", "OR" };
              operatorCombo = new JComboBox(operatorItems);
              operatorCombo.setPreferredSize(new Dimension(95, 40));
              operatorCombo.setBackground(new Color(241, 239, 240));
              operatorCombo.setForeground(new Color(93, 58, 64));
              operatorCombo.setFont(boxFont);
              operatorCombo.setEnabled(true);
    //Panel containing Not Combo Boxes
              firstQueryPanel = new JPanel();
              firstQueryPanel.setLayout(new GridLayout(5, 0, 10, 10));
              firstQueryPanel.setBackground(new Color(241, 239, 240));
              firstQueryPanel.setBorder(new EmptyBorder(10, 10, 0, 0));
              firstQueryPanel.add(notCombo);
              firstQueryPanel.add(notComboTwo);
              firstQueryPanel.add(notComboThree);
              firstQueryPanel.add(notComboFour);
              firstQueryPanel.add(notComboFive);
              //Panel containing Dictionary Type Combo Boxes
              secondQueryPanel = new JPanel();
              secondQueryPanel.setLayout(new GridLayout(5, 0, 10, 10));
              secondQueryPanel.setBackground(new Color(241, 239, 240));
              secondQueryPanel.setBorder(new EmptyBorder(10, 0, 0, 0));
              secondQueryPanel.add(dictTypeCombo);
              secondQueryPanel.add(dictTypeComboTwo);
              secondQueryPanel.add(dictTypeComboThree);
              secondQueryPanel.add(dictTypeComboFour);
              secondQueryPanel.add(dictTypeComboFive);
              //Panel containing Search Type Combo Boxes
              thirdQueryPanel = new JPanel();
              thirdQueryPanel.setLayout(new GridLayout(5, 0, 10, 10));
              thirdQueryPanel.setBackground(new Color(241, 239, 240));
              thirdQueryPanel.setBorder(new EmptyBorder(10, 0, 0, 0));
              thirdQueryPanel.add(searchTypeCombo);
              thirdQueryPanel.add(searchTypeComboTwo);
              thirdQueryPanel.add(searchTypeComboThree);
              thirdQueryPanel.add(searchTypeComboFour);
              thirdQueryPanel.add(searchTypeComboFive);
              //Panel containing Query Text Fields
              fourthQueryPanel = new JPanel();
              fourthQueryPanel.setLayout(new GridLayout(5, 0, 10, 10));
              fourthQueryPanel.setBackground(new Color(241, 239, 240));
              fourthQueryPanel.setBorder(new EmptyBorder(10, 0, 0, 0));
              fourthQueryPanel.add(searchTermField);
              fourthQueryPanel.add(searchTermFieldTwo);
              fourthQueryPanel.add(searchTermFieldThree);
              fourthQueryPanel.add(searchTermFieldFour);
              fourthQueryPanel.add(searchTermFieldFive);
              //Panel containing Operator Combo Boxes
              fifthQueryPanel = new JPanel();
              fifthQueryPanel.setLayout(new GridLayout(4,0,10,10));
              fifthQueryPanel.setBackground(new Color(241, 239, 240));
              fifthQueryPanel.setBorder(new EmptyBorder(10, 0, 0, 10));
              fifthQueryPanel.add(operatorCombo);
              fifthQueryPanel.add(operatorComboTwo);
              fifthQueryPanel.add(operatorComboThree);
              fifthQueryPanel.add(operatorComboFour);
              //Search button
              searchButton = new JButton("Search");
              searchButton.setFont(boxFont);
              searchButton.setBackground(new Color(249, 249, 249));
              searchButton.setForeground(new Color(93, 58, 64));
              searchButton.setToolTipText("Search with the set parameters");
              searchButton.setPreferredSize(new Dimension(100, 40));
              searchButton.setFocusPainted(false);
              //Back button
              backButton = new JButton("< Back");
              backButton.setFont(boxFont);
              backButton.setBackground(new Color(249, 249, 249));
              backButton.setForeground(new Color(93, 58, 64));
              backButton.setPreferredSize(new Dimension(100, 40));
              backButton.setFocusPainted(false);
              //Exit button
              exitButton = new JButton("Exit");
              exitButton.setFont(boxFont);
              exitButton.setBackground(new Color(249, 249, 249));
              exitButton.setForeground(new Color(93, 58, 64));
              exitButton.setPreferredSize(new Dimension(100, 40));
              exitButton.setFocusPainted(false);
    layout = new SpringLayout();
              getContentPane().setLayout(layout);
              layout.putConstraint(SpringLayout.NORTH, searchImage, 10, SpringLayout.NORTH, getContentPane());
              layout.putConstraint(SpringLayout.EAST, searchImage, 0, SpringLayout.EAST, getContentPane());
              layout.putConstraint(SpringLayout.NORTH, firstQueryPanel, 10, SpringLayout.SOUTH, searchImage);
              layout.putConstraint(SpringLayout.WEST, secondQueryPanel, 10, SpringLayout.EAST, firstQueryPanel);
              layout.putConstraint(SpringLayout.NORTH, secondQueryPanel, 10, SpringLayout.SOUTH, searchImage);
              layout.putConstraint(SpringLayout.WEST, thirdQueryPanel, 10, SpringLayout.EAST, secondQueryPanel);
              layout.putConstraint(SpringLayout.NORTH, thirdQueryPanel, 10, SpringLayout.SOUTH, searchImage);
              layout.putConstraint(SpringLayout.WEST, fourthQueryPanel, 10, SpringLayout.EAST, thirdQueryPanel);
              layout.putConstraint(SpringLayout.NORTH, fourthQueryPanel, 10, SpringLayout.SOUTH, searchImage);
              layout.putConstraint(SpringLayout.WEST, fifthQueryPanel, 10, SpringLayout.EAST, fourthQueryPanel);
              layout.putConstraint(SpringLayout.NORTH, fifthQueryPanel, 10, SpringLayout.SOUTH, searchImage);
              layout.putConstraint(SpringLayout.SOUTH, backButton, -10, SpringLayout.SOUTH, getContentPane());
              layout.putConstraint(SpringLayout.WEST, backButton, 10, SpringLayout.WEST, getContentPane());
              layout.putConstraint(SpringLayout.WEST, exitButton, 10, SpringLayout.EAST, backButton);
              layout.putConstraint(SpringLayout.SOUTH, exitButton, -10, SpringLayout.SOUTH, getContentPane());
              layout.putConstraint(SpringLayout.EAST, helpButton, -10, SpringLayout.WEST, searchButton);
              layout.putConstraint(SpringLayout.SOUTH, helpButton, -10, SpringLayout.SOUTH, getContentPane());
              layout.putConstraint(SpringLayout.SOUTH, searchButton, -10, SpringLayout.SOUTH, getContentPane());
              layout.putConstraint(SpringLayout.EAST, searchButton, -10, SpringLayout.EAST, getContentPane());
              getContentPane().setBackground(new Color(241, 239, 240));
              getContentPane().add(searchImage);
              getContentPane().add(firstQueryPanel);
              getContentPane().add(secondQueryPanel);
              getContentPane().add(thirdQueryPanel);
              getContentPane().add(fourthQueryPanel);
              getContentPane().add(fifthQueryPanel);
              getContentPane().add(backButton);
              getContentPane().add(exitButton);
              getContentPane().add(searchButton);
    ...

    -__- On searchWindowFrame I want to centre all 24 input components. On resultsFrame I want to centre the scroll pane containing the JTable.
    To say I rewrote most of the program I had to completely redo this to get it to run, nor can I even use them all because that's 'too much', so that was fun.
    Like I said, I can centre things, just when the window resizes, it doesn't move with it.
    Originally the window is set to the right size, so everything is in its correct place.
    import javax.swing.*;
    import java.awt.*;
    import java.io.*;
    public class searchFrame extends JFrame
         public searchFrame()
              setTitle("Dictionary A'la Lewis");
              // Get the toolkit for reading System information
              Toolkit tk = Toolkit.getDefaultToolkit();
              // Get the dimensions of the screen
              Dimension screenDimension = tk.getScreenSize();
              // Set the size
              setSize(620, 535);
              // Centre window on screen
              setLocation(new Point((screenDimension.width - 600) / 2, (screenDimension.height - 535) / 2));
              JComboBox notCombo = new JComboBox();
              notCombo.setPreferredSize(new Dimension(95, 40));
              notCombo.setEnabled(true);
              JComboBox notCombo2 = new JComboBox();
              notCombo2.setPreferredSize(new Dimension(95, 40));
              notCombo2.setEnabled(true);
              JComboBox dictionaryType = new JComboBox();
              dictionaryType.setPreferredSize(new Dimension(95, 40));
              dictionaryType.setEnabled(true);
              JComboBox dictionaryType2 = new JComboBox();
              dictionaryType2.setPreferredSize(new Dimension(95, 40));
              dictionaryType2.setEnabled(true);
              JPanel notPanel = new JPanel();
              JPanel dictionaryPanel = new JPanel();
              notPanel.setLayout(new GridLayout(2, 0, 10, 10));
              notPanel.add(notCombo);
              notPanel.add(notCombo2);
              dictionaryPanel.setLayout(new GridLayout(2, 0, 10, 10));
              dictionaryPanel.add(dictionaryType);
              dictionaryPanel.add(dictionaryType2);
              //Search button
              JButton searchButton = new JButton("Search");
              //Back button
              JButton backButton = new JButton("< Back");
              //Exit button
              JButton exitButton = new JButton("Exit");
              SpringLayout layout = new SpringLayout();
              getContentPane().setLayout(layout);
              layout.putConstraint(SpringLayout.NORTH, notPanel, 10, SpringLayout.NORTH, getContentPane());
              layout.putConstraint(SpringLayout.WEST, notPanel, 10, SpringLayout.WEST, getContentPane());
              layout.putConstraint(SpringLayout.NORTH, dictionaryPanel, 10, SpringLayout.NORTH, getContentPane());
              layout.putConstraint(SpringLayout.WEST, dictionaryPanel, 10, SpringLayout.EAST, notPanel);
              layout.putConstraint(SpringLayout.SOUTH, backButton, -10, SpringLayout.SOUTH, getContentPane());
              layout.putConstraint(SpringLayout.WEST, backButton, 10, SpringLayout.WEST, getContentPane());
              layout.putConstraint(SpringLayout.WEST, exitButton, 10, SpringLayout.EAST, backButton);
              layout.putConstraint(SpringLayout.SOUTH, exitButton, -10, SpringLayout.SOUTH, getContentPane());
              layout.putConstraint(SpringLayout.SOUTH, searchButton, -10, SpringLayout.SOUTH, getContentPane());
              layout.putConstraint(SpringLayout.EAST, searchButton, -10, SpringLayout.EAST, getContentPane());
              getContentPane().add(notPanel);
              getContentPane().add(dictionaryPanel);
              getContentPane().add(searchButton);
              getContentPane().add(backButton);
              getContentPane().add(exitButton);
         public static void main(String[] args) throws IOException
              JFrame search = new searchFrame();
              search.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              search.show();
    }On this one I want to keep the scroll pane centred (which it won't be at the mo) and I also want to keep the label saying so many results found to the scroll pane's right edge (which it won't be at the moment if the table moves because of the screen resizing).
    import javax.swing.*;
    import java.awt.*;
    import java.io.*;
    public class resultsFrame extends JFrame
         public resultsFrame()
              setTitle("Dictionary A'la Lewis");
              // Get the toolkit for reading System information
              Toolkit tk = Toolkit.getDefaultToolkit();
              // Get the dimensions of the screen
              Dimension screenDimension = tk.getScreenSize();
              // Set the size
              setSize(620, 535);
              // Centre window on screen
              setLocation(new Point((screenDimension.width - 600) / 2, (screenDimension.height - 535) / 2));
              //Search button
              JButton refineButton = new JButton("Refine");
              //Back button
              JButton homeButton = new JButton("Home");
              //Exit button
              JButton exitButton = new JButton("Exit");
              //Results Table
              JTable resultsTable = new JTable();
              resultsTable.doLayout();
              //Table's Scroll Pane
              JScrollPane tableScrollPane = new JScrollPane(resultsTable);
              tableScrollPane.setPreferredSize(new Dimension(520, 290));
              //Number of Results
              JLabel numberOfResults = new JLabel("0 results found.");
              SpringLayout layout = new SpringLayout();
              getContentPane().setLayout(layout);
              layout.putConstraint(SpringLayout.SOUTH, homeButton, -10, SpringLayout.SOUTH, getContentPane());
              layout.putConstraint(SpringLayout.WEST, homeButton, 10, SpringLayout.WEST, getContentPane());
              layout.putConstraint(SpringLayout.WEST, exitButton, 10, SpringLayout.EAST, homeButton);
              layout.putConstraint(SpringLayout.SOUTH, exitButton, -10, SpringLayout.SOUTH, getContentPane());
              layout.putConstraint(SpringLayout.SOUTH, refineButton, -10, SpringLayout.SOUTH, getContentPane());
              layout.putConstraint(SpringLayout.EAST, refineButton, -10, SpringLayout.EAST, getContentPane());
              layout.putConstraint(SpringLayout.NORTH, tableScrollPane, 10, SpringLayout.NORTH, getContentPane());
              layout.putConstraint(SpringLayout.WEST, tableScrollPane, 50, SpringLayout.WEST, getContentPane());
              layout.putConstraint(SpringLayout.EAST, numberOfResults, 0, SpringLayout.EAST, tableScrollPane);
              layout.putConstraint(SpringLayout.NORTH, numberOfResults, 5, SpringLayout.SOUTH, tableScrollPane);
              getContentPane().add(tableScrollPane);
              getContentPane().add(refineButton);
              getContentPane().add(homeButton);
              getContentPane().add(exitButton);
              getContentPane().add(numberOfResults);
         public static void main(String[] args) throws IOException
              JFrame result = new resultsFrame();
              result.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              result.show();
    }

  • 0x8007000e (E_OUTOFMEMORY) while adding a firewall rule using the windows firewall COM API

    Hello,
    Configuration: Windows Embedded 8 64-bit.
    I'm using the Windows Firewall with Advanced Security COM API. The program uses the INetFwRules interface. Basically, I'm using the following code (Form the code sample available here : http://msdn.microsoft.com/en-us/library/windows/desktop/dd339604%28v=vs.85%29.aspx.)
     I get the error when performing "hr = pFwRules->Add(pFwRule);".
    We can also encounter the problem when removing a rule (using pFwRules->Remove(ruleName);)
    HRESULT hrComInit = S_OK;
    HRESULT hr = S_OK;
    INetFwPolicy2 *pNetFwPolicy2 = NULL;
    INetFwRules *pFwRules = NULL;
    INetFwRule *pFwRule = NULL;
    long CurrentProfilesBitMask = 0;
    BSTR bstrRuleName = SysAllocString(L"SERVICE_RULE");
    BSTR bstrRuleDescription = SysAllocString(L"Allow incoming network traffic to myservice");
    BSTR bstrRuleGroup = SysAllocString(L"Sample Rule Group");
    BSTR bstrRuleApplication = SysAllocString(L"%systemroot%\\system32\\myservice.exe");
    BSTR bstrRuleService = SysAllocString(L"myservicename");
    BSTR bstrRuleLPorts = SysAllocString(L"135");
    // Initialize COM.
    hrComInit = CoInitializeEx(
    0,
    COINIT_APARTMENTTHREADED
    // Ignore RPC_E_CHANGED_MODE; this just means that COM has already been
    // initialized with a different mode. Since we don't care what the mode is,
    // we'll just use the existing mode.
    if (hrComInit != RPC_E_CHANGED_MODE)
    if (FAILED(hrComInit))
    printf("CoInitializeEx failed: 0x%08lx\n", hrComInit);
    goto Cleanup;
    // Retrieve INetFwPolicy2
    hr = WFCOMInitialize(&pNetFwPolicy2);
    if (FAILED(hr))
    goto Cleanup;
    // Retrieve INetFwRules
    hr = pNetFwPolicy2->get_Rules(&pFwRules);
    if (FAILED(hr))
    printf("get_Rules failed: 0x%08lx\n", hr);
    goto Cleanup;
    // Create a new Firewall Rule object.
    hr = CoCreateInstance(
    __uuidof(NetFwRule),
    NULL,
    CLSCTX_INPROC_SERVER,
    __uuidof(INetFwRule),
    (void**)&pFwRule);
    if (FAILED(hr))
    printf("CoCreateInstance for Firewall Rule failed: 0x%08lx\n", hr);
    goto Cleanup;
    // Populate the Firewall Rule object
    pFwRule->put_Name(bstrRuleName);
    pFwRule->put_Description(bstrRuleDescription);
    pFwRule->put_ApplicationName(bstrRuleApplication);
    pFwRule->put_ServiceName(bstrRuleService);
    pFwRule->put_Protocol(NET_FW_IP_PROTOCOL_TCP);
    pFwRule->put_LocalPorts(bstrRuleLPorts);
    pFwRule->put_Grouping(bstrRuleGroup);
    pFwRule->put_Profiles(CurrentProfilesBitMask);
    pFwRule->put_Action(NET_FW_ACTION_ALLOW);
    pFwRule->put_Enabled(VARIANT_TRUE);
    // Add the Firewall Rule
    hr = pFwRules->Add(pFwRule);
    if (FAILED(hr))
    printf("Firewall Rule Add failed: 0x%08lx\n", hr);
    goto Cleanup;
    This works pretty well but, sometimes, at system startup, adding a rule ends up with the error 0x8007000e (E_OUTOFMEMORY) ! At startup, the system is always loaded cause several applications starts at the same time. But nothing abnormal. This is quite a random
    issue.
    According MSDN documentation, this error indicates that the system "failed to allocate the necessary memory".
    I'm not convinced that we ran out of memory.
    Has someone experienced such an issue? How to avoid this?
    Thank you in advance.
    Regards, -Ruben-

    Does Windows 8 desktop have the same issue? Are you building a custom WE8S image, or are you using a full WE8S image? The reason I ask is to make sure you have the modules in the image to support the operation.
    Is Windows Embedded 8.1 industry an option?
    www.annabooks.com / www.seanliming.com / Book Author - Pro Guide to WE8S, Pro Guide to WES 7, Pro Guide to POS for .NET

  • Error adding buffer entry when using Asynchronous mode of JRA and JCO call

    Enviroment: XMII 12.1.4 / CE EhP1 SP03
    When I using SAP JRA Function Call or SAP JCO Funciton Call in transaction, it works well when I choose 'Process Type' as 'Synchronous processing' in 'Data Buffering Configuration' tab. But when I use 'Asynchronouse processing' it doesn't work.
    I check the Netweaver logs, there some logs like following:
    Error adding buffer entry (com.sap.xmii.dataqueue.DataBufferManager)
    Couldn't add buffer entry (com.sap.xmii.dataqueue.DataBufferManager)
    ManagedConnectionImpl.dissociateConnections(), dissociation of a non-cci transaction, H1, C1(com.sap.mw.jco.jra)
    how could I solve this problem?

    Solved after deploy 12.1 SP05 (xMII 12.1.5 build 91)

  • Multiclip - adding angle - WHAT is used as the sync point???

    When I try to add a clip to a multiclip, I cannot discern the rational FCP is using in determining where the new clip lands in timing to the others already present. My multiclips are In-point based. Tried every combination of ins, no ins, beginning of clips, etc etc. It seems to add different amounts of black to the newly added clip, but there's no correlation I can see of the amount added. HELLLLP!

    Manual says just drag a new clip onto the current multiclip. But it no info as to how the sync is established. I'm working on a music vid with non-match TC, and have a few angles to add to an exisiting multiclip, that was created via In-points. No matter how I try to align the multiclip & the new clip to be added, I just can't get anything even remotely close to match points. UPDATE: wouldn't you know it - I just tested this on some clips from another project that have some matching TC - and it works! I didn't test all the variations, but I lined up 2 clips at matching code, and no problem. %!#$@$%$! So another half-implementation of a feature.

  • Problem adding item to list using a function.  Error - Null pointer

    Hi Guys,
    I'm not sure what the problem is, but for some reason I am unable to add an item to a list using a function. I can add an item when I call it in the same function that the list is created, but I cannot add the item from anoter function. Here is the code:
    Main:
    import java.awt.Color;
    import java.awt.FlowLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.*;
    public class main {
          * @param args
         public static void main(String[] args) {
              JFrame JFrame = new JFrame();
              JFrame.setSize(400,400);
              testpanel panel1 = new testpanel();
              panel1.setBackground(Color.red);
              JPanel panel2 = new testpanel();
              panel2.setBackground(Color.BLUE);
              JFrame.add(panel1);
              JFrame.add(panel2);
              JFrame.setLayout(new FlowLayout());
              //THIS GIVES ERROR:
              //NullPointerException
              panel1.addListItem("test");
              JFrame.setVisible(true);
    }And here is the testpanel class:
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    * testpanel.java
    * Created on Apr 7, 2010, 6:10:24 PM
    import java.awt.List;
    import java.awt.ScrollPane;
    import java.awt.event.ActionListener;
    * @author Snowraver1
    public class testpanel extends javax.swing.JPanel {
         public void addListItem(String string){
              list.add(string);
        /** Creates new form testpanel */
        public testpanel() {
            initComponents();
        /** This method is called from within the constructor to
         * initialize the form.
         * WARNING: Do NOT modify this code. The content of this method is
         * always regenerated by the Form Editor.
        @SuppressWarnings("unchecked")
        // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
        private void initComponents() {
            jButton1 = new javax.swing.JButton();
            ScrollPane scrollPane = new ScrollPane();
            List list = new List();
            jButton1.setText("jButton1");
            javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
            this.setLayout(layout);
            layout.setHorizontalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                    .addContainerGap(49, Short.MAX_VALUE)
                    .addComponent(jButton1)
                    .addGap(46, 46, 46))
            layout.setVerticalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGap(123, 123, 123)
                    .addComponent(jButton1)
                    .addContainerGap(139, Short.MAX_VALUE))
            this.add(scrollPane);
            scrollPane.add(list);
        }// </editor-fold>//GEN-END:initComponents
        // Variables declaration - do not modify//GEN-BEGIN:variables
        private javax.swing.JButton jButton1;
        private ScrollPane scrollPane;
        private List list;
        // End of variables declaration//GEN-END:variables
    }Thanks for the help!
    -- Snow

    You should check how you are initializing your variables in your testpanel class. You initialize your button correctly, but your other class variables are being overridden. As a result, your class variables still have a value of 'null'.

  • Adding text automatically through use of a button

    Hi there,
    Apologies if this has been asked before. I am creating a form in which a user creates a cost estimate for work done. This is just done by typing the information into a standard text field. At the end of every cost estimate is a standard piece of text, detailing terms and conditions etc which is the same across all estimates. Rather than have the user have to type this in every time, or go to another document to cut and paste, I thought it might be possible to use a button that when clicked adds this standard text to the end of the currenlty selected text field. Is this possible?
    Thanks
    JTH

    Yes, I thought of that - and that may well work.
    But currenlty the amount of original text that is entered before hand is variable, it could be as little as two lines, as many as fifty or more. So it may be that this text needs to be added on the first or second, even third page of the PDF. If my understanding is correct there is no way of linking text boxes across pages (in the way you can in InDesign) so each page will have a separate text box and the onus will be placed on the user to page break their text themselves, meaning that this standard piece of text might need adding to the text box on a different page each time. Agreed, I could add it as default to each page and the user deletes what they don't need but that's a little messy.

Maybe you are looking for

  • Using web.show_document the first time makes new browser window lose focus

    Hi, In our application we use show_document(url, '_blank') to open our reports (as pdf) in a new window. Our environment is Application Server 10g Release 2 with Forms 10g Release 2 and jinitiator 1.3.1.22. The first time I call a report, the new bro

  • Solaris x86 8 bootdisk

    For some reason my computer fails to boot from scsi cdrom, is there a bootdisk for Solaris x86? I have a Tekram DC-390F SCSI adapter and Pioneer DR-U24X CDROM-drive.

  • How to block duplicate invoice posting in MIRO

    Hello, How to block duplicate invoice posting in MIRO? Regards,

  • I can't share in iMovie 10?

    I recently downloaded iMovie to my iMac. I successfully created a short 30 sec project video in iMovie 10 but I can't share. The share button is dead

  • Where to view the apple email

    Dear all I want to install the MobileMe and have inpunt my apple ID, however, the system replied need to verification and a E-mail have been sent to [email protected] (my apple ID). I have checked all my YAHOO or Gmail account but found no such mail.