當前位置: 首頁>>代碼示例>>Java>>正文


Java Highlighter.Highlight方法代碼示例

本文整理匯總了Java中javax.swing.text.Highlighter.Highlight方法的典型用法代碼示例。如果您正苦於以下問題:Java Highlighter.Highlight方法的具體用法?Java Highlighter.Highlight怎麽用?Java Highlighter.Highlight使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.swing.text.Highlighter的用法示例。


在下文中一共展示了Highlighter.Highlight方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: mouseExited

import javax.swing.text.Highlighter; //導入方法依賴的package包/類
@Override
    public void mouseExited(MouseEvent e) {
        
              JTextArea area = TEdit.getTextArea();
         Highlighter hilite = area.getHighlighter();
         Highlighter.Highlight[] hilites = hilite.getHighlights();
         if(hilites != null&&hilites.length>0)
             TEdit.getSwingPool().put("area.hilites", hilites);
        /*
     if(hilites != null&&hilites.length>0){
             TEdit.setEnabled("Delete", true);
             TEdit.setEnabled("Calc",true);
         }
         else{
             TEdit.setEnabled("Delete", false);
             TEdit.setEnabled("Calc",false);
         }
*/
        //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }
 
開發者ID:mathhobbit,項目名稱:EditCalculateAndChart,代碼行數:21,代碼來源:TextAreaMouseListener.java

示例2: useSelectedTextColor

import javax.swing.text.Highlighter; //導入方法依賴的package包/類
/**
 * Determines whether the SelectedTextColor should be used for painting text
 * foreground for the specified highlight.
 *
 * Returns true only if the highlight painter for the specified highlight
 * is the swing painter (whether inner class of javax.swing.text.DefaultHighlighter
 * or com.sun.java.swing.plaf.windows.WindowsTextUI) and its background color
 * is null or equals to the selection color of the text component.
 *
 * This is a hack for fixing both bugs 4761990 and 5003294
 */
public static boolean useSelectedTextColor(Highlighter.Highlight h, JTextComponent c) {
    Highlighter.HighlightPainter painter = h.getPainter();
    String painterClass = painter.getClass().getName();
    if (painterClass.indexOf("javax.swing.text.DefaultHighlighter") != 0 &&
            painterClass.indexOf("com.sun.java.swing.plaf.windows.WindowsTextUI") != 0) {
        return false;
    }
    try {
        DefaultHighlighter.DefaultHighlightPainter defPainter =
                (DefaultHighlighter.DefaultHighlightPainter) painter;
        if (defPainter.getColor() != null &&
                !defPainter.getColor().equals(c.getSelectionColor())) {
            return false;
        }
    } catch (ClassCastException e) {
        return false;
    }
    return true;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:31,代碼來源:SwingUtilities2.java

示例3: updateHighlighter

import javax.swing.text.Highlighter; //導入方法依賴的package包/類
private void updateHighlighter() {
    Highlighter.Highlight[] highlights = highlighter.getHighlights();
    // remove old highlights
    for (int i = 0; i < highlights.length; i++) {
        highlighter.removeHighlight(highlights[i]);
    }
    String s = "";
    try {
        Document doc = inputField.getDocument();
        s = doc.getText(0, doc.getLength());
    } catch (BadLocationException e) {
    }
    if (s.length() == 0) {
        return;
    }
    highlightErrorPosition();
    int pos = inputField.getCaretPosition();
    if (pos - 1 < 0) {
        return;
    }
    if (pos - 1 >= s.length()) {
        return;
    }
    highlightBrackets(s, pos);
    highlightRNodes(s, pos);
}
 
開發者ID:danielhuson,項目名稱:dendroscope3,代碼行數:27,代碼來源:NewickInputDialog.java

示例4: actionPerformed

import javax.swing.text.Highlighter; //導入方法依賴的package包/類
@Override
public void actionPerformed(ActionEvent e) {
    
    
     JTextArea area = TEdit.getTextArea();
     Highlighter hilite = area.getHighlighter();
     Highlighter.Highlight[] hilites = hilite.getHighlights();
     int Shift=0;
     
     if(hilites != null){ 
         if(hilites.length == 0 && 
                 TEdit.getSwingPool().containsKey("area.hilites")){
             hilites = (Highlighter.Highlight[])TEdit.getSwingPool().get("area.hilites");
             TEdit.getSwingPool().remove("area.hilites");
         }
             
         for (Highlighter.Highlight hilite1 : hilites) {
               area.replaceRange("",hilite1.getStartOffset()-Shift, hilite1.getEndOffset()-Shift);
               Shift = Shift -(hilite1.getEndOffset()-hilite1.getStartOffset());
         }
        
         if(hilites.length>0){
         area.setCaretPosition(hilites[0].getStartOffset());
         area.getCaret().setVisible(true);
         }
                    TEdit.setEnabled("Calc",false);
                    TEdit.setEnabled("Delete",false);
                    TEdit.setEnabled("Save",true); 
                    TEdit.setEnabled("SaveAs",true);
     }
}
 
開發者ID:mathhobbit,項目名稱:EditCalculateAndChart,代碼行數:32,代碼來源:Delete_Action.java

示例5: mouseReleased

import javax.swing.text.Highlighter; //導入方法依賴的package包/類
@Override
public void mouseReleased(MouseEvent e) {
    JTextArea area = TEdit.getTextArea();
     Highlighter hilite = area.getHighlighter();
     Highlighter.Highlight[] hilites = hilite.getHighlights();
     if(hilites != null&&hilites.length>0){
         TEdit.setEnabled("Delete", true);
         TEdit.setEnabled("Calc",true);
     }
     else{
         TEdit.setEnabled("Delete", false);
         TEdit.setEnabled("Calc",false);
     }
    //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
 
開發者ID:mathhobbit,項目名稱:EditCalculateAndChart,代碼行數:16,代碼來源:TextAreaMouseListener.java

示例6: keyReleased

import javax.swing.text.Highlighter; //導入方法依賴的package包/類
@Override
public void keyReleased(KeyEvent e) {
     JTextArea area = TEdit.getTextArea();
     Highlighter hilite = area.getHighlighter();
     Highlighter.Highlight[] hilites = hilite.getHighlights();
     if(hilites != null&&hilites.length>0){
         TEdit.setEnabled("Delete", true);
         TEdit.setEnabled("Calc",true);
     }
     else{
         TEdit.setEnabled("Delete", false);
         TEdit.setEnabled("Calc",false);
     }
    //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
 
開發者ID:mathhobbit,項目名稱:EditCalculateAndChart,代碼行數:16,代碼來源:TextAreaKeyListener.java

示例7: paint

import javax.swing.text.Highlighter; //導入方法依賴的package包/類
@Override
public void paint(Graphics g) {
    Highlighter.Highlight[] highlights = getHighlights();

    for (int i = 0; i < highlights.length; i++) {
        Highlighter.Highlight hl = highlights[i];
        Rectangle bg = component.getBounds();
        Insets insets = component.getInsets();
        bg.x = insets.left;
        bg.y = insets.top;
        bg.height = insets.top + insets.bottom;
        Highlighter.HighlightPainter painter = hl.getPainter();
        painter.paint(g, hl.getStartOffset(), hl.getEndOffset(), bg, component);
    }
}
 
開發者ID:arodchen,項目名稱:MaxSim,代碼行數:16,代碼來源:BookmarkableLogViewer.java

示例8: removeHighlights

import javax.swing.text.Highlighter; //導入方法依賴的package包/類
/*****************************************
* removeHighlights
* remove all high lights from the pane
* @return void
*****************************************/
public void removeHighlights() {
    JTextComponent textComp = this.textPane;
    Highlighter hilite = textComp.getHighlighter();
    Highlighter.Highlight[] hilites = hilite.getHighlights();
    for (int i=0; i<hilites.length; i++) {
        if (hilites[i].getPainter() instanceof MyHighlightPainter){
            hilite.removeHighlight(hilites[i]);
        }
    }
}
 
開發者ID:fcpauldiaz,項目名稱:Compilador,代碼行數:16,代碼來源:TextPanel.java

示例9: removeHighlights

import javax.swing.text.Highlighter; //導入方法依賴的package包/類
/*****************************************
* removeHighlights
* remove all high lights from the pane
*****************************************/
public void removeHighlights() {
    JTextComponent textComp = this.textPane;
    Highlighter hilite = textComp.getHighlighter();
    Highlighter.Highlight[] hilites = hilite.getHighlights();
    for (Highlighter.Highlight hilite1 : hilites) {
        if (hilite1.getPainter() instanceof MyHighlightPainter) {
            hilite.removeHighlight(hilite1);
        }
    }
}
 
開發者ID:fcpauldiaz,項目名稱:Compilador,代碼行數:15,代碼來源:TextPanel.java

示例10: getHighlights

import javax.swing.text.Highlighter; //導入方法依賴的package包/類
/**
    * Makes a copy of the highlights.  Does not actually clone each highlight,
    * but only makes references to them.
    *
    * @return the copy
    * @see Highlighter#getHighlights
    */
   public Highlighter.Highlight[] getHighlights() {
       int size = highlights.size();
       if (size == 0) {
           return noHighlights;
       }
Highlighter.Highlight[] h = new Highlighter.Highlight[size];
highlights.copyInto(h);
return h;
   }
 
開發者ID:freeseawind,項目名稱:littleluck,代碼行數:17,代碼來源:SnippetHighlighter.java

示例11: removeHighlights

import javax.swing.text.Highlighter; //導入方法依賴的package包/類
/**
 * Removes only our private highlights
 */
@Action
public void removeHighlights() {
    Highlighter hilite = jTextAreaEntry.getHighlighter();
    Highlighter.Highlight[] hilites = hilite.getHighlights();
    for (Highlighter.Highlight hilite1 : hilites) {
        if (hilite1.getPainter() instanceof MyHighlightPainter) {
            hilite.removeHighlight(hilite1);
        }
    }
}
 
開發者ID:sjPlot,項目名稱:Zettelkasten,代碼行數:14,代碼來源:NewEntryFrame.java

示例12: removeMarkers

import javax.swing.text.Highlighter; //導入方法依賴的package包/類
/**
 * Removes only our private highlights This is public so that we can remove
 * the highlights when the editorKit is unregistered. SimpleMarker can be
 * null, in which case all instances of our Markers are removed.
 *
 * @param component the text component whose markers are to be removed
 * @param marker the SimpleMarker to remove
 */
public static void removeMarkers(JTextComponent component, Highlighter.HighlightPainter marker) {
    Highlighter hilite = component.getHighlighter();
    Highlighter.Highlight[] hilites = hilite.getHighlights();

    for (int i = 0; i < hilites.length; i++) {
        Highlighter.HighlightPainter hMarker = hilites[i].getPainter();
        if (marker == null || hMarker.equals(marker)) {
            hilite.removeHighlight(hilites[i]);
        }
    }
}
 
開發者ID:jindrapetrik,項目名稱:jpexs-decompiler,代碼行數:20,代碼來源:MyMarkers.java

示例13: removeMarkers

import javax.swing.text.Highlighter; //導入方法依賴的package包/類
/**
 * Removes only our private highlights
 * This is public so that we can remove the highlights when the editorKit
 * is unregistered.  SimpleMarker can be null, in which case all instances of
 * our Markers are removed.
 * @param component the text component whose markers are to be removed
 * @param marker the SimpleMarker to remove
 */
public static void removeMarkers(JTextComponent component, SimpleMarker marker) {
    Highlighter hilite = component.getHighlighter();
    Highlighter.Highlight[] hilites = hilite.getHighlights();

    for (int i = 0; i < hilites.length; i++) {
        if (hilites[i].getPainter() instanceof SimpleMarker) {
            SimpleMarker hMarker = (SimpleMarker) hilites[i].getPainter();
            if (marker == null || hMarker.equals(marker)) {
                hilite.removeHighlight(hilites[i]);
            }
        }
    }
}
 
開發者ID:jindrapetrik,項目名稱:jpexs-decompiler,代碼行數:22,代碼來源:Markers.java

示例14: removeHighlights

import javax.swing.text.Highlighter; //導入方法依賴的package包/類
/**
 * Remove all the Highlights from a JTextComponent
 *
 * @param component Instance of JTextComponent
 */
public void removeHighlights(JTextComponent component) {
    Highlighter hilite = component.getHighlighter();
    Highlighter.Highlight[] hilites = hilite.getHighlights();
    for (int i = 0; i < hilites.length; i++) {
        if (hilites[i].getPainter() instanceof HighlightBookmark) {
            hilite.removeHighlight(hilites[i]);
        }
    }
}
 
開發者ID:silverslade,項目名稱:jif,代碼行數:15,代碼來源:HighlightBookmark.java

示例15: removeHighlights

import javax.swing.text.Highlighter; //導入方法依賴的package包/類
/**
 * Remove all the Highlights from a JTextComponent
 *
 * @param component Instance of JTextComponent
 */
public void removeHighlights(JTextComponent component) {
    Highlighter hilite = component.getHighlighter();
    Highlighter.Highlight[] hilites = hilite.getHighlights();
    for (int i = 0; i < hilites.length; i++) {
        if (hilites[i].getPainter() instanceof HighlightText) {
            hilite.removeHighlight(hilites[i]);
        }
    }
}
 
開發者ID:silverslade,項目名稱:jif,代碼行數:15,代碼來源:HighlightText.java


注:本文中的javax.swing.text.Highlighter.Highlight方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。