Hallo,
Ich habe folgendes Problem. Wenn ich das angehängte Programm ausführe und vertikal skaliere bleibt es ab einer gewissen Grenze hängen, was für ein paar Sekunden mein gesamtes System zum Stehen bringt. Horizontal kann ich Skalieren so viel ich will ohne dabei Probleme festzustellen. Beim Maximieren tritt das selbe Problem auf.
Mein JNotePanel sieht folgendermaßen aus:
Liebe Grüße und Danke im Vorraus
Ich habe folgendes Problem. Wenn ich das angehängte Programm ausführe und vertikal skaliere bleibt es ab einer gewissen Grenze hängen, was für ein paar Sekunden mein gesamtes System zum Stehen bringt. Horizontal kann ich Skalieren so viel ich will ohne dabei Probleme festzustellen. Beim Maximieren tritt das selbe Problem auf.
Code:
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.GridLayout;
import java.awt.Insets;
import java.sql.Timestamp;
import java.text.DateFormat;
import javax.swing.JFormattedTextField;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
public class NoteWindow
extends JFrame
{
//---Default size-----------------------------------------------------------------------------
private int sizex = 600;
private int sizey = 300;
//----------------------------------------------------------------------------------------------
public NoteWindow(String text, DataSet data)
{
setSize(sizex,sizey);
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
GridBagLayout gbl = new GridBagLayout();
setLayout(gbl);
GridBagConstraints gbc;
JPanel labelcont = new JPanel(new GridLayout(2,2));
JLabel authorlabel = new JLabel("Autor: ");
JFormattedTextField txtfield = new JFormattedTextField();
//txtfield.setValue(arg0);
//txtfield.setColumns(100);
txtfield.setText(data.getAuthor());
txtfield.setEditable(false);
txtfield.setColumns(15);
labelcont.add(authorlabel);
labelcont.add(txtfield);
JLabel datelabel = new JLabel("geschrieben am: ");
JFormattedTextField datefield = new JFormattedTextField(DateFormat.DAY_OF_WEEK_FIELD);
datefield.setText(data.getDateTime().toString());
datefield.setEditable(false);
datefield.setColumns(15);
labelcont.add(datelabel);
labelcont.add(datefield);
gbc = makegbc(0,0,1,1);
gbc.weightx = 0;
gbc.weighty = 0;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.anchor = GridBagConstraints.NORTH;
gbl.setConstraints(labelcont,gbc);
add(labelcont);
/*
//empty panel
JPanel pan = new JPanel();
gbc = makegbc(0,1,1,1);
gbc.weightx = 1;
gbc.weighty = 1;
gbc.fill = GridBagConstraints.BOTH;
gbc.anchor = GridBagConstraints.NORTH;
gbl.setConstraints(pan,gbc);
add(pan);
*/
//Note pane
JNotePane txtpane = new JNotePane();
txtpane.setText(text);
JScrollPane sp = new JScrollPane(txtpane);
gbc = makegbc(0,2,1,1);
gbc.weightx = 30;
gbc.weighty = 30;
gbc.fill = GridBagConstraints.BOTH;
gbc.anchor = GridBagConstraints.SOUTH;
gbl.setConstraints(sp,gbc);
add(sp);
setVisible(true);
}
private GridBagConstraints makegbc(int x,int y,int width, int height)
{
GridBagConstraints gbc = new GridBagConstraints();
gbc.gridx = x;
gbc.gridy = y;
gbc.gridwidth = width;
gbc.gridheight = height;
gbc.insets = new Insets(1,1,1,1);
return gbc;
}
public static void main(String[] args) {
Timestamp stamp = new Timestamp(983221339);
String txt =
"<Font size=5 color=#336747 face=Tahoma>Editor Panes vs. Text Panes</font><blockquote>In order to use editor panes and text panes,you need to understand the text system,which is described in<a href=\"generaltext.html\">Text Component Features</a>.Several facts about editor panes and text panesare scattered throughout that section.Here we list the facts againand provide a bit more detail.The information here should help you understand the differencesbetween editor panes and text panes, and when to use which.<ul>[*] An editor pane or a text panecan easily be loaded with text from a URLusing the <code>setPage</code> method.The <code>JEditorPane</code> class also provides constructorsthat let you initialize an editor pane from a URL.The <code>JTextPane</code> class has no such constructors.See<a href=\"#editorpane\">Using an Editor Pane to Display Text From a URL</a>for an example that uses this feature to load an uneditable editor pane with HTML-formatted text.";
DataSet data = new DataSet(12,txt,stamp,"Name Name",1,stamp);
NoteWindow wnd = new NoteWindow(txt,data);
wnd.setLocation(300,300);
}
}
Mein JNotePanel sieht folgendermaßen aus:
Code:
import javax.swing.JEditorPane;
import javax.swing.text.html.HTMLEditorKit;
public class JNotePane
extends JEditorPane
{
private static final long serialVersionUID = 1L;
public JNotePane()
{
HTMLEditorKit htmlkit = new HTMLEditorKit();
setEditorKit(htmlkit);
setEditable(false);
}
}
Liebe Grüße und Danke im Vorraus