Java 类javax.swing.JTextArea 实例源码

项目:myster    文件:MessageWindow.java   
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");
}
项目:incubator-netbeans    文件:ActionMappingsTest.java   
@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"));
}
项目:incubator-netbeans    文件:ErrorPanel.java   
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);

}
项目:openjdk-jdk10    文件:JobAttrUpdateTest.java   
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);
}
项目:EditCalculateAndChart    文件:HelpFrame.java   
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);

}
项目:school-game    文件:LogReaderPanel.java   
/**
 * 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);
}
项目:EditCalculateAndChart    文件:FindRight_Action.java   
@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());
}
项目:incubator-netbeans    文件:EditorFindSupportTest.java   
/**
 * 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());
}
项目:openjdk-jdk10    文件:bug6442918a.java   
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);
}
项目:jdk8u-jdk    文件:MissingDragExitEventTest.java   
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);
}
项目:JuggleMasterPro    文件:DevelopmentJMenuItem.java   
/**
 * 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);
}
项目:Install_Builder_Universal    文件:GNULicenseWindow.java   
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);
}
项目:owa-notifier    文件:LogWindowPanel.java   
/**
 * 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);
            }
        }
    });
}
项目:marathonv5    文件:ToolBarDemo2.java   
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);
}
项目:HBaseClient    文件:ExecutePutAction.java   
@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);
    }
}
项目:EditCalculateAndChart    文件:Delete_Action.java   
@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);
     }
}
项目:org.alloytools.alloy    文件:OurUtil.java   
/**
 * 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);
}
项目:openjdk-jdk10    文件:JTextAreaOperator.java   
/**
 * Maps {@code JTextArea.getLineCount()} through queue
 */
public int getLineCount() {
    return (runMapping(new MapIntegerAction("getLineCount") {
        @Override
        public int map() {
            return ((JTextArea) getSource()).getLineCount();
        }
    }));
}
项目:VISNode    文件:ExceptionPanel.java   
/**
 * 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;
}
项目:powertext    文件:FontChooser.java   
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();
        }
    });
}
项目:bitnym    文件:BroadcastsView.java   
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);

}
项目:openjdk-jdk10    文件:TooMuchWheelRotationEventsTest.java   
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;
}
项目:school-game    文件:ConfigEditorPanel.java   
/**
 * 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);
}
项目:MTG-Card-Recognizer    文件:SetGenerator.java   
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);
}
项目:Equella    文件:I18nTextArea.java   
@Override
protected JTextComponent getTextComponent()
{
    ta = new JTextArea();
    ta.setLineWrap(true);
    ta.setWrapStyleWord(true);
    return ta;
}
项目:openjdk-jdk10    文件:Test6325652.java   
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;
}
项目:GIFKR    文件:Interpolator.java   
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);
            }
        };
    }
项目:incubator-netbeans    文件:EditorFindSupportTest.java   
@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());
}
项目:chipKIT-importer    文件:ProgressTrackingPanel.java   
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;
}
项目:MyCourses    文件:ActionStok.java   
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;
}
项目:xdman    文件:BrowserIntDlg.java   
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);
}
项目:openjdk-jdk10    文件:JTextAreaOperator.java   
/**
 * Maps {@code JTextArea.getTabSize()} through queue
 */
public int getTabSize() {
    return (runMapping(new MapIntegerAction("getTabSize") {
        @Override
        public int map() {
            return ((JTextArea) getSource()).getTabSize();
        }
    }));
}
项目:Tarski    文件:mxCellEditor.java   
/**
 * 
 */
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);
}
项目:jdk8u-jdk    文件:HorizontalMouseWheelOnShiftPressed.java   
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);
}
项目:incubator-netbeans    文件:FormatPanel.java   
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);
}
项目:incubator-netbeans    文件:InstancesView.java   
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);
}
项目:OpenJSharp    文件:XTextAreaPeer.java   
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();
}
项目:jijimaku    文件:TextAreaOutputStream.java   
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);
}
项目:LivroJavaComoProgramar10Edicao    文件:TicTacToeServer.java   
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
}
项目:code-sentinel    文件:MASConsoleGUI.java   
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));
    }
}