Page 2 of 2 FirstFirst 12
Results 21 to 27 of 27
  1. #21
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,570
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by tom99 View Post
    Where do i add that ? if i put it on display page i get a error on displaying sites, and it dont allow me to put it under the main method.
    In your constructor, just under the line:

    Java Code:
     // Set up page display.
    You don't need to create another object of that class in your main method.

    kind regards,

    Jos

  2. #22
    tom99 is offline Member
    Join Date
    Oct 2010
    Posts
    18
    Rep Power
    0

    Default

    I dont get it, i did that but still... nothing happens.

  3. #23
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,570
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by tom99 View Post
    I dont get it, i did that but still... nothing happens.
    I changed your following method a bit and it sort of works now:

    Java Code:
                public void keyReleased(KeyEvent e) {
                	dumpInfo("Skrev", e);  
                    if (e.getKeyCode() == KeyEvent.VK_ENTER) {
                        actionGo();
                        
                        if(locationTextField.getText().equals("http://zoomout")){
                        	System.out.println("Du skrev zoomout");
                        	zoom = zoom-0.125;
                        	repaint();
                       
                        }
                        if(locationTextField.getText().equals("http://zoomin")){
                        	System.out.println("Du skrev zoomin");
                        	zoom = zoom+0.125;
                        	repaint();
                        }
                    }
                }

  4. #24
    tom99 is offline Member
    Join Date
    Oct 2010
    Posts
    18
    Rep Power
    0

    Default

    It still dont zoom, when i put System.out.println(zoom); under it, it shows that it is increasing but displayEditorPane stay the same.

  5. #25
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,570
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by tom99 View Post
    It still dont zoom, when i put System.out.println(zoom); under it, it shows that it is increasing but displayEditorPane stay the same.
    Did you use my version of your method? (see my previous reply). It repaints the pane after it changed the zoom factor. It works (more or less, there are some other things to do).

    kind regards,

    Jos

  6. #26
    tom99 is offline Member
    Join Date
    Oct 2010
    Posts
    18
    Rep Power
    0

    Default

    yes i used your version with repaint its still no difference.

    Woud it be the same method to zoom in on Textfield you use on Editorpane ?



    http://java-sl.com/src/Scale_JEditorPane_src.html Here is something witch do what im after, but i dont manage to tweak it for what i need, but there you atleast get an idea of what im after.
    Also i was not thinking of using combobox but shortcut or a command.
    Last edited by tom99; 10-06-2010 at 07:26 PM.

  7. #27
    solostaran is offline Member
    Join Date
    Jul 2011
    Location
    Caen
    Posts
    1
    Rep Power
    0

    Thumbs up JEditorPane + HTML + Zoom

    Quote Originally Posted by tom99 View Post
    http://java-sl.com/src/Scale_JEditorPane_src.html Here is something witch do what im after, but i dont manage to tweak it for what i need, but there you atleast get an idea of what im after.
    Also i was not thinking of using combobox but shortcut or a command.
    I was after the same example and got an illumination
    The only thing I had to change is the EditorKit class :

    Java Code:
    class ScaledEditorKit extends HTMLEditorKit {
      public ViewFactory getViewFactory() {
          return new StyledViewFactory();
      }
    
      class StyledViewFactory extends HTMLFactory {
    
          public View create(Element elem) {
              String kind = elem.getName();
              if (kind != null) {
            	  // body is the main element on which you must apply the zoom factor
            	  if (kind.equals("body")) { // HTML.Tag.BODY
            		  return new ScaledView(elem, View.Y_AXIS);
            	  }
              }
              
              // default to HTMLFactory
              return super.create(elem);
          }
    
      }
    }
    No change to the ScaledView class, and the declaration is the same in my EditorPane.
    Last edited by solostaran; 07-06-2011 at 08:24 PM.

Page 2 of 2 FirstFirst 12

Similar Threads

  1. How to simulate browser CTRL+F function
    By crisfromnova in forum SWT / JFace
    Replies: 1
    Last Post: 09-14-2010, 02:41 PM
  2. Replies: 13
    Last Post: 08-30-2010, 07:55 PM
  3. How to Zoom in and Zoom out TYPE_USHORT_565_RGB image
    By Santhoshkumarp in forum AWT / Swing
    Replies: 0
    Last Post: 08-07-2010, 02:39 PM
  4. Java Zoom in and Zoom out?
    By ps20090 in forum Java Applets
    Replies: 2
    Last Post: 09-18-2009, 12:04 PM
  5. No class made
    By ChuckLS in forum New To Java
    Replies: 1
    Last Post: 04-28-2009, 04:54 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •