WARNING: No saved state for javax.swing.JTable

Hi All,
I have a JTable component in my code and I used Netbeans to add swing components. However, I get this warning after I run my app:
WARNING: No saved state for javax.swing.JTable[jTable1,0,0,329x80,alignmentX=0.0,alignmentY=0.0,border=,
        flags=251658568,maximumSize=,minimumSize=,preferredSize=,autoCreateColumnsFromModel=true,
        autoResizeMode=AUTO_RESIZE_SUBSEQUENT_COLUMNS,cellSelectionEnabled=false,editingColumn=-1,
        editingRow=-1,gridColor=javax.swing.plaf.ColorUIResource[r=128,g=128,b=128],
        preferredViewportSize=java.awt.Dimension[width=450,height=400],rowHeight=16,rowMargin=1,
        rowSelectionAllowed=true,selectionBackground=javax.swing.plaf.ColorUIResource[r=51,g=153,b=255],
        selectionForeground=javax.swing.plaf.ColorUIResource[r=255,g=255,b=255],showHorizontalLines=true,
        showVerticalLines=true]What is the reason of this? If I need to catch this exception, how can I add it with netbeans?
Edited by: Darryl Burke -- broke a long line into several lines

Set the name property of your JTable, it's a Netbeans thing, rather than a Java problem. table.setName("MyTable");Have a look at this thread for details: SessionStorage warning while program is running
Please only post Java related questions here and post Netbeans questions to a netbeans forum/mailing list, thanks.

Similar Messages

  • Javax.swing.*  - vs - javax.swing.JTable - any tradeoff?

    I'm new to java and have noticed that sometimes people write:
    import javax.swing.*;and sometimes they write
    import javax.swing.JTable;Is there a performance hit using the first example? Any info on this or pointers to relevant web pages would be greatly appreciated.
    Thanks,
    Matt

    No, there is no performance hit between the two options. The difference lies in readablity and name spaces. Some people prefer to use java.package.* when importing for ease in coding, but it is ambiguous and does not give much information on specific classes used which can hurt readablity. In terms of name spaces using .* can be detrimental. For instance if you were creating a GUI using swing components and imported javax.swing.* That would also give you access to javax.swing.Box class, and if you had your own package with a Box class call my.package.Box which you also imported there would be conflicts in which class would be refrenced. So it can be benifical to explicitly state your imports.

  • [Solved] CLASSPATH for javax.swing libraries?

    Hello,
    I wanted to use the swing packages provided by java for developing cross platform GUIs. But, when I tried compiling it, I ended up with the following error:
    HelloWorldSwing.java:1: package javax does not exist
    import javax.swing;
    After searching a bit online, I found out that the CLASSPATH variable needed to be set to use external java libraries. (I installed the jdk and jre packages). I tried setting CLASSPATH to /opt/java/jre/lib in my ~/.bashrc but that didn't help. What should I do to remedy this situation?
    (This is the first time that I am trying to use external libraries like swing on Arch. So I am a Noob at this)
    Thanks for your time!
    Last edited by mgangav (2009-11-24 15:45:59)

    urist wrote:
    The
    import javax.swing.event.*;
    is unnecessary as it is covered by the previous import.
    No, each package must be imported separately, even if one is "inside" the other.  I wrote a little test program to make sure   Try compiling it with line 4 commented/uncommented.
    package foo;
    import javax.swing.*;
    //import javax.swing.event.*;
    public class Thingy
    public Thingy() {
    JMenu menu = new JMenu("File");
    menu.addMenuListener(new MenuListener() {
    public void menuCanceled(MenuEvent e) {
    System.out.println("canceled");
    public void menuSelected(MenuEvent e) {
    System.out.println("selected");
    public void menuDeselected(MenuEvent e) {
    System.out.println("deselected");

  • Document Listener for JTextArea in JTable

    I am trying to implement a DocumentListener for JTextArea in JTable, but its not happening.
    Can someone tell me what's wrong. SSCCE below.
    import java.awt.Component;
    import java.awt.Dimension;
    import java.awt.event.WindowAdapter;
    import java.awt.event.WindowEvent;
    import javax.swing.Icon;
    import javax.swing.JFrame;
    import javax.swing.JScrollPane;
    import javax.swing.JTable;
    import javax.swing.JTextArea;
    import javax.swing.UIManager;
    import javax.swing.event.DocumentEvent;
    import javax.swing.event.DocumentListener;
    import javax.swing.table.DefaultTableModel;
    import javax.swing.table.TableCellRenderer;
    import javax.swing.table.TableColumn;
    import javax.swing.text.Document;
    public class MyTable_TextArea extends JTable {
         private DefaultTableModel defaultTableModel;
         private Object[][] dataArray;
         private Object[] columnNameArray;
         public final int TEXT_COLUMN = 0;     
         // column headers
         public static final String TEXT_COLUMN_HEADER = "Text";
         // text area
         TextFieldRenderer3 textFieldRenderer3;
          * constructor
          * @param variableNameArray
          * @param columnNameArray
         public MyTable_TextArea(Object[][] variableNameArray, Object[] columnNameArray) {
              this.dataArray = variableNameArray;
              this.columnNameArray = columnNameArray;
              defaultTableModel = new DefaultTableModel(variableNameArray, columnNameArray);
              this.setModel(defaultTableModel)     ;
              // text field
            textFieldRenderer3 = new TextFieldRenderer3();
              MyDocumentListener myListener = new MyDocumentListener();
              textFieldRenderer3.getDocument().addDocumentListener(myListener);
            TableColumn modelColumn = this.getColumnModel().getColumn(TEXT_COLUMN);
              modelColumn.setCellRenderer(textFieldRenderer3);
          * nested class
         class MyDocumentListener implements DocumentListener {
             String newline = "\n";
             public void insertUpdate(DocumentEvent e) {
                  System.out.println ("insert update");
                 updateLog(e, "inserted into");
             public void removeUpdate(DocumentEvent e) {
                  System.out.println ("remove update");
                 updateLog(e, "removed from");
             public void changedUpdate(DocumentEvent e) {
                 //Plain text components do not fire these events
             public void updateLog(DocumentEvent e, String action) {
                 Document doc = (Document)e.getDocument();
                 int changeLength = e.getLength();
                 textFieldRenderer3.append(
                     changeLength + " character" +
                     ((changeLength == 1) ? " " : "s ") +
                     action + doc.getProperty("name") + "." + newline +
                     "  Text length = " + doc.getLength() + newline);
          * @param args
         public static void main(String[] args) {
              try{
                   UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
              catch (Exception e){
                   e.printStackTrace();
             String[] columnNameArray = {
                       TEXT_COLUMN_HEADER,
                       "1",
                       "2",
              Object[][]  dataArray = {      {"", "", ""},      };
              final MyTable_TextArea panel = new MyTable_TextArea(dataArray, columnNameArray);
              final JFrame frame = new JFrame();
              frame.getContentPane().add(new JScrollPane(panel));
              frame.setTitle("My Table");
              frame.setPreferredSize(new Dimension(500, 200));
              frame.addWindowListener(new WindowAdapter(){
                   @Override
                   public void windowClosing(WindowEvent e) {
              frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
              frame.setLocation(300, 200);
              frame.pack();
              frame.setVisible(true);
    class TextFieldRenderer3 extends JTextArea implements TableCellRenderer {
         Icon defaultIcon;
         boolean isChecked = false;
         public TextFieldRenderer3() {
              System.out.println ("TextFieldRenderer()");
              setToolTipText("Double click to type");
         @Override
         public Component getTableCellRendererComponent(JTable table,
                   Object value,
                   boolean isSelected,
                   boolean hasFocus,
                   int row,
                   int column) {
              System.out.println ("TextFieldRenderer.getTableCellRendererComponent() row/column: " + row + "\t"+ column);
              return this;
    }

    I've implemented in the cell editor. I don't see how to get the value being typed (and nothing appears in the text area)
    import java.awt.Component;
    import java.awt.Dimension;
    import java.awt.event.WindowAdapter;
    import java.awt.event.WindowEvent;
    import java.util.EventObject;
    import javax.swing.Icon;
    import javax.swing.JFrame;
    import javax.swing.JScrollPane;
    import javax.swing.JTable;
    import javax.swing.JTextArea;
    import javax.swing.UIManager;
    import javax.swing.event.CellEditorListener;
    import javax.swing.event.DocumentEvent;
    import javax.swing.event.DocumentListener;
    import javax.swing.table.DefaultTableModel;
    import javax.swing.table.TableCellEditor;
    import javax.swing.table.TableCellRenderer;
    import javax.swing.table.TableColumn;
    import javax.swing.text.Document;
    public class MyTable_TextArea extends JTable {
         private DefaultTableModel defaultTableModel;
         private Object[][] dataArray;
         private Object[] columnNameArray;
         public final int TEXT_COLUMN = 0;     
         // column headers
         public static final String TEXT_COLUMN_HEADER = "Text";
         // text area
         TextAreaEditor textAreaEditor;
          * constructor
          * @param variableNameArray
          * @param columnNameArray
         public MyTable_TextArea(Object[][] variableNameArray, Object[] columnNameArray) {
              this.dataArray = variableNameArray;
              this.columnNameArray = columnNameArray;
              defaultTableModel = new DefaultTableModel(variableNameArray, columnNameArray);
              this.setModel(defaultTableModel)     ;
              // text field
            textAreaEditor = new TextAreaEditor();
              MyDocumentListener myListener = new MyDocumentListener();
              textAreaEditor.getDocument().addDocumentListener(myListener);
            TableColumn modelColumn = this.getColumnModel().getColumn(TEXT_COLUMN);
              modelColumn.setCellEditor(textAreaEditor);
          * nested class
         class MyDocumentListener implements DocumentListener {
             String newline = "\n";
             public void insertUpdate(DocumentEvent e) {
                  System.out.println ("insert update");
                 updateLog(e, "inserted into");
             public void removeUpdate(DocumentEvent e) {
                  System.out.println ("remove update");
                 updateLog(e, "removed from");
             public void changedUpdate(DocumentEvent e) {
                 //Plain text components do not fire these events
             public void updateLog(DocumentEvent e, String action) {
                 Document doc = (Document)e.getDocument();
                 int changeLength = e.getLength();
                 textAreaEditor.append(
                     changeLength + " character" +
                     ((changeLength == 1) ? " " : "s ") +
                     action + doc.getProperty("name") + "." + newline +
                     "  Text length = " + doc.getLength() + newline);
          * @param args
         public static void main(String[] args) {
              try{
                   UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
              catch (Exception e){
                   e.printStackTrace();
             String[] columnNameArray = {
                       TEXT_COLUMN_HEADER,
                       "1",
                       "2",
              Object[][]  dataArray = {      {"", "", ""},      };
              final MyTable_TextArea panel = new MyTable_TextArea(dataArray, columnNameArray);
              final JFrame frame = new JFrame();
              frame.getContentPane().add(new JScrollPane(panel));
              frame.setTitle("My Table");
              frame.setPreferredSize(new Dimension(500, 200));
              frame.addWindowListener(new WindowAdapter(){
                   @Override
                   public void windowClosing(WindowEvent e) {
              frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
              frame.setLocation(300, 200);
              frame.pack();
              frame.setVisible(true);
    class TextAreaEditor extends JTextArea implements TableCellEditor {
         Icon defaultIcon;
         boolean isChecked = false;
         public TextAreaEditor() {
              System.out.println ("TextAreaEditor()");
              setToolTipText("Double click to type");
         @Override
         public Component getTableCellEditorComponent(JTable arg0,
                   Object arg1,
                   boolean arg2,
                   int arg3,
                   int arg4) {
              System.out.println ("TextAreaEditor() arg1: " + arg1 + "arg2: " + arg2  + " arg3: " + arg3  + " arg4: " + arg4  );
              return null;
         @Override
         public void addCellEditorListener(CellEditorListener arg0) {
              System.out.println ("TextAreaEditor().addCellEditorListener");
         @Override
         public void cancelCellEditing() {
              System.out.println ("TextAreaEditor().cancelCellEditing");
         @Override
         public Object getCellEditorValue() {
              System.out.println ("TextAreaEditor().getCellEditorValue");
              return null;
         @Override
         public boolean isCellEditable(EventObject arg0) {
              System.out.println ("TextAreaEditor().isCellEditable");
              return true;
         @Override
         public void removeCellEditorListener(CellEditorListener arg0) {
              System.out.println ("TextAreaEditor().removeCellEditorListener");          
         @Override
         public boolean shouldSelectCell(EventObject arg0) {
              System.out.println ("TextAreaEditor().shouldSelectCell");
              return false;
         @Override
         public boolean stopCellEditing() {
              System.out.println ("TextAreaEditor().stopCellEditing");
              return false;
    }

  • Listener for CheckBoxes in JTable

    Hi,
    I have a table that displays a checkbox in one of the fields. Which event handler/ listener should I use? Eg: Checkbox listener, List listener or otherwise?
    A change in the checkbox value (tick or untick) will trigger recalculation.
    Thanks.

    I can't really understand your problem.
    Here's a simple example that will print out the new check box state when you press the checkbox:
    import javax.swing.JDialog;
    import javax.swing.JFrame;
    import javax.swing.JScrollPane;
    import javax.swing.JTable;
    import javax.swing.event.TableModelEvent;
    import javax.swing.event.TableModelListener;
    import javax.swing.table.DefaultTableModel;
    import javax.swing.table.TableModel;
    public class TableCheckboxListenerExample {
        public static void main(String[] args) {
            try {
                JFrame frame = new JFrame();
                frame.setDefaultCloseOperation(JDialog.EXIT_ON_CLOSE);
                DefaultTableModel model = new DefaultTableModel(new Object[][] {{Boolean.FALSE, "Row 1"}, {Boolean.TRUE, "Row 2"}}, new String[] {"col1", "col2"}) {
                    public Class<?> getColumnClass(int columnIndex) {
                        if (getRowCount() > 0 && getValueAt(0, columnIndex) != null)
                            return getValueAt(0, columnIndex).getClass();
                        return super.getColumnClass(columnIndex);
                model.addTableModelListener(new TableModelListener() {
                    public void tableChanged(TableModelEvent e) {
                        int row = e.getFirstRow();
                        int column = e.getColumn();
                        TableModel model = (TableModel)e.getSource();
                        Object data = model.getValueAt(row, column);
                        if (data instanceof Boolean)
                            System.out.println("Value changed in Row: " + row + " Column: " + column + " New Value = " + data);
                JTable table = new JTable(model);
                frame.add(new JScrollPane(table));
                frame.pack();
                frame.setVisible(true);
            catch (Exception e) {e.printStackTrace();}       
    }

  • IPad revert to preconfigured saved state on cold boot?

    We're looking to create a saved state for all the apps and OS settings for our many iPads that would reset automatically on a cold boot. Apple Configurator seems to require too much finagling. We're just looking for some kind of scripted solution that could recall our preconfigured settings for each iPad, restoring it to our business's preferred "pristine" condition whenever the iPad is started from a fully off state.
    I've searched for this everywhere online, but I'm not finding what seems like a very common need for a business that relies on iPads.
    Thanks in advance for any resources/apps/info you can provide!

    Is it the same keyboard you tried on all occassions?
    Sometimes there is a little gap, when the I/O-port metal bracket is not in properly.
    Have you tried PS2 mouse and keyboard? Is there any mentioning of this in Device Manager.
    Windows is keen on having USB-things hot-plugged, while that is totally wrong for PS2-things.

  • Missing Jar files javax.swing.text.Utilities(printTable)

    Hi Experts,
    please explain which jar files are required for Javax.swing.text.Utilites(printTable()).
    tilities utilities = new Utilities();
         ArrayList al = new ArrayList();
         al.add(IPrivateWOAccCodeView.IWOElement.RQT_NO);
         al.add(IPrivateWOAccCodeView.IWOElement.WO_TITLE);
         al.add(IPrivateWOAccCodeView.IWOElement.RQTR);
         al.add(IPrivateWOAccCodeView.IWOElement.TOT_AMT);
         al.add(IPrivateWOAccCodeView.IWOElement.STATUS);
         al.add(IPrivateWOAccCodeView.IWOElement.PLAN_START_DATE);
         al.add(IPrivateWOAccCodeView.IWOElement.TARGET_END_DATE);
         al.add(IPrivateWOAccCodeView.IWOElement.ACCOUNT_CODE);
         al.add(IPrivateWOAccCodeView.IWOElement.APPLY_AMOUNT);     
         //To print in HTML
         String printURL = (String) utilities.printTable(al,"Work Order Details By Account Code","Work Order Details By Account Code",wdContext.nodeWO()).get("url");
         wdContext.currentContextElement().setPrintURL(printURL);
        //@@end
    Error  in printTable that is method is undefined.
    Regards,
    Smruti
    Edited by: smruti moharana on Jun 20, 2011 8:10 AM

    According to my knowledge, there is no printTable method in javax.swing.text.Utilities class
    What are you trying to achieve?

  • Windows domain controller in a virtual machine: how dangerous is saving its state for a short period of time?

    I have a Windows Server 2012 R2 virtualization cluster. All the hosts are connected to an external storage system, and virtual machines' files are stored on external volumes (CSVs). All the hosts and virtual machines are a part of the same AD domain
    (mixed Windows Server 2012 RTM / 2008 R2 domain controllers). All the domain controllers are running in the virtual machines on the hosts of this cluster.
    To prevent problems when all the hosts are turned off and then on simultaneously (for example, because of a power failure) all the domain controller VM files has been placed on local disks of the virtualization hosts (not on the Cluster Shared
    Volumes). As Hyper-V services don't depend on other Windows Server services (except its networking components), it means that my domain controllers can always start, providing the virtualization host can start at all. However, it also means
    that those DCs cannot be (quickly) migrated to other hosts while their current hosts are being rebooted. So if I need to reboot a virtualization host to install new updates, for example, I have to shut down the corresponding DC, reboot the host
    and wait for the DC to finish cold boot and come back online. It means some interruption of service for our users, which, in turn, requires me to perform the reboots late in night.
    The downtime can be significantly decreased by saving the state of the VM in which the DC is running. However, all the articles I've found on the Internet strongly recommend against it. I'm trying to understand why this recommendation was issued in the first
    place. However, I'm unable to find a clear explanation. I've found some statements that saving state of a DC can cause serious AD replication problems because of tombstoning, and that the password of a DC computer account may be changed
    while the DC itself stays in the saved state, which could prevent the DC from connecting to the domain after its state has been restored. However, those considerations are non-significant when we discuss a short-time
    (5 to 10 minutes) saved state.
    I work with AD and virtualization long time, and I fail to see any danger in saving state of a DC for several minutes. In my opinion, after its state has been restored it would simply replicate all the AD changes from other DCs, and that's all.
    What's your opinion?
    Evgeniy Lotosh
    MSCE: Server infractructire, MCSE: Messaging

    Hello,
    as stated in "http://technet.microsoft.com/en-us/library/virtual_active_directory_domain_controller_virtualization_hyperv(v=ws.10).aspx"
    Operational Considerations for Virtualized Domain Controllers
    Domain controllers that are running on virtual machines have operational restrictions that do not apply to domain controllers that are running on physical machines. When you use a virtualized domain controller, there are some virtualization software features
    and practices that you should not use:
    Do not pause, stop, or store the
    saved state of a domain controller
    in a virtual machine for time periods longer than the tombstone lifetime of the forest and then resume from the paused or saved state.
    This may sound as it is supported to store it for shorter times and use it.
    BUT recommendation also from the Hyper-V Program manager in
    http://blogs.msdn.com/b/virtual_pc_guy/archive/2008/11/24/the-domain-controller-dilemma.aspx recommends against using them.
    Also best practices
    http://blogs.technet.com/b/vikasma/archive/2008/07/24/hyper-v-best-practices-quick-tips-2.aspx
    Best regards
    Meinolf Weber
    MVP, MCP, MCTS
    Microsoft MVP - Directory Services
    My Blog: http://blogs.msmvps.com/MWeber
    Disclaimer: This posting is provided AS IS with no warranties or guarantees and confers no rights.
    Twitter:  

  • Saved state is not backuped in HyperV backup for Win2012R2

    I am trying to backup Win2012 R2 VM on my Win2012 R2 hyperv host using VSS.
    Before starting backup my vm is in Saved status.
    But after backup I cant find saved state file *vsv and *bin file in the backup so I am loosing whatever contains I have in saved state.
    Its working fine on Win2008. Is there any change in VSS/Saved state behavior in Win2012R2?
    hypervbackup is the utility  I used to run backup.
    Thanks In advance. Please let me know if more details are required.

    Hi Sir,
    According to your description , one thing came into my mind .
    In 2008/R2 , to backup VM online the hyper-v vss writer must be registered , if not , the VM will run into saved state untill accomplishing  the backup .
    http://blogs.technet.com/b/askcore/archive/2008/08/20/how-to-enable-windows-server-backup-support-for-the-hyper-v-vss-writer.aspx
    If you are in that case ( hyper-v VSS writer was not registered in 2008/R2 ) , actually the backup will perform a file based backup  , it will keep the VSV file there .  
    If you do same backup in 2012 R2 (select VM's folder then backup) , the VSV file should be backed up .
    In 2012/R2 you do not to manually register vss writer , you just need to select VM and backup .
    Best Regards,
    Elton Ji
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact [email protected] .

  • Fix for PENDING in javax.swing.text.html.ParagraphView line #131

    Investigating source of HTMLEditorKit I found many PENDING things. That's fix for one of them - proper minimal necessary span detecting in table cells.
    Hope it will help to somebody else.
    import javax.swing.*;
    import javax.swing.text.html.*;
    import javax.swing.text.html.ParagraphView;
    import javax.swing.text.*;
    import java.awt.*;
    import java.text.*;
    import java.util.ArrayList;
    public class App extends JFrame {
        public static String htmlString="<html>\n" +
                "<body>\n" +
                "<p>The following table is used to illustrate the PENDING in javax.swing.text.html.ParagraphView line #131 fix.</p>\n" +
                "<table cellspacing=\"0\" border=\"1\" width=\"50%\" cellpadding=\"3\">\n" +
                "<tr>\n" +
                "<td>\n" +
                "<p>111111111111111111111111111111111<b>bold</b>22222222222222222222222222222</p>\n" +
                "</td>\n" +
                "<td>\n" +
                "<p>-</p>\n" +
                "</td>\n" +
                "</tr>\n" +
                "</table>\n" +
                "<p></p>\n" +
                "</body>\n" +
                "</html>";
        JEditorPane editor=new JEditorPane();
        JEditorPane editor2=new JEditorPane();
        public static void main(String[] args) {
            App app = new App();
            app.setVisible(true);
        public App() {
            super("HTML span fix example");
            setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            JSplitPane split=new JSplitPane(JSplitPane.VERTICAL_SPLIT, createFixedPanel(), createOriginalPanel());
            getContentPane().add(split);
            setSize(700, 500);
            split.setDividerLocation(240);
            setLocationRelativeTo(null);
        JComponent createOriginalPanel() {
            JPanel p=new JPanel(new BorderLayout());
            p.add(new JLabel("Original HTMLEditorKit"), BorderLayout.NORTH);
            HTMLEditorKit kit=new HTMLEditorKit();
            editor2.setEditorKit(kit);
            editor2.setContentType("text/html");
            editor2.setText(htmlString);
            p.add(new JScrollPane(editor2), BorderLayout.CENTER);
            return p;
        JComponent createFixedPanel() {
            JPanel p=new JPanel(new BorderLayout());
            p.add(new JLabel("Fixed HTMLEditorKit"), BorderLayout.NORTH);
            HTMLEditorKit kit=new MyHTMLEditorKit();
            editor.setEditorKit(kit);
            editor.setContentType("text/html");
            editor.setText(htmlString);
            p.add(new JScrollPane(editor), BorderLayout.CENTER);
            return p;
    class MyHTMLEditorKit extends HTMLEditorKit {
        ViewFactory defaultFactory=new MyHTMLFactory();
        public ViewFactory getViewFactory() {
            return defaultFactory;
    class MyHTMLFactory extends HTMLEditorKit.HTMLFactory {
        public View create(Element elem) {
            View v=super.create(elem);
            if (v instanceof ParagraphView) {
                v=new MyParagraphView(elem);
            return v;
    class MyParagraphView extends ParagraphView {
        public MyParagraphView(Element elem) {
            super(elem);
        protected SizeRequirements calculateMinorAxisRequirements(int axis, SizeRequirements r) {
            r = super.calculateMinorAxisRequirements(axis, r);
            float min=getLongestWordSpan();
            r.minimum = Math.max(r.minimum, (int) min);
            return r;
        public float getLongestWordSpan() {
            if (getContainer()!=null && getContainer() instanceof JTextComponent) {
                try {
                    int offs=0;
                    JTextComponent c=(JTextComponent)getContainer();
                    Document doc=getDocument();
                    int start=getStartOffset();
                    int end=getEndOffset()-1; //don't need the last \n
                    String text=doc.getText(start, end - start);
                    if(text.length() > 1) {
                        BreakIterator words = BreakIterator.getWordInstance(c.getLocale());
                        words.setText(text);
                        ArrayList<Integer> wordBounds=new ArrayList<Integer>();
                        wordBounds.add(offs);
                        int count=1;
                        while (offs<text.length() && words.isBoundary(offs)) {
                            offs=words.next(count);
                            wordBounds.add(offs);
                        float max=0;
                        for (int i=1; i<wordBounds.size(); i++) {
                            int wStart=wordBounds.get(i-1)+start;
                            int wEnd=wordBounds.get(i)+start;
                            float span=getLayoutSpan(wStart,wEnd);
                            if (span>max) {
                                max=span;
                        return max;
                } catch (BadLocationException e) {
                    e.printStackTrace();
            return 0;
        public float getLayoutSpan(int startOffset, int endOffset) {
            float res=0;
            try {
                Rectangle r=new Rectangle(Short.MAX_VALUE, Short.MAX_VALUE);
                int startIndex= layoutPool.getViewIndex(startOffset,Position.Bias.Forward);
                int endIndex= layoutPool.getViewIndex(endOffset,Position.Bias.Forward);
                View startView=layoutPool.getView(startIndex);
                View endView=layoutPool.getView(endIndex);
                int x1=startView.modelToView(startOffset,r,Position.Bias.Forward).getBounds().x;
                int x2=endView.modelToView(endOffset,r,Position.Bias.Forward).getBounds().x;
                res=startView.getPreferredSpan(View.X_AXIS)-x1;
                for (int i=startIndex+1; i<endIndex; i++) {
                    res+=layoutPool.getView(i).getPreferredSpan(View.X_AXIS);
                res+=x2;
            } catch (BadLocationException e) {
                e.printStackTrace();
            return res;
    }Regards,
    Stas

    I'm changing the foreground color with
    MutableAttributeSet attr = new SimpleAttributeSet();
    StyleConstants.setForeground(attr, newColor);
    int start=MyJTextPane..getSelectionStart();
    int end=MyJTextPane.getSelectionEnd();
    if (start != end) {
    htmlDoc.setCharacterAttributes(start, end, attr, false);
    else {
    MutableAttributeSet inputAttributes =htmlEditorKit.getInputAttributes();
    inputAttributes.addAttributes(attr);   

  • VDI in saved state however no configuration for save delay?

    I have a 2012 R2 VDI collection (personal, unmanaged) that is not configured for Save Delay.  However, I have many VDI that resort to a Saved State when not in use.  Is this saved state an included feature of 2012 R2 and is that different than
    the save delay?

    Hi Jason,
    Thank you for posting in Windows Server Forum.
    Have you find any relevant log related to this issue on host and guest side?
    When a user connects to the VM collection, RDS and Hyper-V should wake up the VM and restore it to a running state.  Is this not happening in your collection?
    To save resources, the VMs in a collection will not all be in a running state all the time unless the admin manually changes their state via the RDMS console.  
    (Quoted from this thread, by “dgeddes
    [MSFT]”)
    Apart from this, you can refer beneath articles.
    1.Lab Ops 6 – Setup VDI in Windows Server 2012R2
    2. Disable save state on virtual machines in Hyper-V
    Hope it helps!
    Thanks.
    Dharmesh Solanki

  • Help with an If Statement for a Message Dialog

    Hello all! I need help yet once again! I would prefer hints and nudges rather then the answer please, as this is for a homework assignment. Okay I am supposed to write a program that has 3 text boxes to enter a number between 0 and 255 (for red green and blue) and then the user should push the show button and the background color should change, which I have all working! But I am supposed to have a " gracefully handle the situation where the user enters an invalid color value (any number less than zero or greater than 255)" and I have the if statement written, but for some reason, whenever I hit the show button it always pops up that window, no matter what the user types in. So I need help figuring out how to make it stop popping up all of the time! Here is the code: Any other ideas on how to make the code better would be much appreciated!!! Thanks in advance!
    import java.awt.GridLayout;
    import java.awt.BorderLayout;
    import java.awt.Color;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JOptionPane;
    import javax.swing.JTextField;
    import javax.swing.JPanel;
    import javax.swing.BorderFactory;
    public class ColorEditor extends JPanel {
         private JLabel labelRed;
         private JLabel labelGreen;
         private JLabel labelBlue;
         private JTextField textFieldRed;
         private JTextField textFieldGreen;
         private JTextField textFieldBlue;
         private JButton showButton;
         private JButton exitButton;
         private JOptionPane optionPane;
         public ColorEditor()
              super(new BorderLayout());
              labelRed = new JLabel("red: ");
              textFieldRed = new JTextField(5);
              labelGreen = new JLabel("green: ");
              textFieldGreen = new JTextField(5);
              labelBlue = new JLabel("blue: ");
              textFieldBlue = new JTextField(5);
              showButton = new JButton("show");
              exitButton = new JButton("exit");
              JPanel labelPane = new JPanel(new GridLayout(0,1));
              labelPane.add(labelRed);
              labelPane.add(labelGreen);
              labelPane.add(labelBlue);
              labelPane.add(showButton);
              JPanel fieldPane = new JPanel( new GridLayout(0,1));
              fieldPane.add(textFieldRed);
              fieldPane.add(textFieldGreen);
              fieldPane.add(textFieldBlue);
              fieldPane.add(exitButton);
              setBorder(BorderFactory.createEmptyBorder(40,40,40,40));
              add(labelPane, BorderLayout.LINE_START);
              add(fieldPane, BorderLayout.CENTER);
              TextFieldHandler handler = new TextFieldHandler();
              textFieldRed.addActionListener(handler);
              textFieldGreen.addActionListener(handler);
              textFieldBlue.addActionListener(handler);
              showButton.addActionListener(handler);
         private class TextFieldHandler implements ActionListener
              public void actionPerformed(ActionEvent event)
                   if (event.getSource() == showButton)
                        String textRed = textFieldRed.getText();
                        String textGreen = textFieldGreen.getText();
                        String textBlue = textFieldBlue.getText();
                        int a = Integer.parseInt(textRed);
                        int b = Integer.parseInt(textGreen);
                        int c = Integer.parseInt(textBlue);
                        if ((a < 0) || (a > 255)||(b<0)||(b>255)||(c<0)||(c>255));
                             optionPane.showMessageDialog(null, "Please enter a number between 0 and 255!");//HERE IS WHERE I NEED THE HELP!!
                        Color colorObject = new Color(a,b,c);
                        setBackground(colorObject);
         public static void main(String args[])
              JFrame frame = new JFrame("Color Editor");
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE );
              frame.add(new ColorEditor());
              frame.pack();
              frame.setVisible(true);
    }

    Okay now Eclipse is giving me a really funky error that I cannot quite figure out (in the compiler) but my program is running fine.... Can you help me with this too?
    Here is what the compiler is giving me....
    Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: Color parameter outside of expected range: Green
    +     at java.awt.Color.testColorValueRange(Unknown Source)+
    +     at java.awt.Color.<init>(Unknown Source)+
    +     at java.awt.Color.<init>(Unknown Source)+
    +     at ColorEditor$TextFieldHandler.actionPerformed(ColorEditor.java:80)+
    +     at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)+
    +     at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)+
    +     at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)+
    +     at javax.swing.DefaultButtonModel.setPressed(Unknown Source)+
    +     at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)+
    +     at java.awt.Component.processMouseEvent(Unknown Source)+
    +     at javax.swing.JComponent.processMouseEvent(Unknown Source)+
    +     at java.awt.Component.processEvent(Unknown Source)+
    +     at java.awt.Container.processEvent(Unknown Source)+
    +     at java.awt.Component.dispatchEventImpl(Unknown Source)+
    +     at java.awt.Container.dispatchEventImpl(Unknown Source)+
    +     at java.awt.Component.dispatchEvent(Unknown Source)+
    +     at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)+
    +     at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)+
    +     at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)+
    +     at java.awt.Container.dispatchEventImpl(Unknown Source)+
    +     at java.awt.Window.dispatchEventImpl(Unknown Source)+
    +     at java.awt.Component.dispatchEvent(Unknown Source)+
    +     at java.awt.EventQueue.dispatchEvent(Unknown Source)+
    +     at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)+
    +     at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)+
    +     at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)+
    +     at java.awt.EventDispatchThread.pumpEvents(Unknown Source)+
    +     at java.awt.EventDispatchThread.pumpEvents(Unknown Source)+
    +     at java.awt.EventDispatchThread.run(Unknown Source)+

  • Error while saving state in 'client' , in ADF faces application

    Thank you for reading my post
    I have an ADF faces application and i get this error and my application does not function correctly , does any one has an idea ?
    thanks
    06/10/17 17:34:38.15 10.1.3.1.0 Started
    06/10/17 17:34:55.546 web2: 10.1.3.1.0 Started
    06/10/17 17:45:49.531 web2: Servlet error
    java.lang.NullPointerException
         at com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:322)
         at com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:130)
         at oracle.adfinternal.view.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:157)
         at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:87)
         at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
         at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:117)
         at javax.faces.webapp.FacesServlet.service(FacesServlet.java:198)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0) ].server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:64)
         at oracle.adfinternal.view.faces.webapp.AdfFacesFilterImpl._invokeDoFilter(AdfFacesFilterImpl.java:367)
         at oracle.adfinternal.view.faces.webapp.AdfFacesFilterImpl._doFilterImpl(AdfFacesFilterImpl.java:336)
         at oracle.adfinternal.view.faces.webapp.AdfFacesFilterImpl.doFilter(AdfFacesFilterImpl.java:196)
         at oracle.adf.view.faces.webapp.AdfFacesFilter.doFilter(AdfFacesFilter.java:87)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0) ].server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:621)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0) ].server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:368)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0) ].server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:866)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0) ].server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:448)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0) ].server.http.HttpRequestHandler.serveOneRequest(HttpRequestHandler.java:216)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0) ].server.http.HttpRequestHandler.run(HttpRequestHandler.java:117)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0) ].server.http.HttpRequestHandler.run(HttpRequestHandler.java:110)
         at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0) ].util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303)
         at java.lang.Thread.run(Thread.java:619)
    06/10/17 17:46:02.703 web2: Servlet error
    javax.servlet.jsp.JspException: Error while saving state in 'client': 'An established connection was aborted by the software in your host machine'.
         at com.sun.faces.taglib.jsf_core.ViewTag.doAfterBody(ViewTag.java:206)
         at _index._jspService(_index.java:473)
         at com.orionserver[Oracle Containers for J2EE 10g (10.1.3.1.0) ].http.OrionHttpJspPage.service(OrionHttpJspPage.java:59)
         at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:453)
         at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:591)
         at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:515)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0) ].server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:711)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0) ].server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:368)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0) ].server.http.ServletRequestDispatcher.unprivileged_forward(ServletRequestDispatcher.java:287)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0) ].server.http.ServletRequestDispatcher.access$100(ServletRequestDispatcher.java:50)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0) ].server.http.ServletRequestDispatcher$2.oc4jRun(ServletRequestDispatcher.java:193)
         at oracle.oc4j.security.OC4JSecurity.doPrivileged(OC4JSecurity.java:283)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0) ].server.http.ServletRequestDispatcher.forward(ServletRequestDispatcher.java:198)
         at com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:322)
         at com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:130)
         at oracle.adfinternal.view.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:157)
         at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:87)
         at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
         at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:117)
         at javax.faces.webapp.FacesServlet.service(FacesServlet.java:198)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0) ].server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:64)
         at oracle.adfinternal.view.faces.webapp.AdfFacesFilterImpl._invokeDoFilter(AdfFacesFilterImpl.java:367)
         at oracle.adfinternal.view.faces.webapp.AdfFacesFilterImpl._doFilterImpl(AdfFacesFilterImpl.java:336)
         at oracle.adfinternal.view.faces.webapp.AdfFacesFilterImpl.doFilter(AdfFacesFilterImpl.java:196)
         at oracle.adf.view.faces.webapp.AdfFacesFilter.doFilter(AdfFacesFilter.java:87)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0) ].server.http.EvermindFilterChain.doFilter(EvermindFilterChain.java:15)
         at oracle.adf.model.servlet.ADFBindingFilter.doFilter(ADFBindingFilter.java:167)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0) ].server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:619)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0) ].server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:368)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0) ].server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:866)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0) ].server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:448)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0) ].server.http.HttpRequestHandler.serveOneRequest(HttpRequestHandler.java:216)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0) ].server.http.HttpRequestHandler.run(HttpRequestHandler.java:117)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0) ].server.http.HttpRequestHandler.run(HttpRequestHandler.java:110)
         at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0) ].util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303)
         at java.lang.Thread.run(Thread.java:619)

    StateManagerImpl.saveSerializedView tries to let UIViewRoot be a session
    attribute and the error message says it should be serializable; certainly it' not.
    I think HttpSession.setAttribute does not claim the object should be serializable.
    I don't know why apache's StandardSession.setAttribute claims so.

  • What is import statement for ?

    Hi all,
    Sorry for asking a silly question. Since it is a new to java forum I am asking this.
    What is happening when an import statement is triggered at compile time and at runtime.
    What is the difference/advantages/disadvantages between importing an entire package and importing required classes only.
    Is there any size limit on the generated class file.
    rgds
    Antony Paul

    looks like we are both beguinners
    i just received a newsletter from sun and in it has this
    MONITORING CLASS LOADING AND GARBAGE COLLECTION
    Have you ever wondered what classes are loaded when you launch an application or from where the classes are loaded? Have you ever wondered when garbage collection runs or how long it takes? The java command line tool offers several different command line options that you can use to get answers to those questions.
    You might already be familiar with a number of command line options available with the java command line tool, such as -cp, -Xms, and -Xmx. The -cp option is used for specifying the classpath. The -Xms and -Xmx options are used to specify the heap size. For example, instead of setting the CLASSPATH environment variable, you can use the -cp option to tell the system to look in a specific directory for necessary class files:
    java -cp ExampleDir MyExample
    Here, the system will look in the ExampleDir subdirectory for the MyExample.class file and anything else needed besides the system classes. The ExampleDir in the command line tells the system to look only in the ExampleDir directory (assume that it's the parent directory). If MyExample.class is located in the current working directory, the system would not find it.
    Two less frequently used command line features report on class loading and garbage collection. The -verbose:class option reports when a class is loaded into the Java virtual machine and from where it came. For instance, if you use the -verbose:class option when loading the SwingSet2 demo that comes with the J2SE 1.4.2 SDK, you get a report on the many different classes that are loaded as part of the demo, such the following two:
    java -verbose:class -jar
    C:\j2sdk1.4.2\demo\jfc\SwingSet2\SwingSet2.jar
    [Loaded FilePreviewer]
    [Loaded javax.swing.plaf.TableUI from
         C:\j2sdk1.4.2\jre\lib\rt.jar]
    The first line indicates that the class came from the main JAR for the demo (assuming it was started with java -jar SwingSet2.jar). The second line indicates that the TableUI class was loaded from the rt.jar file that comes with the runtime located in the c:\j2sdk1.4.2\jre directory. (From there, the rt.jar file is located in the lib subdirectory.) Different implementations of the Java platform can have different formats here. The only requirement is that -verbose:class displays messages as classes get loaded and unloaded.
    Let's see when classes are loaded, and how many classes are needed for the following simple program:
    public class Sample {
    public static void main(String args[]) {
    System.out.println("Hello, World");
    Compile the Sample class. Then run it with the -verbose:class option enabled:
    java -verbose:class Sample
    When you run the command, you'll see that this simple program requires the opening of five jar files (such as rt.jar) and the loading of almost 250 classes.
    To see an example of a class unloading message, try the -verbose:class command line option with the RunItReload class shown in the August 19, 2003 Tech Tip titled Unloading and Reloading Classes.
    The -verbose:gc option reports on each garbage collection event. This includes the time for garbage collection to run, and the before and after heap sizes. This is demonstrated in the following lines:
    [GC 27872K->26296K(42216K), 0.0069590 secs]
    [GC 28973K->26455K(42216K), 0.0036812 secs]
    [GC 29134K->26474K(42216K), 0.0016388 secs]
    [GC 29117K->26487K(42216K), 0.0008859 secs]
    [GC 29134K->26498K(42216K), 0.0009197 secs]
    [GC 29180K->26479K(42216K), 0.0008711 secs]
    [GC 29149K->26484K(42216K), 0.0008716 secs]
    Like the output for -verbose:class, there is no requirement for output format, and it is subject to change without notice. The "GC" at the beginning indicates what kind of collection occurred. The number before the "->" is the heap occupancy before the collection. The number after the "->" is the heap occupancy after the collection. The number in parentheses is the currently allocated size of the heap. The seconds are the duration of the collection.
    This information can be useful in debugging. For example, it could help you determine if garbage collection happened at a critical point in time, and might have caused a program to crash. This sometimes happens when mixing Java and C/C++ code with JNI, especially when there is an underlying bug on the C/C++ code side.
    If you're ever curious about why it takes so long for an application to start, or if garbage collection in the middle of an operation appears to cause a problem, be sure to try out these command line options.
    hope it helps

  • Question for everyone: Swing Design Patterns

    I've used kodo for many web projects, but I am currently looking at using it
    for a swing application and am having a hard time figuring out the best way
    to use it.
    My original attempt used a singleton PersistenceManager for the entire
    application that always had a running transaction. When the application
    started, the pm was created, and currentTransaction.begin() was called.
    Whenever anything was done that needed to change the JDO-persisted business
    objects, I would simply make the necessary method calls to the business
    objects. Whenever the user wanted their changes to be saved (committed)
    there was a "File->Save All" menu item that did a
    currentTransaction.commit() then a currentTransaction.begin(). This seemed
    very easy to do, and I could even bind JTextFields etc. directly to
    getters/setters and all data to and from the swing app was nice and easy. I
    see two problems with this, however:
    1) The user needs to remember to call "file->save all" from time to time,
    which is not always done
    2) It makes an all-or-nothing approach to saving data. You cannot have a
    "ok/cancel/apply" button on each window that commits only the data changed
    in that window.
    I could get rid of the "file->save all" necessity by having it auto-commit
    after certain things are done. The trouble is, I think that would probably
    be after each text field etc. looses focus and would lead to a lot of commit
    overhead as well as default fields that shouldn't really be committed to the
    database being committed.
    My next attempt was to try to make the entering/editing of data independent
    from the gets/sets/business methods on the business objects. In this
    attempt, there is still a singleton pm, but no on-going transaction. On
    each "OK" button click, transactions are begun, the information set in the
    swing components are transferred to the business objects, and the
    transaction is committed. Before long, however, it got very unwieldy to try
    to manually track how swing controls map to business object calls. I did
    find a nice pattern where there is a "BufferedValueHolder" object that you
    could use for storing information, and when a passed variable would change
    values (which you would change on your "OK" button), then it would
    automatically send the new value to the underlying business objects which
    would then be committed. This helped a lot on simple properties that can be
    modified, but fell apart when you had more complex business logic such as
    "when they hit the approve button, the approver needs to be set to the
    logged in user, the approval date must be set to the current date, and the
    item must be removed from the unapproved list". Since I can't call the
    ..approve() method on the business object when the approve button is hit
    (since it is not running in a transaction), I must move/duplicate all the
    logic of which swing fields must be changed into the UI layer, in which it
    doesn't belong.
    That's where I am so far. I thought about trying to create a new pm for
    each window/transaction, but I think that would lead to too many "this
    object not managed by this PM" exceptions. I've looked at the swing example
    in the Kodo download, but the example does not seem to fit a more complex
    application than the one provided. I also checked out JDOCentral.com, but
    couldn't find anything in their code exchange. Any suggestions would be
    very welcome.
    Nathan

    Thanks for the quick response!
    What do you mean by a DataSource class? For example, suppose you have the
    following PC class:
    public class Task {
    private Integer id;
    private String name;
    private String approvedBy;
    private Date approvalDate;
    ..... (getters and setters)
    public void approve(String approver) {
    approvedBy = approver;
    approvalDate = new Date();
    Would you have a DataSource class that is a duplicate of Task except that
    getters and setters throw properyChangedEvents? Does it help to have the
    DataSource object extend the PC object? Where would you put the approve()
    method? On the Task or the TaskDataSource object? How does the DataSource
    object know to save its information to the base Task object, by registering
    with the PM?
    I like the idea of not starting a transaction untill the DataSource changes.
    Does refreshing each PC simply require a call to PM.refresh(), or does it
    take more than that?
    Nathan
    "Alex Roytman" <[email protected]> wrote in message
    news:[email protected]...
    We use:
    - single PM
    - we use DataSource concept (proxy to percistent classes which fires
    property change events on state change) to facilitate MVC
    - Transaction started and commited per dialog box. It is started by
    listeners attached to DataSource class so we do not start transactionbefor
    each opening of a dialog box bu only when attempt is made to make a change
    to state of a PC
    - Dirtiest part is thet we have to refresh each PC instance (or sme time a
    graph of instances) before we present it for editing
    Have fun
    Alex
    "Nathan Voxland" <[email protected]> wrote in message
    news:[email protected]...
    I've used kodo for many web projects, but I am currently looking at
    using
    it
    for a swing application and am having a hard time figuring out the bestway
    to use it.
    My original attempt used a singleton PersistenceManager for the entire
    application that always had a running transaction. When the application
    started, the pm was created, and currentTransaction.begin() was called.
    Whenever anything was done that needed to change the JDO-persistedbusiness
    objects, I would simply make the necessary method calls to the business
    objects. Whenever the user wanted their changes to be saved (committed)
    there was a "File->Save All" menu item that did a
    currentTransaction.commit() then a currentTransaction.begin(). Thisseemed
    very easy to do, and I could even bind JTextFields etc. directly to
    getters/setters and all data to and from the swing app was nice and
    easy.
    I
    see two problems with this, however:
    1) The user needs to remember to call "file->save all" from time to
    time,
    which is not always done
    2) It makes an all-or-nothing approach to saving data. You cannot havea
    "ok/cancel/apply" button on each window that commits only the datachanged
    in that window.
    I could get rid of the "file->save all" necessity by having itauto-commit
    after certain things are done. The trouble is, I think that wouldprobably
    be after each text field etc. looses focus and would lead to a lot ofcommit
    overhead as well as default fields that shouldn't really be committed tothe
    database being committed.
    My next attempt was to try to make the entering/editing of dataindependent
    from the gets/sets/business methods on the business objects. In this
    attempt, there is still a singleton pm, but no on-going transaction. On
    each "OK" button click, transactions are begun, the information set in
    the
    swing components are transferred to the business objects, and the
    transaction is committed. Before long, however, it got very unwieldy totry
    to manually track how swing controls map to business object calls. I
    did
    find a nice pattern where there is a "BufferedValueHolder" object thatyou
    could use for storing information, and when a passed variable wouldchange
    values (which you would change on your "OK" button), then it would
    automatically send the new value to the underlying business objectswhich
    would then be committed. This helped a lot on simple properties thatcan
    be
    modified, but fell apart when you had more complex business logic such
    as
    "when they hit the approve button, the approver needs to be set to the
    logged in user, the approval date must be set to the current date, andthe
    item must be removed from the unapproved list". Since I can't call the
    .approve() method on the business object when the approve button is hit
    (since it is not running in a transaction), I must move/duplicate allthe
    logic of which swing fields must be changed into the UI layer, in whichit
    doesn't belong.
    That's where I am so far. I thought about trying to create a new pm for
    each window/transaction, but I think that would lead to too many "this
    object not managed by this PM" exceptions. I've looked at the swingexample
    in the Kodo download, but the example does not seem to fit a more
    complex
    application than the one provided. I also checked out JDOCentral.com,but
    couldn't find anything in their code exchange. Any suggestions would be
    very welcome.
    Nathan

Maybe you are looking for

  • Final Cut Studio 2 and Panasonic HMC150 on the Big Screen?

    I'm in the process of funding a film student who requires a system that will let him produce shorts that potentially could end up on a small theater screen. My question is, would the Panasonic HMC150 AVCCAM (AVCHD) and FC Studio2 help him create a pr

  • Photoshop CS6 crashes when trying to print

    I'm using Photoshop CS6 for quite a while without any problems. Im running PS CS6 on Windows 7 Pro x64. Since a few days Photohop always crashes without any message when I try to open the printing dialogue. That happens before the dialogue is shown,

  • Blank pdf documents in Adobe

    Hi. Can anyone help with this please? When I am sent pdf documents by Mail, and I try to open them with Adobe Reader, I am sometimes told the required font (Times New Roman in this case) 'cannot be found or created' and the document appears as a blan

  • How to import video from canon xa10

    I can import video file from canon xa-10 camcorder to Final Cut Pro X. Please help.

  • How to edit .mov files?

    I installed premiere cs4 on my pc. When I imported some .mov files into the project, I can preview the video clips but without sound. I installed the sound card driver correctly and can play mp3 files normally. anyone gave some tips?