Java Code Examples for javax.swing.JTextArea

The following are top voted examples for showing how to use javax.swing.JTextArea. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: myster   File: MessageWindow.java   View source code 7 votes vote down vote up
public MessageTextArea(boolean editable, String text, String labelText) {
    setLayout(new BorderLayout());

    area = new JTextArea("");
    area.setSize(400, 400);
    area.setWrapStyleWord(true);
    area.setAutoscrolls(true);
    area.setLineWrap(true);
    area.setEditable(editable);
    area.setText(text);

    JScrollPane scrollPane = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPane.getViewport().add(area);
    scrollPane.setDoubleBuffered(true);
    add(scrollPane, "Center");

    JLabel message = new JLabel(labelText);
    add(message, "North");
}
 
Example 2
Project: incubator-netbeans   File: ActionMappingsTest.java   View source code 7 votes vote down vote up
@Test
public void testSkipTestsAction() throws Exception {
    JTextArea area = new JTextArea();
    area.setText("");
    ActionMappings.SkipTestsAction act = new ActionMappings.SkipTestsAction(area);
    act.actionPerformed(new ActionEvent(area, ActionEvent.ACTION_PERFORMED, "X"));
    assertTrue(area.getText().contains(TestChecker.PROP_SKIP_TEST + "=true"));

    area.setText(TestChecker.PROP_SKIP_TEST + "=false");
    act.actionPerformed(new ActionEvent(area, ActionEvent.ACTION_PERFORMED, "X"));
    assertTrue(area.getText().contains(TestChecker.PROP_SKIP_TEST + "=true"));

    area.setText(TestChecker.PROP_SKIP_TEST + " = false\nyyy=xxx");
    act.actionPerformed(new ActionEvent(area, ActionEvent.ACTION_PERFORMED, "X"));
    assertTrue(area.getText().contains(TestChecker.PROP_SKIP_TEST + "=true"));

    area.setText("aaa=bbb\n" + TestChecker.PROP_SKIP_TEST + " =    false   \nyyy=xxx");
    act.actionPerformed(new ActionEvent(area, ActionEvent.ACTION_PERFORMED, "X"));
    assertTrue(area.getText().contains(TestChecker.PROP_SKIP_TEST + "=true"));
}
 
Example 3
Project: incubator-netbeans   File: ErrorPanel.java   View source code 6 votes vote down vote up
private void btnStackActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnStackActionPerformed
    StringWriter sw = new StringWriter();
    exception.printStackTrace(new PrintWriter(sw));
    JPanel pnl = new JPanel();
    pnl.setLayout(new BorderLayout());
    pnl.setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6));
    JTextArea ta = new JTextArea();
    ta.setText(sw.toString());
    ta.setEditable(false);
    JScrollPane pane = new JScrollPane(ta);
    pnl.add(pane);
    pnl.setMaximumSize(new Dimension(600, 300));
    pnl.setPreferredSize(new Dimension(600, 300));
    NotifyDescriptor.Message nd = new NotifyDescriptor.Message(pnl);
    DialogDisplayer.getDefault().notify(nd);

}
 
Example 4
Project: openjdk-jdk10   File: JobAttrUpdateTest.java   View source code 6 votes vote down vote up
private static void doTest(Runnable action) {
    String description
            = " A print dialog will be shown.\n "
            + " Please select Pages within Page-range.\n"
            + " and enter From 2 and To 3. Then Select OK.";

    final JDialog dialog = new JDialog();
    dialog.setTitle("JobAttribute Updation Test");
    JTextArea textArea = new JTextArea(description);
    textArea.setEditable(false);
    final JButton testButton = new JButton("Start Test");

    testButton.addActionListener((e) -> {
        testButton.setEnabled(false);
        action.run();
    });
    JPanel mainPanel = new JPanel(new BorderLayout());
    mainPanel.add(textArea, BorderLayout.CENTER);
    JPanel buttonPanel = new JPanel(new FlowLayout());
    buttonPanel.add(testButton);
    mainPanel.add(buttonPanel, BorderLayout.SOUTH);
    dialog.add(mainPanel);
    dialog.pack();
    dialog.setVisible(true);
}
 
Example 5
Project: EditCalculateAndChart   File: HelpFrame.java   View source code 6 votes vote down vote up
public void createAndShow() throws Exception{
    Preferences Config = TEdit.getConfig();
    JTextArea area = new JTextArea(10,40);
    area.setEditable(false);
              String Font_Name =  Config.get("FONT_NAME","Monospaced");
              int Font_Size = Config.getInt("FONT_SIZE",12);
              int Font_Style = Config.getInt("FONT_STYLE",Font.PLAIN);
              area.setFont(new Font(Font_Name,Font_Style,Font_Size));
              	JScrollPane scroll = new JScrollPane(area,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
		this.add(scroll,BorderLayout.CENTER);
                if(txt == null){
                    BufferedReader br = new BufferedReader(new InputStreamReader(getClass().getResourceAsStream("org/ioblako/edit/resources/Help.txt"), "UTF-8"));
                     for (int c = br.read(); c != -1; c = br.read()) sb.append((char)c);
                     txt=sb.toString();
                }
                
                area.setText(txt);
                this.setTitle("Help");
                this.pack();
                this.setVisible(true);
               
}
 
Example 6
Project: school-game   File: LogReaderPanel.java   View source code 6 votes vote down vote up
/**
 * Konstruktor.
 *
 * Zeigt einen schreibgeschützten Editor an.
 *
 * @param logFileName der Name der Log Datei
 */
public LogReaderPanel(String logFileName)
{
    super(new BorderLayout());

    String logPath = PathHelper.getBasePath();
    logFile = new File(logPath + logFileName);

    textArea = new JTextArea("Keine Logs geladen!");
    textArea.setEditable(false);

    JScrollPane scrollPane = new JScrollPane(textArea, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    add(scrollPane, BorderLayout.CENTER);

    reloadButton = new JButton("Laden");
    reloadButton.addActionListener(this);

    add(reloadButton, BorderLayout.SOUTH);
}
 
Example 7
Project: EditCalculateAndChart   File: FindRight_Action.java   View source code 6 votes vote down vote up
@Override
public void actionPerformed(ActionEvent e) {
     JTextArea area = TEdit.getTextArea();
     String txt = area.getText();
     if(txt == null)
         return;
     String s = TEdit.getLookingFor();
     if(s.contentEquals(""))
         return;
     if(txt.contentEquals("") || txt.length()<1)
         return;
      if(area.getCaretPosition() >=txt.length()-1){
          area.setCaretPosition(0);
          //JOptionPane.showMessageDialog(TEdit.getFrame(),"Reached the end of the text");
          //return;
      }
           int foundAt = txt.indexOf(s,area.getCaretPosition()+s.length());
           if(foundAt == -1){
               JOptionPane.showMessageDialog(TEdit.getFrame(),"Reached the end of the text");
               return;
           }
               area.setCaretPosition(foundAt);
               area.select(foundAt,foundAt+s.length());
}
 
Example 8
Project: incubator-netbeans   File: EditorFindSupportTest.java   View source code 6 votes vote down vote up
/**
 * Test of replaceAll method, of class EditorFindSupport.
 */
@Test
public void testReplaceAll10() throws Exception {
    final Map<String, Object> props = new HashMap<>();
    props.put(EditorFindSupport.FIND_WHAT, "a");
    props.put(EditorFindSupport.FIND_REPLACE_WITH, "b");
    props.put(EditorFindSupport.FIND_HIGHLIGHT_SEARCH, Boolean.TRUE);
    props.put(EditorFindSupport.FIND_INC_SEARCH, Boolean.TRUE);
    props.put(EditorFindSupport.FIND_BACKWARD_SEARCH, Boolean.FALSE);
    props.put(EditorFindSupport.FIND_WRAP_SEARCH, Boolean.FALSE);
    props.put(EditorFindSupport.FIND_MATCH_CASE, Boolean.FALSE);
    props.put(EditorFindSupport.FIND_SMART_CASE, Boolean.FALSE);
    props.put(EditorFindSupport.FIND_WHOLE_WORDS, Boolean.FALSE);
    props.put(EditorFindSupport.FIND_REG_EXP, Boolean.FALSE);
    props.put(EditorFindSupport.FIND_HISTORY, new Integer(30));

    final EditorFindSupport instance = EditorFindSupport.getInstance();
    JTextArea ta = new JTextArea("aa");
    ta.setCaretPosition(1);
    instance.replaceAllImpl(props, ta);
    assertEquals("ab", ta.getText());
}
 
Example 9
Project: openjdk-jdk10   File: bug6442918a.java   View source code 6 votes vote down vote up
private static void runTest() {
    JDialog dialog = Util
                .createModalDialogWithPassFailButtons("Empty header showing \"...\"");
    String[] columnNames = {"", "", "", "", "Testing"};
    String[][] data = {{"1", "2", "3", "4", "5"}};
    JTable table = new JTable(data, columnNames);
    DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
    int tableCellWidth = renderer.getFontMetrics(renderer.getFont())
            .stringWidth("test");
    table.setPreferredScrollableViewportSize(new Dimension(
            5 * tableCellWidth, 50));
    JPanel p = new JPanel();
    p.add(new JScrollPane(table));
    dialog.add(p, BorderLayout.NORTH);
    JTextArea area = new JTextArea();
    String txt  = "\nInstructions:\n\n";
           txt += "Only the last column header should show \"...\".";
    area.setText(txt);
    dialog.add(new JScrollPane(area), BorderLayout.CENTER);
    dialog.pack();
    dialog.setVisible(true);
}
 
Example 10
Project: jdk8u-jdk   File: MissingDragExitEventTest.java   View source code 6 votes vote down vote up
private static void initAndShowUI() {
    frame = new JFrame("Test frame");

    frame.setSize(SIZE, SIZE);
    frame.setLocationRelativeTo(null);
    final JTextArea jta = new JTextArea();
    jta.setBackground(Color.RED);
    frame.add(jta);
    jta.setText("1234567890");
    jta.setFont(jta.getFont().deriveFont(150f));
    jta.setDragEnabled(true);
    jta.selectAll();
    jta.setDropTarget(new DropTarget(jta, DnDConstants.ACTION_COPY,
                                     new TestdropTargetListener()));
    jta.addMouseListener(new TestMouseAdapter());
    frame.setVisible(true);
}
 
Example 11
Project: JuggleMasterPro   File: DevelopmentJMenuItem.java   View source code 6 votes vote down vote up
/**
 * Constructs
 * 
 * @param objPcontrolJFrame
 */
public DevelopmentJMenuItem(ControlJFrame objPcontrolJFrame) {

	this.objGcontrolJFrame = objPcontrolJFrame;
	this.objGdevelopmentJTextArea = new JTextArea(25, 80);
	this.objGdevelopmentJTextArea.setFont(new Font("Courier", Font.PLAIN, 11));
	this.objGdevelopmentJTextArea.setOpaque(true);
	this.objGdevelopmentJTextArea.setEditable(false);
	this.objGcloseExtendedJButton = new ExtendedJButton(objPcontrolJFrame, this);

	// Build dialog :
	this.objGdevelopmentJDialog = this.getDevelopmentDialog(objPcontrolJFrame, this.objGdevelopmentJTextArea, this.objGcloseExtendedJButton);
	this.setOpaque(true);
	this.addActionListener(this);
	this.setAccelerator(Constants.keyS_DEVELOPMENT);
}
 
Example 12
Project: Install_Builder_Universal   File: GNULicenseWindow.java   View source code 6 votes vote down vote up
private void initialize() {
	txtArea = new JTextArea();
	txtArea.setFont(new Font(Font.SANS_SERIF, 0, 12));
	txtArea.setEditable(false);
	JScrollPane sp = new JScrollPane(txtArea);
	sp.setBounds(5, 5, 600, 410);
	frame.getContentPane().add(sp);
	
	btnOk = new JButton("OK");
	btnOk.setFont(new Font(Font.SANS_SERIF, 0, 12));
	btnOk.setBounds(510, 420, 95, 20);
	btnOk.addActionListener(new ActionListener() {
		public void actionPerformed(ActionEvent e) {
			frame.dispose();
		}
	});
	frame.getContentPane().add(btnOk);
	
	txtArea.append(new Utils().getLicenseFile());
	txtArea.setCaretPosition(0);
}
 
Example 13
Project: owa-notifier   File: LogWindowPanel.java   View source code 6 votes vote down vote up
/**
 * Constructor
 */
private LogWindowPanel() {

       this.setSize(500, 400);
       this.setVisible(false);
	jLogTextArea = new JTextArea();
	TextAreaAppender.setTextArea(jLogTextArea);
	
       JPanel thePanel = new JPanel(new BorderLayout());
       JScrollPane scrollPane = new JScrollPane(jLogTextArea);
       thePanel.add(scrollPane);
	this.add(thePanel);
	
	/*
	 * On close update notification tray
	 */
	this.addWindowListener(new java.awt.event.WindowAdapter() {
		@Override
	    public void windowClosing(java.awt.event.WindowEvent windowEvent) {
			if(displayLogItem != null) {
				displayLogItem.setLabel("Afficher les traces");
				displayLogItem.setState(false);
			}
	    }
	});
}
 
Example 14
Project: marathonv5   File: ToolBarDemo2.java   View source code 6 votes vote down vote up
public ToolBarDemo2() {
    super(new BorderLayout());

    // Create the toolbar.
    JToolBar toolBar = new JToolBar("Still draggable");
    addButtons(toolBar);
    toolBar.setFloatable(false);
    toolBar.setRollover(true);

    // Create the text area used for output. Request
    // enough space for 5 rows and 30 columns.
    textArea = new JTextArea(5, 30);
    textArea.setEditable(false);
    JScrollPane scrollPane = new JScrollPane(textArea);

    // Lay out the main panel.
    setPreferredSize(new Dimension(450, 130));
    add(toolBar, BorderLayout.PAGE_START);
    add(scrollPane, BorderLayout.CENTER);
}
 
Example 15
Project: HBaseClient   File: ExecutePutAction.java   View source code 6 votes vote down vote up
@Override
public void onClick(ActionEvent i_Event)
{
    String v_CMD = ((JTextArea)XJava.getObject("xtPutsInfo")).getText();
    
    if ( JavaHelp.isNull(v_CMD) )
    {
        this.getAppFrame().showHintInfo("请输入要执行的命令" ,Color.BLUE);
        return;
    }
    
    
    try
    {
        AppMain.executes(v_CMD);
        super.onClick(i_Event);
        
        this.getAppFrame().showHintInfo("执行完成,请查看控制台日志" ,Color.BLUE);
    }
    catch (Exception exce)
    {
        this.getAppFrame().showHintInfo("执行命令异常:" + exce.getMessage() ,Color.RED);
    }
}
 
Example 16
Project: EditCalculateAndChart   File: Delete_Action.java   View source code 5 votes vote down vote up
@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);
     }
}
 
Example 17
Project: org.alloytools.alloy   File: OurUtil.java   View source code 5 votes vote down vote up
/**
 * Make a JTextArea with the given text and number of rows and columns, then
 * call Util.make() to apply a set of attributes to it.
 * 
 * @param attributes - see {@link edu.mit.csail.sdg.alloy4.OurUtil#make
 *            OurUtil.make(component, attributes...)}
 */
public static JTextArea textarea(String text, int rows, int columns, boolean editable, boolean wrap,
		Object... attributes) {
	JTextArea ans = make(new JTextArea(text, rows, columns), Color.BLACK, Color.WHITE, new EmptyBorder(0, 0, 0, 0));
	ans.setEditable(editable);
	ans.setLineWrap(wrap);
	ans.setWrapStyleWord(wrap);
	return make(ans, attributes);
}
 
Example 18
Project: openjdk-jdk10   File: JTextAreaOperator.java   View source code 5 votes vote down vote up
/**
 * Maps {@code JTextArea.getLineCount()} through queue
 */
public int getLineCount() {
    return (runMapping(new MapIntegerAction("getLineCount") {
        @Override
        public int map() {
            return ((JTextArea) getSource()).getLineCount();
        }
    }));
}
 
Example 19
Project: VISNode   File: ExceptionPanel.java   View source code 5 votes vote down vote up
/**
 * Builds the message label
 * 
 * @param exception
 * @return JComponent
 */
private JComponent buildMessageLabel(Exception exception) {
    JTextArea textArea = new JTextArea(2, 100);
    textArea.setText(exception.getMessage());
    textArea.setBorder(null);
    textArea.setOpaque(false);
    textArea.setEditable(false);
    return textArea;
}
 
Example 20
Project: powertext   File: FontChooser.java   View source code 5 votes vote down vote up
public FontChooser(Frame frame, JTextArea t) {
	super(frame, "Choose Font", false);
               this.setLocationRelativeTo(null);
	if (sessionActive == true) {
		dispose();
		return;
	}
	sessionActive = true;
	this.textArea = t;
	font = textArea.getFont();
	setVisible(true);
	setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
	Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
	int width = (int) (screenSize.width / 3);
	int height = (int) (screenSize.height / 1.5);
	setSize(width, height);
	setLocation((screenSize.width / 2) - (width / 2),
			(screenSize.height / 2) - (height / 2));
	parentPanel = new JPanel(new BorderLayout());
	add(parentPanel);
	createFontList();
	createButtons();
	addWindowListener(new WindowAdapter() {
		public void windowClosing(WindowEvent e) {
			sessionActive = false;
			dispose();
		}
	});
}
 
Example 21
Project: bitnym   File: BroadcastsView.java   View source code 5 votes vote down vote up
public BroadcastsView() {
	super();
	GridBagConstraints gbc = new GridBagConstraints();
	GridBagLayout layout = new GridBagLayout();
	this.setLayout(layout);
	
	display = new JTextArea(16, 58);
	display.setEditable(false);
	
	scroll = new JScrollPane(display);
    scroll.setVerticalScrollBarPolicy ( ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS );
	this.add(scroll);
	
}
 
Example 22
Project: openjdk-jdk10   File: TooMuchWheelRotationEventsTest.java   View source code 5 votes vote down vote up
private static JPanel createTestPanel() {
    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
    JTextArea textArea = new JTextArea(20, 20);
    textArea.setText(getLongString());
    JScrollPane scrollPane = new JScrollPane(textArea);
    panel.add(scrollPane);
    return panel;
}
 
Example 23
Project: school-game   File: ConfigEditorPanel.java   View source code 5 votes vote down vote up
/**
 * Konstruktor.
 * Legt den Inhalt des Panels fest.
 */
public ConfigEditorPanel()
{
    super(new BorderLayout());

    String logPath = PathHelper.getBasePath();
    configFile = new File(logPath + "de.entwicklerpages.java.schoolgame");

    textArea = new JTextArea("Keine Konfiguration geladen!");
    textArea.setEditable(true);

    JScrollPane scrollPane = new JScrollPane(textArea, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    add(scrollPane, BorderLayout.CENTER);

    reloadButton = new JButton("Laden");
    reloadButton.addActionListener(this);

    saveButton = new JButton("Speichern");
    saveButton.addActionListener(this);
    saveButton.setEnabled(false);

    JPanel buttonBar = new JPanel(new GridLayout(1, 2));
    buttonBar.add(reloadButton);
    buttonBar.add(saveButton);

    add(buttonBar, BorderLayout.SOUTH);
}
 
Example 24
Project: MTG-Card-Recognizer   File: SetGenerator.java   View source code 5 votes vote down vote up
public SetGenerator()
{
	super("Set generator");
	setDefaultCloseOperation(DISPOSE_ON_CLOSE);
	gen = new JButton("Generate sets");
	typeBox = new JComboBox<>(setTypes);
	JScrollPane scroll = new JScrollPane();
	gen.addActionListener(new ActionListener(){
		public void actionPerformed(ActionEvent e) {
			runThread = true;
			genSets = new Thread(){
				public void run()
				{
					typeBox.setEnabled(false);
					gen.setEnabled(false);
					ArrayList<Set> sets = MTGCardQuery.getSets();
					for(Set s:sets){
						writeSet(s,SavedConfig.PATH,true);
						if(!runThread){
							System.out.println("stopped");
							return;
						}
					}
					gen.setEnabled(true);
					typeBox.setEnabled(true);
				}
			};
			genSets.start();
		}
	});
	jt=new JTextArea(10,50);
	jt.setEditable(false);
	scroll.setViewportView(jt);
	setLayout(new BorderLayout());
	add(scroll,BorderLayout.NORTH);
	add(typeBox,BorderLayout.CENTER);
	add(gen,BorderLayout.SOUTH);
	pack();
	setVisible(true);
}
 
Example 25
Project: Equella   File: I18nTextArea.java   View source code 5 votes vote down vote up
@Override
protected JTextComponent getTextComponent()
{
	ta = new JTextArea();
	ta.setLineWrap(true);
	ta.setWrapStyleWord(true);
	return ta;
}
 
Example 26
Project: openjdk-jdk10   File: Test6325652.java   View source code 5 votes vote down vote up
private static JInternalFrame create(int index) {
    String text = "test" + index; // NON-NLS: frame identification
    index = index * 3 + 1;

    JInternalFrame internal = new JInternalFrame(text, true, true, true, true);
    internal.getContentPane().add(new JTextArea(text));
    internal.setBounds(10 * index, 10 * index, WIDTH, HEIGHT);
    internal.setVisible(true);
    return internal;
}
 
Example 27
Project: GIFKR   File: Interpolator.java   View source code 5 votes vote down vote up
private void initializeComponents() {

		instructionArea = new JTextArea(getInstructions());
		instructionArea.setLineWrap(true);
		instructionArea.setWrapStyleWord(true);
		instructionArea.setEditable(false);
		instructionArea.setOpaque(false);
		
		animationButton = new JButton() {
			private static final long serialVersionUID = 225462629234945413L;
			@Override 
			public void paint(Graphics ga) {
				Graphics2D g = (Graphics2D) ga;

				g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
				g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);

				super.paint(ga);


				double xs = .9, ys = .75;

				g.translate(animationButton.getWidth()*((1-xs)/2), animationButton.getHeight()*((1-ys)/2));
				g.scale(xs, ys);
				paintButton(g, animationButton.getWidth(), animationButton.getHeight());

			}		
			@Override
			public Dimension getPreferredSize() {
				return new Dimension(super.getPreferredSize().width, 50);
			}
		};
	}
 
Example 28
Project: incubator-netbeans   File: EditorFindSupportTest.java   View source code 5 votes vote down vote up
@Test
public void testReplaceFindFocused() throws Exception {
    final Map<String, Object> props = new HashMap<>();
    props.put(EditorFindSupport.FIND_WHAT, "a");
    props.put(EditorFindSupport.FIND_REPLACE_WITH, "b");
    props.put(EditorFindSupport.FIND_HIGHLIGHT_SEARCH, Boolean.TRUE);
    props.put(EditorFindSupport.FIND_INC_SEARCH, Boolean.TRUE);
    props.put(EditorFindSupport.FIND_BACKWARD_SEARCH, Boolean.FALSE);
    props.put(EditorFindSupport.FIND_WRAP_SEARCH, Boolean.FALSE);
    props.put(EditorFindSupport.FIND_MATCH_CASE, Boolean.FALSE);
    props.put(EditorFindSupport.FIND_SMART_CASE, Boolean.FALSE);
    props.put(EditorFindSupport.FIND_WHOLE_WORDS, Boolean.FALSE);
    props.put(EditorFindSupport.FIND_REG_EXP, Boolean.FALSE);
    props.put(EditorFindSupport.FIND_HISTORY, new Integer(30));
    
    final EditorFindSupport instance = EditorFindSupport.getInstance();
    JTextArea ta = new JTextArea("aaaa");
    ta.setCaretPosition(0);
    instance.setFocusedTextComponent(ta);
    instance.replace(props, false);
    instance.find(props, false);
    assertEquals("baaa", ta.getText());
    instance.replace(props, false);
    instance.find(props, false);
    assertEquals("bbaa", ta.getText());
    instance.replace(props, false);
    instance.find(props, false);
    assertEquals("bbba", ta.getText());
}
 
Example 29
Project: chipKIT-importer   File: ProgressTrackingPanel.java   View source code 5 votes vote down vote up
private JComponent createImportFailedPane( Exception cause ) {
    JLabel infoLabel = new JLabel( NbBundle.getMessage( ProgressTrackingPanel.class, "ProgressTrackingPanel.importFailedMessage" ));
    infoLabel.setHorizontalAlignment(JLabel.CENTER );
    infoLabel.setBackground(Color.red);
    infoLabel.setOpaque(true);
    infoLabel.setBorder( BorderFactory.createLineBorder(Color.red, 3) );
    
    ByteArrayOutputStream arrayOutputStream = new ByteArrayOutputStream();
    PrintWriter printWriter = new PrintWriter( arrayOutputStream );
    cause.printStackTrace( printWriter );
    printWriter.flush();
    String stackTraceText = arrayOutputStream.toString();
    
    JTextArea stackTraceTextArea = new JTextArea( stackTraceText );
    stackTraceTextArea.setEditable(false);
    
    JScrollPane scrollPane = new JScrollPane( stackTraceTextArea );        
    
    JButton copyToClipboardButton = new JButton( NbBundle.getMessage( ProgressTrackingPanel.class, "ProgressTrackingPanel.copyToClipboard" ));
    copyToClipboardButton.addActionListener( (a) -> {
        Toolkit defaultToolkit = Toolkit.getDefaultToolkit();
        defaultToolkit.getSystemClipboard().setContents( new StringSelection(stackTraceText), null );
    });
    
    JPanel p1 = new JPanel( new FlowLayout(FlowLayout.TRAILING) );
    p1.add( copyToClipboardButton );
    
    JPanel p2 = new JPanel( new BorderLayout(0, 10) );
    p2.add( infoLabel, BorderLayout.NORTH );
    p2.add( scrollPane, BorderLayout.CENTER );        
    p2.add( p1, BorderLayout.SOUTH );
    p2.setSize( new Dimension(600,400) );
    p2.setMinimumSize( p2.getSize() );
    p2.setPreferredSize( p2.getSize() );
    
    return p2;
}
 
Example 30
Project: MyCourses   File: ActionStok.java   View source code 5 votes vote down vote up
public ActionStok(JTextField i, JTextField j, JTextField k,
	  JTextField o,JTextField t,JTextField e, JComboBox<String> g,JTextArea b,JTextField c ) {

  	StokAdi=i;
  	Stok_Kodu=j;
  	Kdv=k;
  	Marka=o;
  	Stok_Aciklama=t;
  	_zel_Kod=e;
  	Stok_Type=g;
PersonelTextArea=b;
sil=c;
}
 
Example 31
Project: xdman   File: BrowserIntDlg.java   View source code 5 votes vote down vote up
void createFFPanel() {
	ffPanel = new JPanel(new BorderLayout(20, 20));
	ffPanel.setBackground(Color.WHITE);
	ffPanel.setBorder(new EmptyBorder(20, 20, 20, 20));
	text2 = new JTextArea();
	Cursor c = text2.getCursor();
	text2.setBackground(bgColor);
	text2.setOpaque(false);
	text2.setWrapStyleWord(true);
	text2.setEditable(false);
	text2.setLineWrap(true);
	text2.setText(StringResource.getString("BI_LBL_2"));
	text2.setCursor(c);
	ffPanel.add(text2, BorderLayout.NORTH);
	ffPanel.add(ff);

	helpff = new JButton(StringResource.getString("BI_LBL_3"));
	helpff.addActionListener(this);
	JPanel pp = new JPanel(new BorderLayout(10, 10));
	pp.setBackground(Color.white);
	JTextArea txt2 = new JTextArea();
	txt2.setOpaque(false);
	txt2.setWrapStyleWord(true);
	txt2.setEditable(false);
	txt2.setLineWrap(true);
	String txt = new File(System.getProperty("user.home"),
			"xdm-helper/xdmff.xpi").getAbsolutePath();
	txt2.setText(StringResource.getString("BI_LBL_FF").replace("<FILE>",
			txt));
	pp.add(txt2);
	pp.add(helpff, BorderLayout.SOUTH);
	ffPanel.add(pp, BorderLayout.SOUTH);
}
 
Example 32
Project: openjdk-jdk10   File: JTextAreaOperator.java   View source code 5 votes vote down vote up
/**
 * Maps {@code JTextArea.getTabSize()} through queue
 */
public int getTabSize() {
    return (runMapping(new MapIntegerAction("getTabSize") {
        @Override
        public int map() {
            return ((JTextArea) getSource()).getTabSize();
        }
    }));
}
 
Example 33
Project: Tarski   File: mxCellEditor.java   View source code 5 votes vote down vote up
/**
 * 
 */
public mxCellEditor(mxGraphComponent graphComponent) {
  this.graphComponent = graphComponent;

  // Creates the plain text editor
  textArea = new JTextArea();
  textArea.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
  textArea.setOpaque(false);

  // Creates the HTML editor
  editorPane = new JEditorPane();
  editorPane.setOpaque(false);
  editorPane.setBackground(new Color(0, 0, 0, 0));
  editorPane.setContentType("text/html");

  // Workaround for inserted linefeeds in HTML markup with
  // lines that are longar than 80 chars
  editorPane.setEditorKit(new NoLinefeedHtmlEditorKit());

  // Creates the scollpane that contains the editor
  // FIXME: Cursor not visible when scrolling
  scrollPane = new JScrollPane();
  scrollPane.setBorder(BorderFactory.createEmptyBorder());
  scrollPane.getViewport().setOpaque(false);
  scrollPane.setVisible(false);
  scrollPane.setOpaque(false);

  // Installs custom actions
  editorPane.getActionMap().put(CANCEL_EDITING, cancelEditingAction);
  textArea.getActionMap().put(CANCEL_EDITING, cancelEditingAction);
  editorPane.getActionMap().put(SUBMIT_TEXT, textSubmitAction);
  textArea.getActionMap().put(SUBMIT_TEXT, textSubmitAction);

  // Remembers the action map key for the enter keystroke
  editorEnterActionMapKey = editorPane.getInputMap().get(enterKeystroke);
  textEnterActionMapKey = editorPane.getInputMap().get(enterKeystroke);
}
 
Example 34
Project: jdk8u-jdk   File: HorizontalMouseWheelOnShiftPressed.java   View source code 5 votes vote down vote up
static void createAndShowGUI() {
    frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setSize(300, 300);
    frame.setLocationRelativeTo(null);
    textArea = new JTextArea("Hello World!");
    scrollPane = new JScrollPane(textArea);
    JPanel panel = new JPanel(new BorderLayout());
    panel.add(scrollPane, BorderLayout.CENTER);
    frame.getContentPane().add(panel);
    frame.setVisible(true);
}
 
Example 35
Project: incubator-netbeans   File: FormatPanel.java   View source code 5 votes vote down vote up
private void validateText(JTextArea textArea) {
    assert textArea == revisionTextArea || textArea == issueInfoTextArea;
    String[] variables = textArea == revisionTextArea ? supportedRevisionVariables : supportedIssueInfoVariables;

    boolean valid = !HookUtils.containsUnsupportedVariables(textArea.getText(), variables);
    warningLabel.setText(NbBundle.getMessage(FormatPanel.class, "FormatPanel.warningLabel.text", list(variables)));
    warningLabel.setVisible(!valid);
}
 
Example 36
Project: incubator-netbeans   File: InstancesView.java   View source code 5 votes vote down vote up
public SuspendInfoPanel() {
    setLayout(new java.awt.GridBagLayout());
    JTextArea infoText = new JTextArea(NbBundle.getMessage(InstancesView.class, "MSG_NotSuspendedApp"));
    infoText.setEditable(false);
    infoText.setEnabled(false);
    infoText.setBackground(getBackground());
    infoText.setDisabledTextColor(new JLabel().getForeground());
    infoText.setLineWrap(true);
    infoText.setWrapStyleWord(true);
    infoText.setPreferredSize(
            new Dimension(
                infoText.getFontMetrics(infoText.getFont()).stringWidth(infoText.getText()),
                infoText.getPreferredSize().height));
    GridBagConstraints gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 1;
    //gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    //gridBagConstraints.weightx = 1.0;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.CENTER;
    gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
    add(infoText, gridBagConstraints);
    infoText.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(InstancesView.class, "MSG_NotSuspendedApp"));
    
    JButton pauseButton = new JButton();
    pauseButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            doStopCurrentDebugger();
        }
    });
    org.openide.awt.Mnemonics.setLocalizedText(pauseButton, NbBundle.getMessage(InstancesView.class, "CTL_Pause"));
    pauseButton.setIcon(ImageUtilities.loadImageIcon("org/netbeans/modules/debugger/resources/actions/Pause.gif", false));
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 2;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.CENTER;
    gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
    add(pauseButton, gridBagConstraints);
}
 
Example 37
Project: OpenJSharp   File: XTextAreaPeer.java   View source code 5 votes vote down vote up
AWTTextPane(JTextArea jt, XWindow xwin, Container parent) {
    super(jt);
    this.xwin = xwin;
    setDoubleBuffered(true);
    jt.addFocusListener(this);
    AWTAccessor.getComponentAccessor().setParent(this,parent);
    setViewportBorder(new BevelBorder(false,SystemColor.controlDkShadow,SystemColor.controlLtHighlight) );
    this.jtext = jt;
    setFocusable(false);
    addNotify();
}
 
Example 38
Project: jijimaku   File: TextAreaOutputStream.java   View source code 5 votes vote down vote up
public TextAreaOutputStream(JTextArea txtara, int maxlin) {
  if (maxlin < 1) {
    throw new IllegalArgumentException("TextAreaOutputStream maximum lines must be positive (value=" + maxlin + ")");
  }
  txtara.setEditable(false);
  txtara.setLineWrap(true);
  txtara.setWrapStyleWord(true);
  oneByte = new byte[1];
  appender = new Appender(txtara, maxlin);
}
 
Example 39
Project: LivroJavaComoProgramar10Edicao   File: TicTacToeServer.java   View source code 5 votes vote down vote up
public TicTacToeServer()
{
   super("Tic-Tac-Toe Server"); // set title of window

   // create ExecutorService with a thread for each player
   runGame = Executors.newFixedThreadPool(2);
   gameLock = new ReentrantLock(); // create lock for game

   // condition variable for both players being connected
   otherPlayerConnected = gameLock.newCondition();

   // condition variable for the other player's turn
   otherPlayerTurn = gameLock.newCondition();      

   for (int i = 0; i < 9; i++)
      board[i] = new String(""); // create tic-tac-toe board
   players = new Player[2]; // create array of players
   currentPlayer = PLAYER_X; // set current player to first player
 
   try
   {
      server = new ServerSocket(12345, 2); // set up ServerSocket
   } 
   catch (IOException ioException) 
   {
      ioException.printStackTrace();
      System.exit(1);
   } 

   outputArea = new JTextArea(); // create JTextArea for output
   add(outputArea, BorderLayout.CENTER);
   outputArea.setText("Server awaiting connections\n");

   setSize(300, 300); // set size of window
   setVisible(true); // show window
}
 
Example 40
Project: code-sentinel   File: MASConsoleGUI.java   View source code 5 votes vote down vote up
protected void initOutput() {
    output = new JTextArea();
    output.setEditable(false);        
    ((DefaultCaret)output.getCaret()).setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
    if (isTabbed) {
        tabPane.add("common", new JScrollPane(output));
    } else {
        pcenter.add(BorderLayout.CENTER, new JScrollPane(output));
    }
}