Not able to highlight text. Help please?

Hi I am trying to build a tool which is going to be used to to load an html book and the make some notes on it. Now I am trying to highlight. I am in thye very beginning so I just try to highlight a small part from the begginig not the user, this is my next step. But even I think that I don't have a problem with my code as I have used as base a program that is working actually my rpogram doesn't highlight anything.
Here is the class I make the highlight
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.text.*;
import java.awt.*;
import java.awt.event.*;
import java.util.HashMap;
import javax.swing.*;
import javax.swing.text.*;
import javax.swing.event.*;
import javax.swing.undo.*;
public class ViewClass extends JFrame {
  private JFrame frame = new JFrame(); // main window
  private JPanel panel = new JPanel(new BorderLayout()); //panels to aid layout
  private JPanel panel2 = new JPanel(new GridLayout(1, 1));
  private JMenuBar menuBar=new JMenuBar();
  JMenu file = new JMenu("File");
  JMenu help = new JMenu("Help");
  JMenuItem open=new JMenuItem("Open");
  JMenuItem save=new JMenuItem("Save");
  JMenuItem exit=new JMenuItem("Exit");
  JMenuItem manual=new JMenuItem("Manual");
  JMenuItem about=new JMenuItem("About");
  JButton buttonH=new JButton();
  JButton buttonB=new JButton();
  JButton buttonT=new JButton();
  private JToolBar toolBar = new JToolBar();
  private JScrollPane scrollPane = new JScrollPane();
  private Model callingModel;
  private Controller theController;
    private static JEditorPane createEditorPane() {
    JEditorPane editorPane = new JEditorPane();
    editorPane.setEditable(false);
    java.net.URL helpURL = ViewClass.class.getResource("mexico_city.html");
    System.out.println(helpURL);
    if (helpURL != null) {
        try {
            editorPane.setPage(helpURL);
        } catch (IOException e) {
            System.err.println("Attempted to read a bad URL: " + helpURL);
    } else {
        System.err.println("Couldn't find file: mexico_city.html");
     return editorPane;
public ViewClass(Model m) {
     callingModel =m; //retrieve link to model
     theController = new Controller(callingModel); // create controller
     //set up visual features of the window
     frame.setTitle("Take a note");
     frame.setJMenuBar(menuBar);
     menuBar.add(file);
     menuBar.add(help);
     file.add(open);
     file.add(save);
     file.addSeparator();
     file.add(exit);
     help.add(manual);
     help.add(about);
     file.setMnemonic(KeyEvent.VK_F);
     help.setMnemonic(KeyEvent.VK_H);
     //frame.getContentPane().setLayout(new BorderLayout());
     toolBar.add(buttonH);
     buttonH.setIcon(new ImageIcon("H.gif"));
     buttonH.setToolTipText("Highlight");
     buttonH.setActionCommand("Highlight");
     toolBar.add(buttonB);
     buttonB.setIcon(new ImageIcon("B.gif"));
     buttonB.setToolTipText("Bookmark");
     buttonB.setActionCommand("Bookmark");
     toolBar.add(buttonT);
     buttonT.setIcon(new ImageIcon("T.gif"));
     buttonT.setToolTipText("Take a note");
     buttonT.setActionCommand("Noting");
     JEditorPane editorPane = createEditorPane();
     scrollPane = new JScrollPane(editorPane);
     MyHighlightPainter h = new MyHighlightPainter(Color.yellow);
     Highlighter hilite = editorPane.getHighlighter();
     try
          hilite.addHighlight(155, 1155,h);
     catch(BadLocationException ex)
          System.out.println(ex.getMessage());
    frame.getContentPane().add(panel);
    frame.getContentPane().add(panel2);
    panel.add(toolBar, BorderLayout.PAGE_START);
    panel.add(scrollPane, BorderLayout.CENTER);
   frame.getContentPane().add(panel, BorderLayout.CENTER);
   panel.add(new JScrollPane(editorPane) );
   exit.addActionListener(theController);
   about.addActionListener(theController);
   buttonH.addActionListener(theController);
   buttonB.addActionListener(theController);
   buttonT.addActionListener(theController);
     //ensure the following statement is always last
     frame.pack();
     frame.setSize(1274,970);
     frame.setVisible(true);//and nobody sees it until we do this
     frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   static class MyHighlightPainter extends DefaultHighlighter.DefaultHighlightPainter
public MyHighlightPainter(Color r)
super(r);
}

With interactive reports in APEX 3.1 you can use the pull down menu to highlight cells and or rows of data. You can apply many highlighting rules, that are evaluated in order. So high values can be green, low values red, and other values default. You can try this running the sample application on OTN:
http://apex.oracle.com/pls/otn/f?p=2357:2
Mike

Similar Messages

Maybe you are looking for