We need a StyledEditorKit.BackgroundAction

Dear Experts:
I'm working on a Rich Text Editor. Since there is no StyledEditorKit.BackgroundAction, I followed the example of StyledEditorKit.ForegroundAction and wrote the following class:
    private class BackgroundAction extends StyledEditorKit.StyledTextAction {
     private Color bg;
         * Creates a new BackgroundAction.
         * @param nm the action name
         * @param bg the background color
     public BackgroundAction(String nm, Color bg) {
         super(nm);
         this.bg = bg;
         * Sets the background color.
         * @param e the action event
        public void actionPerformed(ActionEvent e) {
         JEditorPane editor = getEditor(e);
         if (editor != null) {
          Color bg = this.bg;
          if ((e != null) && (e.getSource() == editor)) {
              String s = e.getActionCommand();
              try {
               bg = Color.decode(s);
              } catch (NumberFormatException nfe) {
          if (bg != null) {
              MutableAttributeSet attr = new SimpleAttributeSet();
              StyleConstants.setBackground(attr, bg);
              setCharacterAttributes(editor, attr, false);
          } else {
              UIManager.getLookAndFeel().provideErrorFeedback(editor);
    }It works fine on setting the background color of the selected text. But, when I used the JTextPane.getText() method to get the HTML code, I didn't get the correct one. It seems like that all background attributes are ignored. Does anybody know the solution?
And, if you happen to know how to set Style, say <h1>, please let me know too. Do I have to use RTFEditorKit instead of HTMLEditorKit?
Thanks a lot.

searching to solve the issues with this color calibration program for 2 weeks by now....
it does not work at all
IT WOULD BE HIGHLY APPRECIATED TO HAVE A WINDOWS 8 VERSION OF THIS PROGRAM....
is it so hard to provide this program when there are w530 laptops delivered with win 8?
and plz stop promoting win 8 upgrades if you are not able to fix the nearly countless issues with w530 in general...

Similar Messages

  • Custom line wrapping in JTextPane, StyledEditorKit

    Hello to everybody.
    I have a question. I've been stuck with this for several days now, and I couldn't find a solution on this forum or elswhere on the internet.
    I'm using a JTextPane, with a StyledEditorKit. I need to do line breaking on certain specific tokens. However, the ParagraphView which the StyledEditorKit uses only breaks on whitespaces. I've tried going into the java sources, but I can't figure out how to do it.
    Is there a simple way to change the delimiters it breaks on ? If not, is there any sample code I can use to figure out what classes/methods I need to overwrite?
    Thanks,
    Andrei

    Hello, I am having the same need of the problem posed here. I tried to use the code refered in the previous post, but (maybe my case is differente) if I am editing in the component (JTextPane) I start to have some odd behaviours, like this:
    1: After pressing Alt+Enter (my key mapping to insert a '\r') the caret remains in the same line, in order to have the caret in next line, I have to insert more characters
    2: After the first '\r', the other '\r' doesn't do the expected behavior, its as you haven't insert anything
    I'd be great if you could help me please!!!
    Thanx.

  • Using StyledEditorKit text actions

    Hi I'm trying to build a text editor using a JTextPane. I want to be able to provide a toolbar for things like font size, bold, underline, etc. Bold and Underline are no problem. There exist classes
    StyledEditorKit.BoldStyleAction
    Which I can create a JToggleButton around. This works great. But what about the FontFamilyNameAction and FontSizeAction? I'd like to put font names and sizes each in a JComboBox. Do I need to create JMenuItems and add those to the Comboboxes? Surely there's got to be a better way to do this. How do I do this?

    The simplest way is to create your own ActionListener. Fill the JComboBox with font names and when user selects font just specify your own attributes and apply them to the document.
    Like this:
    SimpleAttributeSet attrs=new SimpleAttributeSet ();
    StyleConstants.setFontFamily(attrs, fontFamilyString);
    int start=editorPane.getSelectionStart();
    int len=editorPane.getSelectionEnd()-start;
    styledDocument.setCharacterAttributes(start,len,attrs,false);
    regards,
    Stas

  • Menus, Tabs and Tree Views I need some help

    heya,
    I am quite new here! I was searching desperately on a solution on how to fix my code. I need to do a menu in Java and bellow two boxes, one in which I will display a static tree structure (on the left side of the window) and one where I have some tabs (on the irght side of the window).
    Now, today I was playing around with the tree structure view and also trying to use modules in my code for a more easy debugging and understanding later on and I managed to screw up the functionality for good :D.
    Please some help, where am I going wrong and what is missing in my application.
    Here are my 4 files:
    ______File ModulMeniu____________
    package modules;
    import javax.swing.AbstractAction;
    import javax.swing.Action;
    import javax.swing.BorderFactory;
    import javax.swing.border.Border;
    import javax.swing.JTabbedPane;
    import javax.swing.Box;
    import javax.swing.BoxLayout;
    import javax.swing.JToolBar;
    import javax.swing.JButton;
    import javax.swing.ImageIcon;
    import javax.swing.JMenuItem;
    import javax.swing.JCheckBoxMenuItem;
    import javax.swing.JMenu;
    import javax.swing.JMenuBar;
    import javax.swing.JFrame;
    import javax.swing.JTextArea;
    import javax.swing.JScrollPane;
    import javax.swing.JPanel;
    import javax.swing.JLabel;
    import javax.swing.JEditorPane;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.JSplitPane;
    import javax.swing.UIManager;
    import javax.swing.JTree;
    import javax.swing.tree.DefaultMutableTreeNode;
    import javax.swing.tree.TreeSelectionModel;
    import javax.swing.event.TreeSelectionEvent;
    import javax.swing.event.TreeSelectionListener;
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.BorderLayout;
    import java.awt.Container;
    import java.awt.Dimension;
    import java.awt.Dimension;
    import java.awt.GridLayout;
    import java.net.URL;
    import java.io.IOException;
    public class ModulMeniu extends JPanel {
    protected Action loadConfigurationAction, saveConfigurationAction, stopAction, continueAction, exitAction, newFilterAction, allFiltersSentAction;
    protected Action currentFilterAction, allComputersAction, probesAction, deleteAction, resetAction, hideComputersAction, backgroundAction;
    protected Action computerAction, filterAction, searchFilterByNameAction, searchPackageByPositionAction, deleteFilterAndRuleAction ;
    public ModulMeniu() {
    //Creates the actions shared by the toolbar and menu.
    loadConfigurationAction = new LoadConfigurationAction("Load Configuration",
    "This allows to load a previous configuration.",
    new Integer(KeyEvent.VK_L));
    saveConfigurationAction = new SaveConfigurationAction("Save Configuration",
    "This allows to save the current configuration.",
    new Integer(KeyEvent.VK_S));
    stopAction = new StopAction( "Stop",
    "This stops the Client.",
    new Integer(KeyEvent.VK_T));
    continueAction = new ContinueAction( "Continue",
    "This continues the traffic observing where we left on.",
    new Integer(KeyEvent.VK_C));
    exitAction = new ExitAction( "Exit",
    "This exits the Application.",
    new Integer(KeyEvent.VK_E));
    newFilterAction = new NewFilterAction( "New Filter",
    "This creates a new filter.",
    new Integer(KeyEvent.VK_N));
              allFiltersSentAction = new AllFiltersSentAction( "All Filters Sent",
    "This displays all the filters sent.",
    new Integer(KeyEvent.VK_A));
    currentFilterAction = new CurrentFilterAction( "Current Filter",
    "This displays the current filter.",
    new Integer(KeyEvent.VK_C));
    allComputersAction = new AllComputersAction( "All Computers",
    "This displays all the computers in the network.",
    new Integer(KeyEvent.VK_L));
    probesAction = new ProbesAction( "Probes",
    "This displays all the probes in the network.",
    new Integer(KeyEvent.VK_P));
    deleteAction = new DeleteAction( "Delete",
    "This deletes the filter.",
    new Integer(KeyEvent.VK_D));
    resetAction = new ResetAction( "Reset",
    "This resets the client.",
    new Integer(KeyEvent.VK_R));
    hideComputersAction = new HideComputersAction( "Hide Computers",
    "This hides given computers.",
    new Integer(KeyEvent.VK_H));
    backgroundAction = new BackgroundAction( "Background",
    "This sets the background color.",
    new Integer(KeyEvent.VK_B));
    computerAction = new ComputerAction( "Computer",
    "This sets the computer color.",
    new Integer(KeyEvent.VK_C));
    filterAction = new FilterAction( "Filter",
    "This sets the filter color.",
    new Integer(KeyEvent.VK_F));
    searchFilterByNameAction = new SearchFilterByNameAction( "Search Filter By Name",
    "This searches a filter by its name.",
    new Integer(KeyEvent.VK_F));
    deleteFilterAndRuleAction = new DeleteFilterAndRuleAction( "Delete Filter And Rule",
    "This deletes a filter or a rule.",
    new Integer(KeyEvent.VK_D));
    public JMenuBar createMenuBar() {
    JMenuItem menuItem = null;
    JMenuBar menuBar;
    //Create the menu bar.
    menuBar = new JMenuBar();
    //Create the first menu.
    JMenu fileMenu = new JMenu("File");
    JMenu setMenu = new JMenu("Set");
    JMenu viewMenu = new JMenu("View");
    JMenu optionsMenu = new JMenu("Options");
    JMenu colorsMenu = new JMenu("Colors");
    JMenu searchMenu = new JMenu("Search");
    JMenu deleteMenu = new JMenu("Delete");
    Action[] actions1 = {loadConfigurationAction, saveConfigurationAction, stopAction, continueAction, exitAction};
    for (int i = 0; i < actions1.length; i++) {
    menuItem = new JMenuItem(actions1);
    fileMenu.add(menuItem);
    Action[] actions2 = {newFilterAction};
    menuItem = new JMenuItem(actions2[0]);
    setMenu.add(menuItem);
    Action[] actions3 = {allFiltersSentAction, currentFilterAction, allComputersAction, probesAction};
    for (int j = 0; j < actions3.length; j++) {
    menuItem = new JMenuItem(actions3[j]);
    viewMenu.add(menuItem);
    Action[] actions4 = {deleteAction, resetAction, hideComputersAction};
    for (int i = 0; i < actions4.length; i++) {
    menuItem = new JMenuItem(actions4[i]);
    optionsMenu.add(menuItem);
    Action[] actions5 = {backgroundAction, computerAction, filterAction};
    for (int i = 0; i < actions5.length; i++) {
    menuItem = new JMenuItem(actions5[i]);
    colorsMenu.add(menuItem);
    Action[] actions6 = {searchFilterByNameAction};
    menuItem = new JMenuItem(actions6[0]);
    searchMenu.add(menuItem);
    Action[] actions7 = {deleteFilterAndRuleAction};
    menuItem = new JMenuItem(actions7[0]);
    deleteMenu.add(menuItem);
    //Set up the menu bar.
    menuBar.add(fileMenu);
    menuBar.add(setMenu);
    menuBar.add(viewMenu);
    menuBar.add(optionsMenu);
    menuBar.add(colorsMenu);
    menuBar.add(searchMenu);
    menuBar.add(deleteMenu);
    return menuBar;
    public class LoadConfigurationAction extends AbstractAction {
    public LoadConfigurationAction(String text,String desc, Integer mnemonic) {
    super(text);
    putValue(SHORT_DESCRIPTION, desc);
    putValue(MNEMONIC_KEY, mnemonic);
    public void actionPerformed(ActionEvent e) {
    public class SaveConfigurationAction extends AbstractAction {
    public SaveConfigurationAction(String text,String desc, Integer mnemonic) {
    super(text);
    putValue(SHORT_DESCRIPTION, desc);
    putValue(MNEMONIC_KEY, mnemonic);
    public void actionPerformed(ActionEvent e) {
    public class StopAction extends AbstractAction {
    public StopAction(String text,String desc, Integer mnemonic) {
    super(text);
    putValue(SHORT_DESCRIPTION, desc);
    putValue(MNEMONIC_KEY, mnemonic);
    public void actionPerformed(ActionEvent e) {
    public class ContinueAction extends AbstractAction {
    public ContinueAction(String text,String desc, Integer mnemonic) {
    super(text);
    putValue(SHORT_DESCRIPTION, desc);
    putValue(MNEMONIC_KEY, mnemonic);
    public void actionPerformed(ActionEvent e) {
    public class ExitAction extends AbstractAction {
    public ExitAction(String text,String desc, Integer mnemonic) {
    super(text);
    putValue(SHORT_DESCRIPTION, desc);
    putValue(MNEMONIC_KEY, mnemonic);
    public void actionPerformed(ActionEvent e) {
    public class NewFilterAction extends AbstractAction {
    public NewFilterAction(String text,String desc, Integer mnemonic) {
    super(text);
    putValue(SHORT_DESCRIPTION, desc);
    putValue(MNEMONIC_KEY, mnemonic);
    public void actionPerformed(ActionEvent e) {
    public class AllFiltersSentAction extends AbstractAction {
    public AllFiltersSentAction(String text,String desc, Integer mnemonic) {
    super(text);
    putValue(SHORT_DESCRIPTION, desc);
    putValue(MNEMONIC_KEY, mnemonic);
    public void actionPerformed(ActionEvent e) {
    public class CurrentFilterAction extends AbstractAction {
    public CurrentFilterAction(String text,String desc, Integer mnemonic) {
    super(text);
    putValue(SHORT_DESCRIPTION, desc);
    putValue(MNEMONIC_KEY, mnemonic);
    public void actionPerformed(ActionEvent e) {
    public class AllComputersAction extends AbstractAction {
    public AllComputersAction(String text,String desc, Integer mnemonic) {
    super(text);
    putValue(SHORT_DESCRIPTION, desc);
    putValue(MNEMONIC_KEY, mnemonic);
    public void actionPerformed(ActionEvent e) {
    public class ProbesAction extends AbstractAction {
    public ProbesAction(String text,String desc, Integer mnemonic) {
    super(text);
    putValue(SHORT_DESCRIPTION, desc);
    putValue(MNEMONIC_KEY, mnemonic);
    public void actionPerformed(ActionEvent e) {
    public class DeleteAction extends AbstractAction {
    public DeleteAction(String text,String desc, Integer mnemonic) {
    super(text);
    putValue(SHORT_DESCRIPTION, desc);
    putValue(MNEMONIC_KEY, mnemonic);
    public void actionPerformed(ActionEvent e) {
    public class ResetAction extends AbstractAction {
    public ResetAction(String text,String desc, Integer mnemonic) {
    super(text);
    putValue(SHORT_DESCRIPTION, desc);
    putValue(MNEMONIC_KEY, mnemonic);
    public void actionPerformed(ActionEvent e) {
    public class HideComputersAction extends AbstractAction {
    public HideComputersAction(String text,String desc, Integer mnemonic) {
    super(text);
    putValue(SHORT_DESCRIPTION, desc);
    putValue(MNEMONIC_KEY, mnemonic);
    public void actionPerformed(ActionEvent e) {
    public class BackgroundAction extends AbstractAction {
    public BackgroundAction(String text,String desc, Integer mnemonic) {
    super(text);
    putValue(SHORT_DESCRIPTION, desc);
    putValue(MNEMONIC_KEY, mnemonic);
    public void actionPerformed(ActionEvent e) {
    public class ComputerAction extends AbstractAction {
    public ComputerAction(String text,String desc, Integer mnemonic) {
    super(text);
    putValue(SHORT_DESCRIPTION, desc);
    putValue(MNEMONIC_KEY, mnemonic);
    public void actionPerformed(ActionEvent e) {
    public class FilterAction extends AbstractAction {
    public FilterAction(String text,String desc, Integer mnemonic) {
    super(text);
    putValue(SHORT_DESCRIPTION, desc);
    putValue(MNEMONIC_KEY, mnemonic);
    public void actionPerformed(ActionEvent e) {
    public class SearchFilterByNameAction extends AbstractAction {
    public SearchFilterByNameAction(String text,String desc, Integer mnemonic) {
    super(text);
    putValue(SHORT_DESCRIPTION, desc);
    putValue(MNEMONIC_KEY, mnemonic);
    public void actionPerformed(ActionEvent e) {
    public class DeleteFilterAndRuleAction extends AbstractAction {
    public DeleteFilterAndRuleAction(String text,String desc, Integer mnemonic) {
    super(text);
    putValue(SHORT_DESCRIPTION, desc);
    putValue(MNEMONIC_KEY, mnemonic);
    public void actionPerformed(ActionEvent e) {
    ___FIle ModulTabbedArea________
    //pls consider I have all the imports of the first file
    public class ModulTabbedArea extends JPanel{
         public JTabbedPane tabbedPane;
         public ModulTabbedArea(){
         public JTabbedPane createTabbedArea(){
    Border paneEdge = BorderFactory.createEmptyBorder(0,10,10,10);
    JPanel IP = new JPanel();
    IP.setBorder(paneEdge);
    IP.setLayout(new BoxLayout(IP,BoxLayout.Y_AXIS));
    JPanel TCP = new JPanel();
    TCP.setBorder(paneEdge);
    TCP.setLayout(new BoxLayout(TCP,BoxLayout.Y_AXIS));
    JPanel UDP = new JPanel();
    UDP.setBorder(paneEdge);
    UDP.setLayout(new BoxLayout(UDP,BoxLayout.Y_AXIS));
    JPanel ICMP = new JPanel();
    ICMP.setBorder(paneEdge);
    ICMP.setLayout(new BoxLayout(ICMP,BoxLayout.Y_AXIS));
    JPanel ARP = new JPanel();
    ARP.setBorder(paneEdge);
    ARP.setLayout(new BoxLayout(ARP,BoxLayout.Y_AXIS));
    JPanel RARP = new JPanel();
    RARP.setBorder(paneEdge);
    RARP.setLayout(new BoxLayout(RARP,BoxLayout.Y_AXIS));
    JPanel UNKNOWN = new JPanel();
    UNKNOWN.setBorder(paneEdge);
    UNKNOWN.setLayout(new BoxLayout(UNKNOWN,BoxLayout.Y_AXIS));
    JTabbedPane tabbedPane = new JTabbedPane();
    tabbedPane.addTab("IP", null, IP, null);
    tabbedPane.addTab("TCP", null, TCP, null);
    tabbedPane.addTab("UDP", null, UDP, null);
    tabbedPane.addTab("ICMP", null, ICMP, null);
    tabbedPane.addTab("ARP", null, ARP, null);
    tabbedPane.addTab("RARP", null, RARP, null);
    tabbedPane.addTab("UNKNOWN", null, UNKNOWN, null);
    return(tabbedPane);
    ___File ModulTree____
    //all the imports and the import of the package above
    public class ModulTree extends JPanel implements TreeSelectionListener {
    public JTree tree;
    private boolean DEBUG = false;
    public ModulTree() {
    //Create the nodes.
    DefaultMutableTreeNode top =new DefaultMutableTreeNode("Computers:");
    createNodes(top);
    //Create a tree that allows one selection at a time.
    tree = new JTree(top);
    tree.getSelectionModel().setSelectionMode (TreeSelectionModel.SINGLE_TREE_SELECTION);
    //Listen for when the selection changes.
    tree.addTreeSelectionListener(this);
    /** Required by TreeSelectionListener interface. */
    public void valueChanged(TreeSelectionEvent e) {
    DefaultMutableTreeNode node = (DefaultMutableTreeNode)
    tree.getLastSelectedPathComponent();
    if (node == null) return;
    Object nodeInfo = node.getUserObject();
    if (node.isLeaf()) {
    IPInfo ipAndName = (IPInfo)nodeInfo;
    if (DEBUG){           
    if (ipAndName.name==""){
         System.out.println(ipAndName.ip+ ": \n ");
    else {
    System.out.print(ipAndName.ip + ipAndName.name + ": \n ");
    if (DEBUG) {
    System.out.println(nodeInfo.toString());
    private class IPInfo {
    public String ip;
    public String name;
    public IPInfo(String adresaIP, String numeleComputerului) {
    ip=adresaIP;
    name=numeleComputerului;
    public String toString() {
    return ip + name;
    private void createNodes(DefaultMutableTreeNode top) {
    DefaultMutableTreeNode category = null;
    DefaultMutableTreeNode ipAndName = null;
    category = new DefaultMutableTreeNode("Computers in the Network");
    top.add(category);
    ipAndName = new DefaultMutableTreeNode(new IPInfo
    ("216.27.61.137",
    "Artemis"));
    category.add(ipAndName);
    ipAndName = new DefaultMutableTreeNode(new IPInfo
    ("216.32.61.132",
    "Venus"));
    category.add(ipAndName);
    ipAndName = new DefaultMutableTreeNode(new IPInfo
    ("216.132.61.11",
    "Zeus"));
    category.add(ipAndName);
    category = new DefaultMutableTreeNode("Probes in the Network");
    top.add(category);
    ipAndName = new DefaultMutableTreeNode(new IPInfo
    ("10.11.11.1",
    "Probe1"));
    category.add(ipAndName);
    ipAndName = new DefaultMutableTreeNode(new IPInfo
    ("10.11.1.1",
    "Probe2"));
    category.add(ipAndName);
    __File ModulMain___
    //all the imports and imports also modules.*
    public class ModulMain extends JFrame{
         public ModulMain(){
    private static void createAndShowGUI() {
    //Create and set up the window.
    JFrame frame = new JFrame("Sistem grafic de monitorizare a unei retele");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    //Create/set menu bar and content pane.
    ModulMeniu menu = new ModulMeniu();
    frame.setJMenuBar(menu.createMenuBar());
    //Create the scroll pane and add the tree to it.
    JScrollPane treeView = new JScrollPane(tree);
    JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    splitPane.setLeftComponent(treeView);
    splitPane.setRightComponent(tabbedPane);
    Dimension minimumSize = new Dimension(100, 50);
    tabbedPane.setMinimumSize(minimumSize);
    treeView.setMinimumSize(minimumSize);
    splitPane.setDividerLocation(100); //XXX: ignored in some releases
    //of Swing. bug 4101306
    //workaround for bug 4101306:
    //treeView.setPreferredSize(new Dimension(100, 100));
    splitPane.setPreferredSize(new Dimension(500, 300));
    //Add the split pane to this panel.
    add(splitPane);
    menu.setOpaque(true); //content panes must be opaque
    frame.setContentPane(menu);
    //Display the window.
    frame.pack();
    frame.setVisible(true);
    public static void main(String[] args) {
    javax.swing.SwingUtilities.invokeLater(new Runnable() {
    public void run() {
    createAndShowGUI();
    This is it guys! The code is not hard, just long and I need to deliver this project and I just dunno what to do to it to make it work :(. I appreciate any help I can get :p.
    THANK YOU for your time!
    Cristina

    hey friend,
    i don't have solution to your problem but i am facing the same problem in my project, i need to fetch filenames from folder and show it in a tree view. if you have any solution then please refer me with code..!1
    thanx in advance..

  • Overriding default Copy behaviour of StyledEditorKit

    hi,
    just executing the default behaviour of "copy" (i.e. the Action associated with the string DefaultEditorKit.copyAction), inherited from DefaultEditorKit, turns Styled text into plain text.
    So I need to override the behaviour of this action in StyledEditorKit... I find the way into this must be use of the nested class of DefaultEditorKit, i.e. class DefaultEditorKit.CopyAction.
    But can someone provide a code example on how to do the override... ? Have tried extending a CopyAction class in a StyledEditorKit constructor... etc.
    Thanks
    Mike

    By the way I don't read code that has been posted
    without the "Code Formatting Tags, found in the
    "Formatting Tips" link.great, much better:
    System.out.println();
    Action doNothing = new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            //do nothing
    ActionMap actionMap = getActionMap();
    for( InputMap inputMap = getInputMap(); inputMap != null; inputMap = inputMap.getParent() ){
        System.out.println( "input/action maps level..." );
        KeyStroke ctrlC = KeyStroke.getKeyStroke( KeyEvent.VK_C, Event.CTRL_MASK );
        String nm = (String)inputMap.get( ctrlC );
        if( nm != null ){
            System.out.println( "inputMap entry found for Ctrl-C: " + nm );
            inputMap.put( ctrlC, "doNothing");
            if( actionMap != null )
                actionMap.put( "doNothing", doNothing);
            nm = (String)inputMap.get( ctrlC );
            System.out.println( "now: inputMap entry " + nm + " present" );
            if( actionMap != null )
                actionMap = actionMap.getParent();
            if( actionMap == null && inputMap.getParent() != null )
                    System.out.println( "hmm... actionMap parent null and inputMap parent non-null!!" );
    Well, you should not be trying to get rid of the
    deault Action.
    You are adding your own custom Action, so you just
    need to create you Acton and add the Action to the
    ActionMap with the correct KeyStroke. that's what I do in the above code... despite replacing the "copy-to-clipboard" with doNothing in all 3 generations of ActionMap, the Action for "copy-to-clipboard" still appears to be present... and to de-style text automatically

  • Reg StyledEditorKit.CutAction()....

    I have a JTextPane where text formatting is done .There is need for CUT COPY & PASTE,and I obtain it from
    StyledEditorKit.CutAction(),
    StyledEditorKit.CopyAction()
    StyledEditorKit.PasteAction()
    The result is not to expectation and formating are lost when I do cut/copy and paste .
    There is so many Docs and examples for Plain Text CUT/COPY/PASTE , but I havent find anything for Styles...
    Any one have come across this?

    ...a rather cheap, rough, lazy and inefficient means of simple styled cut/copy/paste within the same JVM where a firm and informed grasp of element mechanics is lacking and a solid implementation of standard transfer APIs is subverted...
    This is not recommended. For true transfer capability, HTML and RTF flavors, along with adequate translation algorithms to those formats, should be supported via the standard transfer APIs.
    Assume: valid args, standard attributed paragraph parents with standard attributed character children, mono-thread access
    public class DerivedD extends BaseB implements InterfaceI {
    /*List of:
    Parent->Paragraph element segment{start, end, span, text, attr},
    Child->Character element segment{start, end, span, null, attr}, ...
    private static ArrayList elemSegList;
    /* Phony element storage item. */
    //               ElemSeg
         private static final class ElemSeg {
              private static final int PARA = 1;
              private static final int CHAR = 2;
              private int
                   type,
                   start,
                   end,
                   span;
              private String text;
              private AttributeSet attr;
              private ElemSeg() {  }
    /* selStart:selection Start selEnd:selection End*/
         // copy(DefaultStyledDocument, int, int)
         public static void copy(
    DefaultStyledDocument doc, int selStart, int _selEnd) {
         elemSegList = new ArrayList();
         for (int i=_selStart; i<_selEnd;) {
              Element para = _doc.getParagraphElement(i);
              ElemSeg paraSeg = new ElemSeg();
              paraSeg.type = ElemSeg.PARA;
              int paraStart = para.getStartOffset();
              int paraEnd = Math.min(para.getEndOffset(), _selEnd);
              paraSeg.span = paraEnd-paraStart;
              paraSeg.attr = para.getAttributes();
              paraSeg.start = paraStart - _selStart;
              paraSeg.end = paraEnd - _selStart;
              try {
              paraSeg.text =
    _doc.getText(paraStart, paraSeg.span);
              } catch (BadLocationException _ble) {
              System.out.println(_ble.getMessage());     
              return;
              elemSegList.add(paraSeg);
              for (int j=paraStart; j<paraEnd;) {
              Element char = doc.getCharacterElement(j);
              ElemSeg charSeg = new ElemSeg();
              charSeg.type = ElemSeg.CHAR;
              int charStart=j;
              int charEnd =
    Math.min(paraEnd, _char.getEndOffset());
              charSeg.span = charEnd - charStart;
              charSeg.attr = _char.getAttributes();
              charSeg.start = charStart-_selStart;
              charSeg.end = charEnd-_selStart;
              elemSegList.add(charSeg);
              j=charEnd;
         i=paraEnd;
    //               paste(DefaultStyledDocument, int)
         public static void paste(
    DefaultStyledDocument doc, int selS) {
         int listSize = elemSegList.size();
         for (int i=0; i<listSize; i++) {
              ElemSeg elemSeg = (ElemSeg) elemSegList.get(i);
              if (elemSeg.type == ElemSeg.PARA) {
              try {
              _doc.insertString(
                   elemSeg.start + _selS, elemSeg.text, null);
              } catch (BadLocationException _ble) {
              System.out.println(_ble.getMessage());
              return;
              _doc.setParagraphAttributes(
              elemSeg.start +
    _selS, elemSeg.span, elemSeg.attr, true);
              } else if (elemSeg.type == ElemSeg.CHAR) {
                   _doc.setCharacterAttributes(
                   elemSeg.start +
                   _selS, elemSeg.span, elemSeg.attr, false);
    } // end: DerivedD
    Although the example above could be further expanded for different subclasses of documents, the author, in no way, recommends any commercial implementation of it.

  • Apple Mini DVI to Video Adapter - do you need cables as well?????????????

    Apple Mini DVI to Video Adapter
    i have this already,but do i need a certain cable to go into the TV. as it only has one port instead of the usual 3 av leads have???
    help please,confused...............

    Look in your question and you'll find the answer...
    Apple mini DVI to Video Adapter
    ...the usual 3 av (audio/video) leads...
    DVI is video only so you only need one port... if you were hooking up audio and video you'd need three (1 for video - 2 for the left/right audio channels)

  • I need to upgrade my external hard drive, any suggestions

    I have an iMac i5 quad core (2010 model), I have been using a Seagate Barracuda 250 GB 7200 RPM from an older iMac 20" G5 in an OWC Mercury Elite Pro Firewire 400/USB 2.0/1.1 enclosure as my backup external HD.  The enclosure has the Oxford 911 chipset and says that it supports up to 750GB.
    Since I have been using Snow Leopard only I have used time machine to backup to this HD.  Now, that I have installed Lion, and partitioned my HD on my computer to have both Lion and Snow Leopard OS, I need to get a larger external HD to install in my OWC enclosure to save money.
    I was looking on the OWC website and found a SeaGate 2.0TB Barracuda Green SATA 6Gb/s 64MB, 5900 RPM for $90.00, or the 7200 RPM for $158.00.
    I am not sure if my enclosure with the Oxford 911 chipset will support this drive, and also the specs for my enclosure says up to 750GB, and that probably rules out these drives anyway.
    I could just keep what I have and use it as a back up of my Lion partition currently using 134 GB.  Snow Leopard using 127 GB on my internal 1TB hard drive.  Then, I could purchase the OWC Mercury Elite Pro 2.0 TB Firewire 400/USB 2.0/1.1 with the Oxford 934 chipset, 5900 RPM, and 64 MB for $150.00. Even thought this would be a little slower, is it worth paying $40.00 more for the 7200 RPM speed?
    On my hard drive now I am only using 261 GB, so after I first back up both partitions on the 2.0 TB external HD, any other backups would not take as long to do.  I have Super Duper, but right now it is not recognizing my Lion HD, and I have not backed up Lion to my current external HD yet since I want to get a larger external HD.  When I get the new HD, I can partition it so that I can backup either Lion partition or SL partition using time machine, it that right?  My current external HD is bootable, but I am confused about Carbon Copy or Super Duper, will that be saved on my external HD?
    Thanks,
    DaisyMay

    DaisyMay wrote:
    Firewire 400/USB 2.0/1.1
    I would recommend not settling for less then USB 3 or hold out for Thunderbolt, if your machine is capable. Firewire 800 minimum.
    MacBook Pro, Mac OS X (10.7), 2.4GHz IntelCore i5 320 HD 8GB RAM ParallelsDesktop6.0

  • How large of a hard drive can I install on dual G5, and do I need more RAM?

    I recently had a situation in which my dual-processor 2.0 G5 was completely refurbished by Apple repair-new logic board, both processors, video card, thermistor, all new. Finally it has been working well after a month of trips back and forth from the Apple store. I have two internal hard drives installed on my G5, both 300GB, one for OS applications, and one for audio. I am running out of space on my main hard drive, and so I recently purchased a Maxtor 1TB hard drive, now manufactured by Seagate, from Fry's. After having my G5 refurbished, I was having an issue with my Samsung 930B monitor going into sleep mode when I boot-up from a CD, but other than that G5 was working fine. I removed the main 300GB hard drive from slot #1 and put it into slot #2, from which I had removed my audio hard drive. I installed the Maxtor drive in slot #1 and reformatted it for Mac using my laptop with ATA/USB cables previously purchased for data transfer. This took about 14 hours as I used the "zeros" option. After that I hooked up the internal cables to both drives and tried to boot up from Leopard in order to install it on the Maxtor drive, but again my monitor went into to sleep mode. We went to the Apple store to try to see if there was an issue with the computer, but everything worked fine with their monitors and CD's, as well as my CD. So there is some kind of issue with my monitor, probably software as it works fine when booting up from the main hard drive, and also was fine when I did its self-test function. While at the Apple store, they installed Leopard from their hard drive which took about 30 minutes.
    My problem is this: When I arrived home, I turned on my G5, which had been set to boot from my new Maxtor drive and complete the Leopard setup process, which we had decided to do at home as it would have taken another 20 minutes in the Apple store. The G5 turned on, chimed, I got the Apple screen with the wheel, but then after that my monitor goes into sleep mode. I can hear Leopard's setup intro playing through the speakers, but the screen is in sleep mode. So I reboot holding down the option key so I can boot up from my old (300GB) main hard drive, now in slot #2. This works and the monitor screen does not go to sleep. However, as I am browsing on the web to check for issues concerning this monitor, the G5 freezes, and I get a screen with black bars with writing in them and various technical language across the screen. This happened several times after rebooting. Finally I shut the computer down. I am going to try removing the new hard drive and putting both old ones back in and see if the G5 stops crashing. I think the monitor issue is a separate issue, and I am more concerned with the crashing, as previous to the new hard drive installation the G5 was working fine, monitor fine, other than the issue when booting up from a CD. Do I need more memory? Is the 1TB hard drive too large for my dual-processor 2.0 G5 and overloading it? Would I be better off with a 500GB drive? Would appreciate advice from persons with experience in this area. Thank you.

    I have replaced my 5 year old G5 with a Mac Pro, as the G5 just had too many issues, even after replacing all major components (logic board, both processors, video card, etc.) Once I took out the 1 TB hard drive from my old G5, it stopped having the kernel panic issue. Nonetheless I had been through a lengthy repair process previous to this issue, so I didn't care to trust an older machine any longer, especially since being told by an Apple tech that the "new" parts were really just older parts stockpiled from a central location. Could be new, could be refurbished. Apple was kind enough to credit the money we had spent on the G5 repairs towards the purchase of my Mac Pro.

  • Stuck: Need Disk repair but DVD drive dead and only have USB 1

    [1 Ghz flat-panel iMac with USB 1 ports (no USB 2) and also Firewire 400]
    I noticed a strange discrepancy (small but concerning) between the size of a folder on hard drive (folder of all mp3's with no subfolders) and the backup of the same folder on a mounted thumb drive.
    (The size difference was not due to any invisible .DS_Store files and both folders are displayed in List view format.)
    Disk Utility reports three things:
    1. Incorrect number of thread records
    2. Volume Bit Map needs minor repair
    3. Checking volume information.
              Volume free block count",0)   [I might have mangled this line]
    (It should be 13438611 instead of 13437937)
    Here is the GOOD (but these are useless as explained under the "Bad"):
    - I have a Tiger 10.4 boot DVD for a repair ==>but see below
    - I also have a Disk Warrior disk (never used)
    Here is the BAD:
    - My built-in optical drive [Pioneer DVD-RW DVR-105] is -- I now discover - defunct and DEAD - it does not run the Tiger Boot DVD (in pristine shape).
    - I bought an external SuperDrive (unopened) but I believe no boot from USB 1 is possible in PowerPC so a SuperDrive with USB 1 is useless.
    Questions:
    1.) Is there any way to boot from some external source (optical drive is DEAD) to run Disk Utility and/or Disk Warrior? -- I see none in this case! (gulp).
    2.) More importantly (and this is my fundamental concern): Do the three Disk Utility hard drive issues constitute any direct threat to the integrity of my files?
    I have almost everything backed up to duplicate thumb drives over these many months as standard practice.
    Are these Disk Utility errors fully isolated to hard drive directory-keeping...or do these directory damage errors pose the possibility of mangling or harming my files or their metadata (filesize, etc.).
    Put another way, when files are backed-up from a hard drive under the Disk Utility reports above, do they remain unharmed and undamaged by the situations reported by Disk Utility?
    Thanks,
    Bill

    Jeff and Michael,
    Thank you both for your generous and thoughtful input.
    Michael: As I slept on it overnight, the exact same idea occurred to me of trying a Target Mode to the iMac from my Lion MacbookPro (I have it but stupidly have yet to use it much!).
    I did buy a Firewire 800 (MBP) to Firewire 400 (iMac) adapter cable a few months ago!
    CONCERN: Would there be potential compatibility issues or risks in running Lion 10.7's Disk Utility against the hard drive of the old OSX 10.4 iMac in Target Disk Mode?
    ==> Assuming an "it's ok" answer to the Target Disk question, would the majority of users agree that the Target Disk Mode would be more prudent than running:
    fsck -fy   in Single User Mode
    I have never done fsck -fy before especially because I was under the impression there were issues with Journaled drived but from what I have read today...it looks ok to do)
    Jeff: Can't thank you enough for the reference to the OTW DVD drive. I might first invest $10 in one of those DVD lens cleaner disks that I've read about. It's probably not the issue or else why would the drive read commercial Music cds perfectly well!
    Thanks,
    Bilil

  • Dear experts help needed in creation of report in hr

    Please check the below code.
    There is one Transaction code PA20 from these i need the fields in my report.
    I tried writing the report but the fields are from structure so please help in creating the report.
    I am a beginner so i donno how to find the below fields are coming from which table.
    when i do F1 on the fields in PA20 i found the fields but they are from structure.
    type-POOLS: SLIS.
    TYPES : BEGIN OF TY_P0001,
            PERNR TYPE PERNR_D,      "Personnel Number
            BEGDA TYPE BEGDA,        "Start Date
            BUKRS TYPE BUKRS,        "Company Code
            ENAME TYPE EMNAM,        "Formatted Name of Employee or Applicant
            END OF TY_P0001.
    TYPES : BEGIN OF TY_P0016,
            PERNR TYPE PERNR_D,      "Personnel Number
            PRBZT TYPE PRBZT,        "Probationary Period
            CTTYP TYPE CTTYP,        "Contract Type
            END OF TY_P0016.
    TYPES: BEGIN OF TY_P9210,
             PERNR TYPE PERNR_D,
            ZTICKET_AMT TYPE ZTICKET_AMT,  "Ticket Amount
            END OF TY_P9210.
    TYPES : BEGIN OF TY_OUTPUT,
             PERNR TYPE PERNR_D,      "Personnel Number
             BEGDA TYPE BEGDA,        "Start Date
             BUKRS TYPE BUKRS,        "Company Code
             ENAME TYPE EMNAM,        "Formatted Name of Employee or Applicant
             PRBZT TYPE PRBZT,        "Probationary Period
             CTTYP TYPE CTTYP,        "Contract Type
             ZTICKET_AMT TYPE ZTICKET_AMT,  "Ticket Amount
            END OF TY_OUTPUT.
    DATA:  T_P0001 TYPE TY_P0001 OCCURS 1,
           W_P0001 TYPE TY_P0001,
           T_P0016 TYPE TY_P0016 OCCURS 1,
           W_P0016 TYPE TY_P0016,
           T_P9210 TYPE TY_P9210 OCCURS 1,
           W_P9210 TYPE TY_P9210,
           T_OUTPUT TYPE TY_OUTPUT OCCURS 1,
           W_OUTPUT TYPE TY_OUTPUT.
        START-OF-SELECTION.
            SELECT PERNR
                   BEGDA
                   BUKRS
                   ENAME FROM P0001 INTO TABLE T_P0001
                   WHERE
                    AND  BUKRS IN S_BUKRS
                    AND  BEGDA < '31032007'.
              SELECT PERNR
                     PRBZT
                     CTTYP
                     FROM P0016 INTO TABLE T_P0016
                     FOR ALL ENTRIES IN T_P0001
                     WHERE PERNR = T_P0001-PERNR
              SELECT PERNR
                     ZTICKET_AMT
                     FROM P920 INTO TABLE T_P920
                     FOR ALL ENTRIES IN T_P920
                     WHERE PERNR = T_P0001-PERNR.

    use logical data base PNP.
    tables: pernr.
    infotypes: 0001, 0016, ....
    start-of-selection.
    get pernr.
    here all tables Pxxxx defined as INFOTYPES are filled for the selected PERNR.

  • Need to a voltage converter to run US-bought 110v HP Printers in 220v Pakistan any recommendations?

    I Purchased Three Printers 
    1. 
    HP LaserJet Enterprise 500 MFP M525dn(CF116A)
    2.
    HP Color LaserJet Enterprise CP4025n Printer(CC489A)
    3.
    HP LaserJet P2055d Printer (CE457A) -
     All of them three operates on 110v USA.  but i need them to use in 220V . Can anyone recommend me any good Voltage converter ?
    This question was solved.
    View Solution.

    Hi,
    Before go out to buy a converter/transformer  (you need over 2KW for all 3 of them), please check the switches at the back, they may have switches to switch from 110V to 220V. I don't know your market, my suggestion: talk with an electrician who knows the real world much better.
    Regards.
    BH
    **Click the KUDOS thumb up on the left to say 'Thanks'**
    Make it easier for other people to find solutions by marking a Reply 'Accept as Solution' if it solves your problem.

  • Step-by-Step Help Needed for Deploying Some Adobe Software

    We are a K-12 educational institution.  I am currently working at setting up a computer lab with about 16 MacMini computers.
    I'm VERY new to the realm of servers, deployment, using terminal, etc.
    I've done lots of research to make it to where I am, but just can't wrap my head around what needs done next with the Adobe products.
    I am using Server OSX (v3) and DeployStudio (v 1.6.3) to try and manage the computers.
    Both my server and clients are running Mavericks 10.9.
    I deployed my core images successfully and would like to now send Adobe products only the computers I choose since I have limited licenses.
    We have volume licenses of Adobe InDesign CS6 and Photoshop Elements 12 that we would like to deploy.
    I have been referencing the following sites, but just can't seem to wrap my head around the EXACT steps that need to be taken.
    http://blogs.adobe.com/oobe/2010/10/adobe-provisioning-toolkit-enterprise-edition.html
    http://helpx.adobe.com/creative-cloud/packager/provisioning-toolkit-enterprise.html
    http://helpx.adobe.com/photoshop-elements/kb/silent-install-instructions-photoshop-element s2.html
    http://forums.adobe.com/message/5781663
    For Adobe InDesign CS6 - I've done the following:
    Created an "Installation Package" using Adobe Application Manager Enterprise Edition (AAMEE v6.2.112.0) using the following instructions.
    http://wwwimages.adobe.com/www.adobe.com/content/dam/Adobe/en/devnet/creativesuite/pdfs/Ad obeApplicationManagerEnterpriseEditionDeploymentGuide_v_3_1.pdf
    If I log into the client computer, put the package ON the client computer, and run it...it takes me through the install and works wonderfully.It's not automated like I wanted/thought I set it up to do. I have to click through the steps of the installer.
    If I try to deploy it using the "Package install" Workflow in DeployStudio...it loads it during the workflow, then skips through it, acts like it installed it, but it isn't actually installed.Is there a setting that I need to possibly change somewhere?
    For Adobe Photoshop Elements 12 - I'm a bit lost and mostly just have questions:
    I know that I can't use AAMEE and need to use APTEE (Adobe Provisioning Toolkit Enterprise Edition).
    How do I deploy the software? Create my own Package using PackageMaker?
    Which computer do I run APTEE on? All the instructions I can find just say, "do this" - but don't specify where.
    Do I have to open terminal and run the commands on each client computer AFTER installing PE12?
    OR
    Do I run the commands BEFORE deployment on my package stored on my server that is ready for deployment?
    It really comes down to me just not 100% understanding how APTEE works.
    I hope that pertrays my dilemma. I've tried to explain best I can.  If you have any questions - let me know!
    Thanks in advance for any insight you can give!

    We are a K-12 educational institution.  I am currently working at setting up a computer lab with about 16 MacMini computers.
    I'm VERY new to the realm of servers, deployment, using terminal, etc.
    I've done lots of research to make it to where I am, but just can't wrap my head around what needs done next with the Adobe products.
    I am using Server OSX (v3) and DeployStudio (v 1.6.3) to try and manage the computers.
    Both my server and clients are running Mavericks 10.9.
    I deployed my core images successfully and would like to now send Adobe products only the computers I choose since I have limited licenses.
    We have volume licenses of Adobe InDesign CS6 and Photoshop Elements 12 that we would like to deploy.
    I have been referencing the following sites, but just can't seem to wrap my head around the EXACT steps that need to be taken.
    http://blogs.adobe.com/oobe/2010/10/adobe-provisioning-toolkit-enterprise-edition.html
    http://helpx.adobe.com/creative-cloud/packager/provisioning-toolkit-enterprise.html
    http://helpx.adobe.com/photoshop-elements/kb/silent-install-instructions-photoshop-element s2.html
    http://forums.adobe.com/message/5781663
    For Adobe InDesign CS6 - I've done the following:
    Created an "Installation Package" using Adobe Application Manager Enterprise Edition (AAMEE v6.2.112.0) using the following instructions.
    http://wwwimages.adobe.com/www.adobe.com/content/dam/Adobe/en/devnet/creativesuite/pdfs/Ad obeApplicationManagerEnterpriseEditionDeploymentGuide_v_3_1.pdf
    If I log into the client computer, put the package ON the client computer, and run it...it takes me through the install and works wonderfully.It's not automated like I wanted/thought I set it up to do. I have to click through the steps of the installer.
    If I try to deploy it using the "Package install" Workflow in DeployStudio...it loads it during the workflow, then skips through it, acts like it installed it, but it isn't actually installed.Is there a setting that I need to possibly change somewhere?
    For Adobe Photoshop Elements 12 - I'm a bit lost and mostly just have questions:
    I know that I can't use AAMEE and need to use APTEE (Adobe Provisioning Toolkit Enterprise Edition).
    How do I deploy the software? Create my own Package using PackageMaker?
    Which computer do I run APTEE on? All the instructions I can find just say, "do this" - but don't specify where.
    Do I have to open terminal and run the commands on each client computer AFTER installing PE12?
    OR
    Do I run the commands BEFORE deployment on my package stored on my server that is ready for deployment?
    It really comes down to me just not 100% understanding how APTEE works.
    I hope that pertrays my dilemma. I've tried to explain best I can.  If you have any questions - let me know!
    Thanks in advance for any insight you can give!

  • Help Needed: Returning Back to Windows 8 after downgrading to Windows 7

    Hi guys, im just new here.
    I have a MSI GE40 gaming laptop which I bought 2 months back.
    Within those 2 months of usage, I always encounter my laptop to be very slow in shutting down. It always take, maybe up to 10 minutes to fully shut down. The screen goes black but the power button stays on orange color, & as I said, it takes a long time  for the power button to be completely unlit. But for start up, its blazing fast.
    Thinking that windows 8 itself is the culprit of super slow shutting down, I searched the net on how to downgrade to windows 7.
    Of course I did make a back up first on a 16gb usb flash drive using the pre-installed recovery software from MSI which was completed successfully.
    Then I made some tweaks on the bios (ie select legacy & disable secure boot) & boot using windows 7 installation DVD, deleted all partitions (since the notebook comes with GPT partition) to be able to install windows 7. I installed all the drivers which I downloaded from MSI website specific to my notebook.
    But the problem is not solved, it is still very slow in shutting down, & now even boot up becomes very slow too.
    So I downloaded & execute the firmware & bios for windows 7 from msi website (again, specific to my model). But still the same, the notebook is still very slow both in shutting down & start up.
    So I decided to go back again to windows 8, I tried to boot from the flash drive (I adjusted from the bios & make the flash drive to be the first priority) but it did not boot from it. I tried F11 on start up & selected to boot from usb flash drive but again, to no avail.
    So the last one I did was downloaded windows 8, make a bootable flash drive out of it, boot from it and luckily, I succeed - I have now again a windows 8 msi ge40 laptop.
    But I wanted my laptop to be reinstated to factory setting, i.e, all preinstalled softwares are there, the bios is default for windows 8. So I tried to update the bios to the one for windows 8 again (since I downgraded the bios to the one for windows 7 when I downgraded the OS to windows 7). But I could not update the bios, the laptop is not booting from usb flash drive containing the bios.
    I tried also to recover using F3 on start up but the system does not recognize the flash drive (with system back up). I tried also on PC settings but to no avail.
    Now guys, I need your help.
    How can I return back my laptop to default factory settings?
    Thank you.
    (sorry for my not so good English)

    Hello:
    I think it's not only about the OS version, you need to return this back to your shop to repair with the slow shot down issue, because the OS should be shot down in 30 seconds, far from your GE40 times.

  • Need Help to Draw and Drag Triangle - URGENT

    Hi everyone - I am developing various proofs of the pythagora's theorem
    and the following code draws a triangle on screen and the proof follows -
    but i need to know how to drag the triangle such tht 1 angle is always set to 90 degrees.
    i.e. i need to resize the triangle by dragging its vertex points by which the1 angle remains at 90 no matter what the size.
    The proof has got some graphics code hardcoded in it - i.e. LINES AND POLYGONS have been hardcoded
    i need to reconfigure that such that everytime the user increases the size of the triagnle and clicks on next it draws the lines and polygons in the correct area and place
    PLEASE HELP
    the code is as follows
    MAIN CLASS
    import java.awt.BorderLayout;
    import java.awt.Container;
    import java.awt.*;
    import java.awt.event.*;
    import java.text.*;
    import javax.swing.*;
    public class TestProof {
        TestControl control;          // the controls for the visual proof
        TestView view;          // the drawing area to display proof
        // called upon class creation
        public TestProof() {
            view = new TestView();
    view.setBackground(Color.WHITE);
            control = new TestControl(view);
            Frame f = new Frame("Pythagoras");
            f.add(view,"Center");
            f.add(control,"South");
            f.setSize(600,600);
            f.setBackground(Color.lightGray);
            f.addMouseMotionListener(
            new MouseMotionListener() { //anonymous inner class
                //handle mouse drag event
                public void mouseMoved(MouseEvent e) {
                    System.out.println("Mouse  " + e.getX() +","  + e.getY());
                public void mouseDragged(MouseEvent e) {
                    System.out.println("Draggg: x=" + e.getX() + "; y=" + e.getY());
            JMenu File = new JMenu("File");
            JMenuItem Exit = new JMenuItem("Exit");
            Exit.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    ExitActionPerformed(evt);
            JMenuBar menuBar = new JMenuBar();
            menuBar.add(File);
       File.add(Exit);
            f.add(menuBar,"North");
            f.show();
        private JMenuBar getMenuBar() {
            JMenu File = new JMenu("File");
            JMenuItem Exit = new JMenuItem("Exit");
            Exit.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    ExitActionPerformed(evt);
            JMenuBar menuBar = new JMenuBar();
            menuBar.add(File);
                 File.add(Exit);   
            return menuBar;
        private void ExitActionPerformed(java.awt.event.ActionEvent evt) {
            // TODO add your handling code here:
            System.exit(0);
        // for standalone use
        public static void main(String args[]) {
      TestProof TP = new TestProof();
    }Test VIEW
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import java.text.*;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    public class TestView extends Canvas {
        int TRANSLUCENT = 1;
        int sequence;          // sequencer that determines what should be drawn
        // notes matter
        int noteX = 100;     // note coordinates
        int noteY = 60;
        int fontSize = 11;     // font size
        int lineSpacing     // space between two consecutive lines
        = fontSize + 2;
        Font noteFaceFont;     // font used to display notes
        // objects matter
        Polygon tri;          // right-angled triangle with sides A, B, and C
        Polygon tri1;
        Polygon sqrA;          // square with side of length A
        Polygon sqrB;          // square with side of length B
        Polygon sqrC;          // square with side of length C
        Polygon parA;          // parallelogram of base A and height A
        Polygon parB;          // parallelogram of base B and height B
        Polygon poly1;
        Polygon poly2;
        Polygon poly3;
        Polygon poly4;
        Polygon poly5;
        Polygon poly6;
        int X0 = 350;          // coordinates of triangle
        int Y0 = 350;
        int A = 90;//60;          // triangle size
        int B = 120;//80;
        int C = 150;//100;
        //CORDS of 2nd triangle
        int X1 = 350;
        int Y1 = 500;
        // notes: three lines per note
        String notes[] = {
            // note 0
            // note 1
            // note 2
            // note 3
            // note 4
            // note 5
            // note 6
            // note 7
            // note 8
            // note 9
            // note 10
            // note 11
            // note 12
            // note 13
            // note 14
        // constructor
        public TestView() {
            addMouseMotionListener(
            new MouseMotionListener() { //anonymous inner class
                //handle mouse drag event
                public void mouseMoved(MouseEvent e) {
                    System.out.println("Mouse  " + e.getX() +","  + e.getY());
                public void mouseDragged(MouseEvent e) {
                    System.out.println("Draggg: x=" + e.getX() + "; y=" + e.getY());
            // set font
            noteFaceFont = new Font("TimesRoman", Font.PLAIN, fontSize);
            // (coordinates specified w.r.t. to P0, unless otherwise specified)
            // create the triangle
            tri = new Polygon();
            tri.addPoint(0, 0);                    // add P0 coordinate
            tri.addPoint(A*A/C, -A*B/C);          // add A3 coordinate
            tri.addPoint(C, 0);                    // add C1 coordinate
            tri.translate(X0, Y0);               // place triangle
            tri1 = new Polygon();
            tri1.addPoint(0,0);                    // add P0 coordinate
            tri1.addPoint(A*A/C +38, +A*B/C);          // add A3 coordinate
            tri1.addPoint(C, 0);                    // add C1 coordinate
            tri1.translate(X1, Y1);
            // create square of side A
            sqrA = new Polygon();
            sqrA.addPoint(0, 0);               // add P0 coordinate
            sqrA.addPoint(-A*B/C, -A*A/C);          // add A1 coordinate
            sqrA.addPoint(-A*(B-A)/C, -A*(A+B)/C);     // add A2 coordinate
            sqrA.addPoint(A*A/C, -A*B/C);          // add A3 coordinate
            sqrA.translate(X0, Y0);               // place square
            // create square of side B
            // warning: the coordinate of this object are specified relative to C1
            sqrB = new Polygon();
            sqrB.addPoint(0, 0);               // add C1 coordinate
            sqrB.addPoint(B*A/C, -B*B/C);          // add B1 coordinate
            sqrB.addPoint(B*(A-B)/C, -B*(A+B)/C);     // add B2 coordinate
            sqrB.addPoint(-B*B/C, -B*A/C);          // add A3 coordinate
            sqrB.translate(X0 + C, Y0);               // place square
            // create square of side C
            sqrC = new Polygon();
            sqrC.addPoint(0, 0);               // add P0 coordinate
            sqrC.addPoint(C, 0);               // add C1 coordinate
            sqrC.addPoint(C, C);               // add C2 coordinate
            sqrC.addPoint(0, C);               // add C3 coordinate
            sqrC.translate(X0, Y0);               // place square
            poly1 = new Polygon();
            poly1.addPoint(405,279);
            poly1.addPoint(413,350);
            poly1.addPoint(432,500);
            poly1.addPoint(442,571);
            poly1.addPoint(500,500);
            poly1.addPoint(500,350);
            poly2 = new Polygon();
            poly2.addPoint(279,297);
            poly2.addPoint(404,280);
            poly2.addPoint(571,254);
            poly2.addPoint(500,350);
            poly2.addPoint(350,350);
            //Polygon 3
            poly3 = new Polygon();
            poly3.addPoint(404,280);
            poly3.addPoint(350,350);
            poly3.addPoint(414,350);
            poly4 = new Polygon();
            poly4.addPoint(350,350);
            poly4.addPoint(350,500);
            poly4.addPoint(442,572);
            poly4.addPoint(433,500);
            poly4.addPoint(414,350);
            poly5 = new Polygon();
            poly5.addPoint(476,183);
            poly5.addPoint(332,225);
            poly5.addPoint(278,295);
            poly5.addPoint(404,279);
            poly5.addPoint(571,254);
            poly6= new Polygon();
            poly6.addPoint(405,278);
            poly6.addPoint(332,224);
            poly6.addPoint(476,182);
            // create parallelogram of height A
            parA = new Polygon();
            parA.addPoint(0, 0);               // add P0 coordinate
            parA.addPoint(0, C);               // add C3 coordinate
            parA.addPoint(A*A/C, C - A*B/C);          // add Q0 coordinate
            parA.addPoint(A*A/C, -A*B/C);          // add A3 coordinate
            parA.translate(X0,Y0);               // place parallelogram
            // create parallelogram of height B
            // warning: the coordinate of this object are specified from C1
            parB = new Polygon();
            parB.addPoint(0, 0);               // add C1 coordinate
            parB.addPoint(-B*B/C, -B*A/C);          // add A3 coordinate
            parB.addPoint(A*A/C - C, C - A*B/C);     // add Q0 coordinate
            parB.addPoint(0, C);               // add C2 coordinate
            parB.translate(X0 + C, Y0);
            // place parallelogram
        // depending on the sequence number we draw certain objects
        public void paint(Graphics gfx) {
            super.paint(gfx);
            Graphics2D g = (Graphics2D) gfx;
            g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
            RenderingHints.VALUE_ANTIALIAS_ON);
            // text first, then objects (and animation)
            // we always output some notes
            g.drawString(notes[3*sequence], noteX, noteY);
            g.drawString(notes[3*sequence + 1], noteX, noteY + lineSpacing);
            g.drawString(notes[3*sequence + 2], noteX, noteY + 2*lineSpacing);
            // the object are drawn in an order so that they are properly overlapped
            if(sequence == 13) {
                g.setColor(Color.green);
                g.fillPolygon(poly1);
                g.fillPolygon(poly2);
                g.fillPolygon(poly3);
                g.fillPolygon(poly4);
                g.fillPolygon(poly5);
                g.setColor(Color.RED);
                g.setColor(Color.GREEN);
                g.drawLine(413,351,433,499);
                g.setColor(Color.white);
                g.fillPolygon(tri);
                g.fillPolygon(tri1);
                g.fillPolygon(poly6);
            if(sequence == 12 ) {
                g.setColor(Color.green);
                g.fillPolygon(poly1);
                g.fillPolygon(poly2);
                g.fillPolygon(poly3);
                g.fillPolygon(poly4);
                g.fillPolygon(poly5);
                g.setColor(Color.BLACK);
            if(sequence == 11){
                g.setColor(Color.green);
                g.fillPolygon(poly1);
                g.fillPolygon(poly3);
                g.fillPolygon(poly4);
                g.setColor(Color.BLACK);
            if(sequence == 8 ){
                g.setColor(Color.green);
                g.fillPolygon(poly5);
                g.setColor(Color.MAGENTA);
                g.drawString("E",578,254);
                g.drawString("D",268,302);
                g.setColor(Color.black);
                g.drawArc(250,150,350,250,320,65);
            else if (sequence == 9 ){
                g.setColor(Color.green);
                g.fillPolygon(poly2);
                g.setColor(Color.MAGENTA);
                g.drawString("E",578,254);
                g.drawString("D",268,302);
                g.setColor(Color.black);
                g.drawArc(250,150,350,250,320,65);
            if( sequence == 10){
                g.setColor(Color.green);
                g.fillPolygon(poly2);
                g.fillPolygon(poly5);
                g.setColor(Color.black);
                g.setColor(Color.MAGENTA);
                g.drawString("E",578,254);
                g.drawString("D",268,302);
                g.setColor(Color.black);
                g.drawArc(250,150,350,250,320,65);
            if(sequence == 7){
                g.setColor(Color.green);
                g.fillPolygon(poly2);
                g.setColor(Color.MAGENTA);
                g.drawString("E",578,254);
                g.drawString("D",268,302);
                g.setColor(Color.black);
            if(sequence == 6){
                g.setColor(Color.yellow);
                g.fillPolygon(poly2);
                g.setColor(Color.green);
                g.fillPolygon(poly3);
                g.setColor(Color.blue);
                g.fillPolygon(poly4);
                g.setColor(Color.black);
                g.drawArc(250,175,350,275,300,65);
                //g.drawArc(250,150,350,250,320,65);
                g.drawLine( 606,309,599,299);
                g.drawLine(592,313, 599,299);
                g.drawString("+90 degrees",605,378);
            if (sequence == 5 ) {
                g.setColor(Color.yellow);
                g.fillPolygon(poly2);
                g.setColor(Color.black);
            if (sequence == 4) {
                g.setColor(Color.YELLOW);
                g.fillPolygon(poly1);
                g.setColor(Color.black);
                g.drawArc(319,310,250,195,89,-35);
                g.drawLine(499,319, 492,312);
                g.drawLine(499,319, 492,325);
                g.drawArc(200,180, 233,238,-120,-60);
                g.drawLine(200,298, 208,309);
                g.drawLine(200,298, 194,313);
                g.drawString("-90 degrees",227,347);
            if (sequence >= 3) {
                g.drawLine(404,279,442,572);
            // draw the squares
            if (sequence >= 2) {
                g.drawLine(278,296,572,254);
            // draw the squares
            if (sequence >= 1) {
                g.drawLine(333,224,476,182);
                g.drawPolygon(tri1);
            // always draw the triangle
            g.drawPolygon(tri);
            g.drawPolygon(sqrA);
            g.drawPolygon(sqrB);
            g.drawPolygon(sqrC);
            g.setColor(Color.MAGENTA);
            g.drawString("C", X0 + C/2 - fontSize/2, Y0 + lineSpacing);
            g.drawString("A",
            X0 + A*A/(2*C) - fontSize*A/B/2,
            Y0 - A*B/(2*C) - lineSpacing*A/B);
            g.drawString("B",
            X0 + C - B*B/(2*C) - fontSize*A/B/2,// the last "-" isn't log.
            Y0 - B*A/(2*C) - lineSpacing*A/B);
        public void redraw(int sequence) {
            this.sequence = sequence;
            repaint();
    }TEST CONTROL
    * TestControl.java
    * Created on 28 February 2005, 11:16
    import java.awt.*;
    import java.awt.event.*;
    import java.text.*;
    import javax.swing.JFrame;
    * @author  Kripa Bhojwani
    public class TestControl extends Panel implements ActionListener {
      TestView view;
      int sequence;                    // event sequence
      // constructor
      public TestControl(TestView view) {
        Button b = null;
        Label label = new Label("A^2 ");
        this.view = view;          // initialize drawble area
        sequence = 0;               // initialize sequence
        b = new Button("Prev");
        b.addActionListener(this);
        add(b);
        b = new Button("Next");
        b.addActionListener(this);
        add(b);
        add(label);
      // exported method
      public void actionPerformed(ActionEvent ev) {
        String label = ev.getActionCommand();
        if (label.equals("Prev")) {
          if (sequence >0) {
         --sequence;
        else {
          if (sequence < 15) {
         ++sequence;
        this.setEnabled(false);          // disable the controls
        view.redraw(sequence);
        this.setEnabled(true);          // enable the controls
    }Please help --- really need to sort this out...
    THANKS

    One of the problems you face is that it is hard to recognise which parts of your code are drawing the triangle. This is because you are writing code in a procedural way rather than an object oriented way.
    In object oriented code you would have a triangle object that could draw itself. You would create the triangle object by specifying its sizes and angles in some way. Then it should be easy to change the triangles sizes and angles and ask all the drawn objects to redraw themselves.

Maybe you are looking for

  • Alright, what am I missing? Print Report

    Troubleshooting a printer problem today, I had occasion to open the front panel of "Print Report.vi" (report generation toolkit).  There's nothing there!  Both the "error" and "no error" cases just pass the report ref through without operating on it,

  • How to move large number of internal table data to excel by program

    Hi, Iam working on a classical report wherein my requirement is: Have around 25 internal tables which I am displaying using a selection screen.I need to transfer this all internal tables data to Excel file by executing. Now, let me know how can I tra

  • Can I use multiline SQL commands in a query (within a component)?

    I would like to modify the following query: <td>ItranslationString</td>      <td>      INSERT INTO TRANSLATIONSTRINGS (daKey, daLanguage, daTranslation, daStringFlag, daSourceFile) VALUES (?, ?, ?, 'N', ?)      </td>      <td>daKeyField varchar      

  • Pictures Don't Show Up

    I just installed the trial of LR3 and I'm already having problems. When I try to "import" photos, my pictures don't show up. All that shows up in the preview thumbnails are grey boxes where my pictures should be. LR acts like it is loading my picture

  • Group video call on LG 55LA6200 with LG AN-VC500

    Hi, Trying to set up group video to include LG smart TV. Following instructions found here: https://support.skype.com/en/faq/FA10801/making-a-group-video-call-mac Initiate the call by starting a new converstion on a laptop, using Premium account.  Ad