-1
像的話,我想改變文字顏色在我的項目這裏是我做了爪哇 - 文本格式改變
import java.awt.*;
import javax.swing.*;
import javax.swing.border.*;
import javax.swing.JFrame;
public class Cool extends JFrame {
private static final long serialVersionUID = 1L;
private JPanel contentPane;
private JTextField textField;
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
Cool frame = new Cool();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
public Cool() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
contentPane.setLayout(new BorderLayout(0, 0));
setContentPane(contentPane);
setTitle("JNotePad");
textField = new JTextField();
contentPane.add(textField, BorderLayout.NORTH);
textField.setColumns(30);
JScrollPane scrollPane = new JScrollPane();
contentPane.add(scrollPane, BorderLayout.CENTER);
JTextArea IAmText = new JTextArea();
IAmText.setRows(10);
IAmText.setColumns(30);
scrollPane.setViewportView(IAmText);
pack();
}
}
我可以用什麼,請解釋代碼。我將非常感激。 請!!! 我已經添加了所有我知道的任何身體可以給一個新的更新鮮的想法,就像我不知道更新鮮和更好的想法,可以改善這一點,任何人都可以幫助我用文字wrap.I希望當文本到達窗口的結尾時,它會自動到達下一行,這樣我就不必擔心它會一直長達一百二十英里,並且這個人卷軸和卷軸。
您需要使用JTextPane或JEditorPane – MadProgrammer
輸入字段的textcolor或什麼? – Jens
我的意思是,例如某人想寫一件紅色或其他格式的東西,我會用什麼 – user3725193