/* * NewJPanel.java * * Created on 2007/11/11, 21:19 */ package open.dolphin.client; import javax.swing.text.AbstractDocument; import javax.swing.text.BoxView; import javax.swing.text.ComponentView; import javax.swing.text.Element; import javax.swing.text.IconView; import javax.swing.text.LabelView; import javax.swing.text.ParagraphView; import javax.swing.text.StyleConstants; import javax.swing.text.StyledEditorKit; import javax.swing.text.View; import javax.swing.text.ViewFactory; /** * * @author kazm */ // 2013/06/06 //public class KartePanel1 extends Panel2 { public final class KartePanel1 extends Panel2 { /** Creates new form NewJPanel */ public KartePanel1() { initComponents(); //masuda^ jdk7 wrap 2013/06/06 getSoaTextPane().setEditorKit(new WrapEditorKit()); //masuda$ } /** 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. */ // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { jPanel2 = new javax.swing.JPanel(); timeStampLabel = new javax.swing.JLabel(); soaTextPane = new javax.swing.JTextPane(); jPanel2.setMaximumSize(new java.awt.Dimension(55, 26)); timeStampLabel.setText("jLabel1"); jPanel2.add(timeStampLabel); soaTextPane.setFont(new java.awt.Font("SansSerif", 0, 12)); // NOI18N soaTextPane.setMargin(new java.awt.Insets(10, 10, 10, 10)); org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jPanel2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 684, Short.MAX_VALUE) .add(soaTextPane, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 684, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) ); layout.setVerticalGroup( layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(layout.createSequentialGroup() .add(jPanel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 26, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(soaTextPane, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 628, Short.MAX_VALUE)) ); }// </editor-fold>//GEN-END:initComponents // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JPanel jPanel2; private javax.swing.JTextPane soaTextPane; private javax.swing.JLabel timeStampLabel; // End of variables declaration//GEN-END:variables //masuda^ jdk7 wrap 2013/06/06 class WrapEditorKit extends StyledEditorKit { ViewFactory defaultFactory=new WrapColumnFactory(); @Override public ViewFactory getViewFactory() { return defaultFactory; } } class WrapColumnFactory implements ViewFactory { @Override public View create(Element elem) { String kind = elem.getName(); if (kind != null) { if (kind.equals(AbstractDocument.ContentElementName)) { return new WrapLabelView(elem); } else if (kind.equals(AbstractDocument.ParagraphElementName)) { return new ParagraphView(elem); } else if (kind.equals(AbstractDocument.SectionElementName)) { return new BoxView(elem, View.Y_AXIS); } else if (kind.equals(StyleConstants.ComponentElementName)) { return new ComponentView(elem); } else if (kind.equals(StyleConstants.IconElementName)) { return new IconView(elem); } } // default to text display return new LabelView(elem); } } class WrapLabelView extends LabelView { public WrapLabelView(Element elem) { super(elem); } public float getMinimumSpan(int axis) { switch (axis) { case View.X_AXIS: return 0; case View.Y_AXIS: return super.getMinimumSpan(axis); default: throw new IllegalArgumentException("Invalid axis: " + axis); } } } //masuda^ jdk7 wrap public javax.swing.JTextPane getSoaTextPane() { return soaTextPane; } public javax.swing.JLabel getTimeStampLabel() { return timeStampLabel; } public javax.swing.JPanel getTimeStampPanel() { return jPanel2; } }