【发布时间】:2014-03-31 12:15:28
【问题描述】:
我有一个带有 JTextPane 的程序。当我想在其中打印时,我的问题就来了。每次,它将在第一行打印并将其余的向下移动。 我怎样才能让它打印在文本的末尾?
我知道了:
//...
public static enum Level {
CLASSIC,
MAJ,
AJOUT,
SUPRESSION,
CONFIG;
}
public static void add(Level level,String Message){
switch(level){
case CLASSIC:
try{
Color BLACK = new Color(0, 0, 0);
StyleConstants.setForeground(Colors, BLACK);
Text.insertString(0, "\n\t- Mise à jour # " + Message + " -\n\n", Colors);
}catch(Exception e) { ConsoleError(); }
break;
case MAJ:
try{
Color ORANGE = new Color(252, 156, 51);
StyleConstants.setForeground(Colors, ORANGE);
Text.insertString(0, Message + "\n", Colors);
}catch(Exception e) { ConsoleError(); }
break;
case AJOUT:
Color GREEN = new Color(58, 157, 52);
StyleConstants.setForeground(Colors, GREEN);
try{
Text.insertString(0, Message + "\n", Colors);
}catch(Exception e) { ConsoleError(); }
break;
case SUPRESSION:
Color RED = new Color(183, 19, 0);
StyleConstants.setForeground(Colors, RED);
try{
Text.insertString(0, Message + "\n", Colors);
}catch(Exception e) { ConsoleError(); }
break;
case CONFIG:
Color BLACK = new Color(0, 0, 0);
StyleConstants.setForeground(Colors, BLACK);
try{
Text.insertString(0, Message + "\n", Colors);
}catch(Exception e) { ConsoleError(); }
break;
}
}
//...
【问题讨论】:
标签: java swing console output jtextpane