JEditorPane farvning af linie og linienummer..
Hej eksperter..Til at vise hvilken linie man arbejder på, har Textpad valgt at farve hele linien i en diskret farve, som man kan se her
http://www.thehive.dk/tripwire/colorline.JPG
Hvordan får jeg mit JEditorPane til at gøre det samme?
Jeg har et lille eksempel som svaret meget gerne må kodes ind i.
----------EditTest.java-------------
public class EditTest extends javax.swing.JFrame {
/** Creates new form EditTest */
public EditTest() {
initComponents();
}
/** 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.
*/
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
Label_Line = new javax.swing.JLabel();
jScrollPane1 = new javax.swing.JScrollPane();
jEditorPane1 = new javax.swing.JEditorPane();
getContentPane().setLayout(null);
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent evt) {
exitForm(evt);
}
});
jLabel1.setText("Line:");
getContentPane().add(jLabel1);
jLabel1.setBounds(10, 10, 41, 16);
Label_Line.setText("0");
getContentPane().add(Label_Line);
Label_Line.setBounds(60, 10, 80, 16);
jEditorPane1.setText("1\n2\n3\n4\n5\n6\n7\n8\n9");
jScrollPane1.setViewportView(jEditorPane1);
getContentPane().add(jScrollPane1);
jScrollPane1.setBounds(10, 30, 380, 260);
pack();
setTitle("Editorpane test");
setSize(405,335);
}
/** Exit the Application */
private void exitForm(java.awt.event.WindowEvent evt) {
System.exit(0);
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
new EditTest().show();
}
// Variables declaration - do not modify
private javax.swing.JEditorPane jEditorPane1;
private javax.swing.JLabel Label_Line;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JLabel jLabel1;
// End of variables declaration
}
---------------------
Og hvis i kan få min JLabel "Label_Line" til at skrive hvilket linienummer man er på, så ville det være super.. men det med farvningen af linien er mest vigtig.
