List of usage examples for javax.swing JTextArea JTextArea
public JTextArea()
From source file:Main.java
public static void main(String[] argv) throws Exception { JTextComponent textComp = new JTextArea(); Document doc = textComp.getDocument(); Position p = null;/* w w w. j ava 2 s .c o m*/ int location = 3; p = doc.createPosition(location); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame(); JTextArea textarea = new JTextArea(); textarea.setDragEnabled(true);//from ww w . j a v a 2 s.c o m textarea.setText("Drag target"); frame.getContentPane().add(BorderLayout.CENTER, textarea); JTextField textarea1 = new JTextField(); textarea1.setText("Drop target"); frame.getContentPane().add(BorderLayout.SOUTH, textarea1); frame.setSize(500, 300); frame.setVisible(true); frame.setLocation(100, 100); }
From source file:MainClass.java
public static void main(final String args[]) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JTextArea leftTextArea = new JTextArea(); frame.add(leftTextArea);//w ww .j a va 2s .c om leftTextArea.paste(); frame.setSize(250, 150); frame.setVisible(true); }
From source file:Main.java
public static void main(String args[]) { JTextComponent component = new JTextArea(); // Process action list Action actions[] = component.getActions(); // Define comparator to sort actions Comparator<Action> comparator = new Comparator<Action>() { public int compare(Action a1, Action a2) { String firstName = (String) a1.getValue(Action.NAME); String secondName = (String) a2.getValue(Action.NAME); return firstName.compareTo(secondName); }//from w ww . j a v a 2 s. c om }; Arrays.sort(actions, comparator); int count = actions.length; System.out.println("Count: " + count); for (int i = 0; i < count; i++) { System.out.printf("%28s : %s\n", actions[i].getValue(Action.NAME), actions[i].getClass().getName()); } }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame("Shared Model"); JTextArea areaFiftyOne = new JTextArea(); JTextArea areaFiftyTwo = new JTextArea(); areaFiftyTwo.setDocument(areaFiftyOne.getDocument()); JTextArea areaFiftyThree = new JTextArea(); areaFiftyThree.setDocument(areaFiftyOne.getDocument()); frame.setLayout(new GridLayout(3, 1)); frame.add(new JScrollPane(areaFiftyOne)); frame.add(new JScrollPane(areaFiftyTwo)); frame.add(new JScrollPane(areaFiftyThree)); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(300, 300);/*from w ww. j ava 2s .c om*/ frame.setVisible(true); }
From source file:Main.java
public static void main(String[] argv) throws Exception { JTextArea component = new JTextArea(); NextFocusAction nextFocusAction = new NextFocusAction(); PrevFocusAction prevFocusAction = new PrevFocusAction(); component.getActionMap().put(nextFocusAction.getValue(Action.NAME), nextFocusAction); component.getActionMap().put(prevFocusAction.getValue(Action.NAME), prevFocusAction); }
From source file:Main.java
public static void main(String[] args) { JTextArea ta = new JTextArea(); ta.setLineWrap(true);// w ww . ja v a 2 s . c o m Action[] actions = ta.getActions(); JMenuBar menubar = new JMenuBar(); JMenu actionmenu = new JMenu("Actions"); menubar.add(actionmenu); JMenu firstHalf = new JMenu("1st Half"); JMenu secondHalf = new JMenu("2nd Half"); actionmenu.add(firstHalf); actionmenu.add(secondHalf); int mid = actions.length / 2; for (int i = 0; i < mid; i++) { firstHalf.add(actions[i]); } for (int i = mid; i < actions.length; i++) { secondHalf.add(actions[i]); } // Show it . . . JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.getContentPane().add(ta); f.setJMenuBar(menubar); f.setSize(300, 200); f.setVisible(true); }
From source file:Main.java
public static void main(String args[]) { JTextArea textArea = new JTextArea(); JFrame f = new JFrame(); f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); DefaultCaret caret = new DefaultCaret() { @Override//ww w. j ava 2 s. c om public boolean isSelectionVisible() { return true; } }; textArea.setCaret(caret); textArea.setFont(new java.awt.Font("Miriam Fixed", 0, 13)); Color color = Color.BLUE; // textArea.setBackground(color); textArea.setSelectedTextColor(color); f.getContentPane().add(new JScrollPane(textArea)); f.pack(); f.setVisible(true); }
From source file:Main.java
public static void main(String[] argv) throws Exception { JTextArea component = new JTextArea(); Keymap map = component.getKeymap(); while (map != null) { KeyStroke[] keys = map.getBoundKeyStrokes(); for (int i = 0; i < keys.length; i++) { System.out.println(keys[i].getKeyChar()); Action action = (Action) map.getAction(keys[i]); System.out.println(action); }/*from w w w .j a v a 2s . c om*/ Action defAction = map.getDefaultAction(); System.out.println(defAction); map = map.getResolveParent(); } }
From source file:Main.java
public static void main(String[] argv) throws Exception { JTextArea textArea = new JTextArea(); JScrollPane pane = new JScrollPane(textArea); // Listen for value changes in the scroll pane's scrollbars AdjustmentListener listener = new MyAdjustmentListener(); pane.getHorizontalScrollBar().addAdjustmentListener(listener); pane.getVerticalScrollBar().addAdjustmentListener(listener); }