JTextPane pas de scrollbar
Salut,
J'essaye de rendre un JTextPane scrollable mais impossible
voici mon code
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
|
package com.odcgroup.page.ui;
import java.awt.BorderLayout;
import java.awt.Frame;
import javax.swing.JPanel;
import javax.swing.JTextPane;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.swt.SWT;
import org.eclipse.swt.awt.SWT_AWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IEditorSite;
import org.eclipse.ui.part.EditorPart;
public class CodeUIEditor extends EditorPart implements IEditorPart{
/** Instance of the class*/
private static CodeUIEditor instance;
/** The parent frame of the editor.*/
Composite parentFrame;
/** The panel*/
private JPanel panel;
/** The frame*/
private Frame frame;
/** The textfield */
private JTextPane contentPane;
/**
* Singleton
*
* @return CodeUIEditor The instance.
*/
public static CodeUIEditor getInstance() {
if (instance == null) instance = new CodeUIEditor();
return instance;
}
/**
* Initialize the editor.
*
* @param site
* @param input
*/
@Override
public void init(IEditorSite site, IEditorInput input) {
this.setSite(site);
this.setInput(input);
}
/**
* Sets the text to the contentPane.
*
* @param text The text to set.
*/
public void setText(String text) {
contentPane.setText(text);
contentPane.setCaretPosition(contentPane.getDocument().getLength());
}
/**
* Initialize the content.
*
* @param parent The parent component.
*/
public void createPartControl(Composite parent) {
parentFrame = new Composite(parent, SWT.EMBEDDED);
panel = new JPanel();
panel.setLayout(new BorderLayout());
frame = SWT_AWT.new_Frame(parentFrame);
frame.setLayout(new BorderLayout());
contentPane = new JTextPane();
contentPane.setEditable(true);
contentPane.setAutoscrolls(true);
panel.add(contentPane);
panel.setVisible(true);
frame.add(panel);
}
/**
* Set the focus to the current editor.
*/
@Override
public void setFocus() {
parentFrame.setFocus();
}
/*
* (non-Javadoc)
* @see org.eclipse.ui.part.MultiPageEditorPart#isDirty
* */
public boolean isDirty() {
return true;
}
/*
* (non-Javadoc)
* @see org.eclipse.ui.part.MultiPageEditorPart#doSave(org.eclipse.core.runtime.IProgressMonitor)
* */
public void doSave(IProgressMonitor monitor) {
}
/*
* (non-Javadoc)
* @see org.eclipse.ui.part.MultiPageEditorPart#doSaveAs
* */
public void doSaveAs() {
}
/*
* (non-Javadoc)
* @see org.eclipse.ui.part.MultiPageEditorPart#isSaveAllowed
* */
public boolean isSaveAsAllowed() {
return false;
}
} |
d'avance merci