// Path: src/main/java/com/jvms/i18neditor/swing/text/JTextComponentMenuListener.java
// public class JTextComponentMenuListener extends MouseAdapter {
// 	private final JTextComponent parent;
// 	private final JTextComponentMenu menu;
// 	
// 	public JTextComponentMenuListener(JTextComponent parent, UndoManager undoManager) {
// 		super();
// 		this.parent = parent;
// 		this.menu = new JTextComponentMenu(parent, undoManager);
// 	}
// 	
// 	@Override
// 	public void mouseReleased(MouseEvent e) {
// 		showPopupMenu(e);
//     }
// 	
// 	@Override
// 	public void mousePressed(MouseEvent e) {
// 		showPopupMenu(e);
//     }
// 	
// 	private void showPopupMenu(MouseEvent e) {
// 		if (!e.isPopupTrigger() || !parent.isEditable()) {
// 			return;
// 		}
// 		parent.requestFocusInWindow();
// 		menu.show(parent, e.getX(), e.getY());
// 	}
// }
// 
// Path: src/main/java/com/jvms/i18neditor/util/Colors.java
// public final class Colors {
// 
// 	/**
// 	 * Multiplies the RGB values of a color with the given factor.
// 	 * 
// 	 * @param 	c the original color
// 	 * @param 	factor the factor to scale with
// 	 * @return 	the scaled color
// 	 */
// 	public static Color scale(Color c, float factor) {
// 		return new Color(
// 				roundColorValue(c.getRed()*factor), 
// 				roundColorValue(c.getGreen()*factor), 
// 				roundColorValue(c.getBlue()*factor),
// 				c.getAlpha());
// 	}
// 	
// 	/**
// 	 * Gets the hex representation of the RGB values of the given color.
// 	 * 
// 	 * @param 	color the color to get the hex value from
// 	 * @return	the hex representation of the color
// 	 */
// 	public static String hexValue(Color color) {
// 		return String.format("#%02x%02x%02x", color.getRed(), color.getGreen(), color.getBlue());
// 	}
// 	
// 	private static int roundColorValue(float value) {
// 		return Math.round(Math.max(0, Math.min(255, value)));
// 	}
// }


import java.awt.Toolkit;
import java.awt.event.KeyEvent;
import javax.swing.BorderFactory;
import javax.swing.KeyStroke;
import javax.swing.UIManager;
import javax.swing.border.Border;
import javax.swing.undo.UndoManager;
import com.jvms.i18neditor.swing.text.JTextComponentMenuListener;
import com.jvms.i18neditor.util.Colors;
package com.jvms.i18neditor.swing;




/**
 * This class extends a default {@link javax.swing.JTextField} with a {@link UndoManager},
 * a right click menu and a custom look and feel.
 * 
 * @author Jacob van Mourik
 */
public class JTextField extends javax.swing.JTextField {
	private final static long serialVersionUID = 5296894112638304738L;
	protected final UndoManager undoManager = new UndoManager();
	
	/**
	 * Constructs a {@link JTextField}.
	 */
	public JTextField() {
		this(null);
	}
	
	@Override
	public void setEnabled(boolean enabled) {
		super.setEnabled(enabled);
		setOpaque(enabled);
	}
	
	/**
	 * Constructs a {@link JTextField} with an initial text.
	 */
	public JTextField(String text) {
		super(text, 25);
		
		Border border = BorderFactory.createLineBorder(Colors.scale(UIManager.getColor("Panel.background"), .8f));
		setBorder(BorderFactory.createCompoundBorder(border, BorderFactory.createEmptyBorder(5,8,5,8)));
// Path: src/main/java/com/jvms/i18neditor/swing/text/JTextComponentMenuListener.java
// public class JTextComponentMenuListener extends MouseAdapter {
// 	private final JTextComponent parent;
// 	private final JTextComponentMenu menu;
// 	
// 	public JTextComponentMenuListener(JTextComponent parent, UndoManager undoManager) {
// 		super();
// 		this.parent = parent;
// 		this.menu = new JTextComponentMenu(parent, undoManager);
// 	}
// 	
// 	@Override
// 	public void mouseReleased(MouseEvent e) {
// 		showPopupMenu(e);
//     }
// 	
// 	@Override
// 	public void mousePressed(MouseEvent e) {
// 		showPopupMenu(e);
//     }
// 	
// 	private void showPopupMenu(MouseEvent e) {
// 		if (!e.isPopupTrigger() || !parent.isEditable()) {
// 			return;
// 		}
// 		parent.requestFocusInWindow();
// 		menu.show(parent, e.getX(), e.getY());
// 	}
// }
// 
// Path: src/main/java/com/jvms/i18neditor/util/Colors.java
// public final class Colors {
// 
// 	/**
// 	 * Multiplies the RGB values of a color with the given factor.
// 	 * 
// 	 * @param 	c the original color
// 	 * @param 	factor the factor to scale with
// 	 * @return 	the scaled color
// 	 */
// 	public static Color scale(Color c, float factor) {
// 		return new Color(
// 				roundColorValue(c.getRed()*factor), 
// 				roundColorValue(c.getGreen()*factor), 
// 				roundColorValue(c.getBlue()*factor),
// 				c.getAlpha());
// 	}
// 	
// 	/**
// 	 * Gets the hex representation of the RGB values of the given color.
// 	 * 
// 	 * @param 	color the color to get the hex value from
// 	 * @return	the hex representation of the color
// 	 */
// 	public static String hexValue(Color color) {
// 		return String.format("#%02x%02x%02x", color.getRed(), color.getGreen(), color.getBlue());
// 	}
// 	
// 	private static int roundColorValue(float value) {
// 		return Math.round(Math.max(0, Math.min(255, value)));
// 	}
// }


// Path: src/main/java/com/jvms/i18neditor/swing/JTextField.java
import java.awt.Toolkit;
import java.awt.event.KeyEvent;
import javax.swing.BorderFactory;
import javax.swing.KeyStroke;
import javax.swing.UIManager;
import javax.swing.border.Border;
import javax.swing.undo.UndoManager;
import com.jvms.i18neditor.swing.text.JTextComponentMenuListener;
import com.jvms.i18neditor.util.Colors;

package com.jvms.i18neditor.swing;




/**
 * This class extends a default {@link javax.swing.JTextField} with a {@link UndoManager},
 * a right click menu and a custom look and feel.
 * 
 * @author Jacob van Mourik
 */
public class JTextField extends javax.swing.JTextField {
	private final static long serialVersionUID = 5296894112638304738L;
	protected final UndoManager undoManager = new UndoManager();
	
	/**
	 * Constructs a {@link JTextField}.
	 */
	public JTextField() {
		this(null);
	}
	
	@Override
	public void setEnabled(boolean enabled) {
		super.setEnabled(enabled);
		setOpaque(enabled);
	}
	
	/**
	 * Constructs a {@link JTextField} with an initial text.
	 */
	public JTextField(String text) {
		super(text, 25);
		
		Border border = BorderFactory.createLineBorder(Colors.scale(UIManager.getColor("Panel.background"), .8f));
		setBorder(BorderFactory.createCompoundBorder(border, BorderFactory.createEmptyBorder(5,8,5,8)));
		getDocument().addUndoableEditListener(e -> undoManager.addEdit(e.getEdit()));