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   Source Code and License 8 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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: Equella   File: I18nTextArea.java   Source Code and License 6 votes vote down vote up
@Override
protected JTextComponent getTextComponent()
{
	ta = new JTextArea();
	ta.setLineWrap(true);
	ta.setWrapStyleWord(true);
	return ta;
}
 
Example 7
Project: school-game   File: LogReaderPanel.java   Source Code and License 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 8
Project: EditCalculateAndChart   File: FindRight_Action.java   Source Code and License 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 9
Project: incubator-netbeans   File: EditorFindSupportTest.java   Source Code and License 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 10
Project: openjdk-jdk10   File: bug6442918a.java   Source Code and License 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 11
Project: jdk8u-jdk   File: MissingDragExitEventTest.java   Source Code and License 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 12
Project: JuggleMasterPro   File: DevelopmentJMenuItem.java   Source Code and License 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 13
Project: Install_Builder_Universal   File: GNULicenseWindow.java   Source Code and License 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 14
Project: jijimaku   File: TextAreaOutputStream.java   Source Code and License 6 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 15
Project: owa-notifier   File: LogWindowPanel.java   Source Code and License 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 16
Project: OpenJSharp   File: MetalworksDocumentFrame.java   Source Code and License 6 votes vote down vote up
public MetalworksDocumentFrame() {
    super("", true, true, true, true);
    openFrameCount++;
    setTitle("Untitled Message " + openFrameCount);

    JPanel top = new JPanel();
    top.setBorder(new EmptyBorder(10, 10, 10, 10));
    top.setLayout(new BorderLayout());
    top.add(buildAddressPanel(), BorderLayout.NORTH);

    JTextArea content = new JTextArea(15, 30);
    content.setBorder(new EmptyBorder(0, 5, 0, 5));
    content.setLineWrap(true);



    JScrollPane textScroller = new JScrollPane(content,
            JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    top.add(textScroller, BorderLayout.CENTER);


    setContentPane(top);
    pack();
    setLocation(offset * openFrameCount, offset * openFrameCount);

}
 
Example 17
Project: marathonv5   File: ToolBarDemo2.java   Source Code and License 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 18
Project: HBaseClient   File: ExecutePutAction.java   Source Code and License 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 19
Project: EditCalculateAndChart   File: Delete_Action.java   Source Code and License 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 20
Project: org.alloytools.alloy   File: OurUtil.java   Source Code and License 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 21
Project: openjdk-jdk10   File: JTextAreaOperator.java   Source Code and License 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 22
Project: VISNode   File: ExceptionPanel.java   Source Code and License 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 23
Project: incubator-netbeans   File: StringEditor.java   Source Code and License 5 votes vote down vote up
@Override
public Component getCustomEditor () {
    if (customEditor == null) {
        JTextArea textArea = new JTextArea();
        textArea.setWrapStyleWord(true);
        textArea.setLineWrap(true);
        textArea.setColumns(60);
        textArea.setRows(8);
        textArea.getDocument().addDocumentListener(this);
        textArea.getAccessibleContext().setAccessibleName(
                NbBundle.getBundle(StringEditor.class).getString("ACSN_StringEditorTextArea")); //NOI18N
        textArea.getAccessibleContext().setAccessibleDescription(
                NbBundle.getBundle(StringEditor.class).getString("ACSD_StringEditorTextArea")); //NOI18N

        JScrollPane scroll = new JScrollPane();
        scroll.setViewportView(textArea);

        JLabel htmlTipLabel = new JLabel(NbBundle.getMessage(StringEditor.class, "StringEditor.htmlTipLabel.text")); // NOI18N

        JPanel panel = new JPanel();
        GroupLayout layout = new GroupLayout(panel);
        layout.setAutoCreateGaps(true);
        panel.setLayout(layout);
        layout.setHorizontalGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup()
                    .addComponent(scroll)
                    .addComponent(htmlTipLabel))
                .addContainerGap());
        layout.setVerticalGroup(layout.createSequentialGroup()
                .addContainerGap().addComponent(scroll).addComponent(htmlTipLabel));

        customEditor = panel;
        textComp = textArea;
        htmlTipLabel.setVisible(htmlText);
    }

    textComp.setEditable(editable);
    setValueToCustomEditor();

    return customEditor;
}
 
Example 24
Project: powertext   File: FontChooser.java   Source Code and License 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 25
Project: bitnym   File: BroadcastsView.java   Source Code and License 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 26
Project: openjdk-jdk10   File: TooMuchWheelRotationEventsTest.java   Source Code and License 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 27
Project: school-game   File: ConfigEditorPanel.java   Source Code and License 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 28
Project: MTG-Card-Recognizer   File: SetGenerator.java   Source Code and License 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 29
Project: openjdk-jdk10   File: Test6325652.java   Source Code and License 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 30
Project: GIFKR   File: Interpolator.java   Source Code and License 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 31
Project: incubator-netbeans   File: EditorFindSupportTest.java   Source Code and License 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 32
Project: chipKIT-importer   File: ProgressTrackingPanel.java   Source Code and License 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 33
Project: MyCourses   File: ActionStok.java   Source Code and License 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 34
Project: xdman   File: BrowserIntDlg.java   Source Code and License 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 35
Project: openjdk-jdk10   File: JTextAreaOperator.java   Source Code and License 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 36
Project: Tarski   File: mxCellEditor.java   Source Code and License 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 37
Project: jdk8u-jdk   File: HorizontalMouseWheelOnShiftPressed.java   Source Code and License 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 38
Project: incubator-netbeans   File: FormatPanel.java   Source Code and License 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 39
Project: incubator-netbeans   File: InstancesView.java   Source Code and License 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 40
Project: OpenJSharp   File: XTextAreaPeer.java   Source Code and License 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 41
Project: LivroJavaComoProgramar10Edicao   File: TicTacToeServer.java   Source Code and License 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 42
Project: code-sentinel   File: MASConsoleGUI.java   Source Code and License 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));
    }
}
 
Example 43
Project: openjdk-jdk10   File: JTextAreaOperator.java   Source Code and License 5 votes vote down vote up
/**
 * Maps {@code JTextArea.append(String)} through queue
 */
public void append(final String string) {
    runMapping(new MapVoidAction("append") {
        @Override
        public void map() {
            ((JTextArea) getSource()).append(string);
        }
    });
}
 
Example 44
Project: freecol   File: FreeColMenuTest.java   Source Code and License 5 votes vote down vote up
public Container createContentPane() {
    //Create the content-pane-to-be.
    JPanel contentPane = new JPanel(new BorderLayout());
    contentPane.setOpaque(true);

    //Create a scrolled text area.
    output = new JTextArea(5, 30);
    output.setEditable(false);
    scrollPane = new JScrollPane(output);

    //Add the text area to the content pane.
    contentPane.add(scrollPane, BorderLayout.CENTER);

    return contentPane;
}
 
Example 45
Project: JuggleMasterPro   File: DevelopmentJMenuItem.java   Source Code and License 5 votes vote down vote up
final private JDialog getDevelopmentDialog(	ControlJFrame objPcontrolJFrame,
											JTextArea objPdevelopmentJTextArea,
											ExtendedJButton objPdevelopmentCloseExtendedJButton) {

	// Development scrollpane :
	final JScrollPane objLdevelopmentJScrollPane =
													new JScrollPane(objPdevelopmentJTextArea,
																	ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
																	ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
	objLdevelopmentJScrollPane.setOpaque(true);

	// Development dialog :
	final JDialog objLdevelopmentJDialog =
											new JDialog(objPcontrolJFrame,
														objPcontrolJFrame.getLanguageString(Language.intS_TITLE_DEVELOPMENT),
														true);
	objLdevelopmentJDialog.setLayout(new GridBagLayout());
	final ExtendedGridBagConstraints objLextendedGridBagConstraints =
																		new ExtendedGridBagConstraints(	0,
																										GridBagConstraints.RELATIVE,
																										1,
																										1,
																										GridBagConstraints.CENTER,
																										0,
																										0,
																										0,
																										10,
																										0,
																										0,
																										GridBagConstraints.BOTH,
																										1.0F,
																										1.0F);

	// Add content :
	objLdevelopmentJDialog.add(objLdevelopmentJScrollPane, objLextendedGridBagConstraints);
	objLextendedGridBagConstraints.setFilling(GridBagConstraints.NONE, 0.0F, 0.0F);
	objLdevelopmentJDialog.add(objPdevelopmentCloseExtendedJButton, objLextendedGridBagConstraints);
	objLdevelopmentJDialog.addWindowListener(new JDialogWindowListener(objPcontrolJFrame, objLdevelopmentJDialog, false));
	return objLdevelopmentJDialog;
}
 
Example 46
Project: java-course   File: SortLinesDescendingAction.java   Source Code and License 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void actionPerformed(ActionEvent e) {
    JTextArea currentEditor = observer.getActiveEditor().getEditor();
    Document document = currentEditor.getDocument();
    Caret caret = currentEditor.getCaret();

    int startCaret = Math.min(caret.getDot(), caret.getMark());
    int endCaret = Math.max(caret.getDot(), caret.getMark());

    try {

        int startLine = currentEditor.getLineOfOffset(startCaret);
        int endLine = currentEditor.getLineOfOffset(endCaret);
        int fromPos = currentEditor.getLineStartOffset(startLine);
        int length = currentEditor.getLineEndOffset(endLine) - fromPos;

        String text = currentEditor.getText(fromPos, length);
        text = sortLinesDesc(text);
        document.remove(fromPos, length);
        document.insertString(fromPos, text, null);
        caret.setDot(fromPos);
        caret.moveDot(fromPos + length);
        currentEditor.requestFocus();
    } catch (BadLocationException e1) {
        observer.errorMessage(e1);
    }

}
 
Example 47
Project: openjdk-jdk10   File: bug8132503.java   Source Code and License 5 votes vote down vote up
@Override
public void init() {
    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            JTextArea textArea = new JTextArea("Text area of the test.", 40, 40);
            add(new JScrollPane(textArea));
        }
    });
}
 
Example 48
Project: powertext   File: Caretlistener.java   Source Code and License 5 votes vote down vote up
public int getColumn(int pos,JTextArea textPane1)
{
    try
    {
        return pos-Utilities.getRowStart(textPane1, pos)+1;
    }
    catch (BadLocationException evt) {evt.printStackTrace();  }

    return -1;
}
 
Example 49
Project: Equella   File: SqlConnectionAndQueryPanel.java   Source Code and License 5 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public void setup()
{
	description = new JLabel();
	sql = new JTextArea();
	Map<TextAttribute, Object> fas = (Map<TextAttribute, Object>) sql.getFont().getAttributes();
	fas.put(TextAttribute.FAMILY, Font.MONOSPACED);
	sql.setFont(new Font(fas));

	setLayout(new BorderLayout());
	add(description, BorderLayout.NORTH);
	add(new JScrollPane(sql), BorderLayout.CENTER);
}
 
Example 50
Project: FinalSpeed   File: LogFrame.java   Source Code and License 5 votes vote down vote up
public void trunkTextArea(JTextArea txtWin){
    int numLinesToTrunk = txtWin.getLineCount() - SCROLL_BUFFER_SIZE;
    if(numLinesToTrunk > 0)
    {
        try
        {
            int posOfLastLineToTrunk = txtWin.getLineEndOffset(numLinesToTrunk - 1);
            txtWin.replaceRange("",0,posOfLastLineToTrunk);
        }
        catch (BadLocationException ex) {
            ex.printStackTrace();
        }
    }
}
 
Example 51
Project: VASSAL-src   File: ServerAddressBook.java   Source Code and License 5 votes vote down vote up
protected void test() {
  final JTextArea result = new JTextArea(10, 30);
  result.setText(JabberClient.testConnection(jabberHost.getText(), jabberPort.getText(),
      jabberUser.getText(), jabberPw.getText()));
  try {
  Dialogs.showDialog(null,
      Resources.getString("ServerAddressBook.connection_test"), //$NON-NLS-1$
      result, JOptionPane.INFORMATION_MESSAGE, null, JOptionPane.OK_CANCEL_OPTION, null, null,
      null, null);
  }
  catch (IllegalStateException ex) {
    ex.printStackTrace();
  }
}
 
Example 52
Project: EditCalculateAndChart   File: FindLeft_Action.java   Source Code and License 5 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() < s.length()-1){
          JOptionPane.showMessageDialog(TEdit.getFrame(),"Reached the beginning of the text");
          return;
      }
           if(area.getCaretPosition()-s.length()<=0){
               area.setCaretPosition(txt.length()-1);
           }
           int foundAt = txt.substring(0,area.getCaretPosition()-s.length()).lastIndexOf(s);
           
           if(foundAt == -1){
               JOptionPane.showMessageDialog(TEdit.getFrame(),"Reached the beginning of the text");
               return;
           }
               area.setCaretPosition(foundAt);
               area.select(foundAt,foundAt+s.length());
}
 
Example 53
Project: PTEAssistant   File: Console.java   Source Code and License 5 votes vote down vote up
public Console() {
    setLayout(new BorderLayout());
    setBorder(new TitledBorder("控制台"));
    textarea = new JTextArea();
    textarea.setCaretPosition(textarea.getText().length());
    textarea.setFont(new Font("新宋体", Font.PLAIN, 12));
    add(textarea);
    DefaultCaret caret = (DefaultCaret) textarea.getCaret();
    caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
    scrollPane = new JScrollPane();
    scrollPane.setViewportView(textarea);
    add(scrollPane, BorderLayout.CENTER);
    
    welcome();
}
 
Example 54
Project: jdk8u-jdk   File: XTextAreaPeer.java   Source Code and License 4 votes vote down vote up
public JTextArea getTextArea () {
    return this.jtext;
}
 
Example 55
Project: OpenJSharp   File: LWTextAreaPeer.java   Source Code and License 4 votes vote down vote up
public JTextArea getView() {
    return (JTextArea) getViewport().getView();
}
 
Example 56
Project: TechComparisonProject   File: ServerGUI.java   Source Code and License 4 votes vote down vote up
public static JTextArea getTextArea ()
{
	return textArea;
}
 
Example 57
Project: jdk8u-jdk   File: Test6526631.java   Source Code and License 4 votes vote down vote up
public Test6526631(JFrame frame) {
    this.pane = new JScrollPane(new JTextArea(ROWS, COLS));
    this.pane.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
    this.frame = frame;
    this.frame.add(this.pane);
}
 
Example 58
Project: OpenJSharp   File: XTextAreaPeer.java   Source Code and License 4 votes vote down vote up
@Override
public void installUI(JComponent c) {
    super.installUI(c);

    jta = (JTextArea) c;

    JTextArea editor = jta;

    UIDefaults uidefaults = XToolkit.getUIDefaults();

    String prefix = getPropertyPrefix();
    Font f = editor.getFont();
    if ((f == null) || (f instanceof UIResource)) {
        editor.setFont(uidefaults.getFont(prefix + ".font"));
    }

    Color bg = editor.getBackground();
    if ((bg == null) || (bg instanceof UIResource)) {
        editor.setBackground(uidefaults.getColor(prefix + ".background"));
    }

    Color fg = editor.getForeground();
    if ((fg == null) || (fg instanceof UIResource)) {
        editor.setForeground(uidefaults.getColor(prefix + ".foreground"));
    }

    Color color = editor.getCaretColor();
    if ((color == null) || (color instanceof UIResource)) {
        editor.setCaretColor(uidefaults.getColor(prefix + ".caretForeground"));
    }

    Color s = editor.getSelectionColor();
    if ((s == null) || (s instanceof UIResource)) {
        editor.setSelectionColor(uidefaults.getColor(prefix + ".selectionBackground"));
    }

    Color sfg = editor.getSelectedTextColor();
    if ((sfg == null) || (sfg instanceof UIResource)) {
        editor.setSelectedTextColor(uidefaults.getColor(prefix + ".selectionForeground"));
    }

    Color dfg = editor.getDisabledTextColor();
    if ((dfg == null) || (dfg instanceof UIResource)) {
        editor.setDisabledTextColor(uidefaults.getColor(prefix + ".inactiveForeground"));
    }

    Border b = new BevelBorder(false,SystemColor.controlDkShadow,SystemColor.controlLtHighlight);
    editor.setBorder(new BorderUIResource.CompoundBorderUIResource(
        b,new EmptyBorder(2, 2, 2, 2)));

    Insets margin = editor.getMargin();
    if (margin == null || margin instanceof UIResource) {
        editor.setMargin(uidefaults.getInsets(prefix + ".margin"));
    }
}
 
Example 59
Project: freecol   File: SelectAmountDialog.java   Source Code and License 4 votes vote down vote up
/**
 * The constructor to use.
 *
 * @param freeColClient The enclosing {@code FreeColClient}.
 * @param frame The owner frame.
 * @param goodsType The {@code GoodsType} to select an amount of.
 * @param available The amount of goods available.
 * @param defaultAmount The amount to select to start with.
 * @param pay If true, check the player has sufficient funds.
 */
public SelectAmountDialog(FreeColClient freeColClient, JFrame frame,
                          GoodsType goodsType, int available,
                          int defaultAmount, boolean pay) {
    super(freeColClient, frame);

    if (pay) {
        final Player player = getMyPlayer();
        final int gold = player.getGold();
        int price = player.getMarket().getCostToBuy(goodsType);
        available = Math.min(available, gold/price);
    }
    this.available = available;

    JTextArea question
        = Utility.localizedTextArea("selectAmountDialog.text");

    List<Integer> values = new ArrayList<>();
    int defaultIndex = -1;
    for (int index = 0; index < amounts.length; index++) {
        if (amounts[index] < available) {
            if (amounts[index] == defaultAmount) defaultIndex = index;
            values.add(amounts[index]);
        } else {
            if (available == defaultAmount) defaultIndex = index;
            values.add(available);
            break;
        }
    }
    if (defaultAmount > 0 && defaultIndex < 0) {
        for (int index = 0; index < values.size(); index++) {
            if (defaultAmount < values.get(index)) {
                values.add(index, defaultAmount);
                defaultIndex = index;
                break;
            }
        }
    }
    this.comboBox = new JComboBox<>(values.toArray(new Integer[0]));
    this.comboBox.setEditable(true);
    if (defaultIndex >= 0) this.comboBox.setSelectedIndex(defaultIndex);
    this.comboBox.setInputVerifier(new InputVerifier() {
            @Override @SuppressWarnings("unchecked")
            public boolean verify(JComponent input) {
                return verifyWholeBox((JComboBox<Integer>)input);
            }
        });
    MigPanel panel = new MigPanel(new MigLayout("wrap 1", "", ""));
    panel.add(question);
    panel.add(this.comboBox, "wrap 20, growx");
    panel.setSize(panel.getPreferredSize());

    initializeInputDialog(frame, true, panel, null, "ok", "cancel");
}
 
Example 60
Project: etomica   File: ViewSpeciesSelection.java   Source Code and License 4 votes vote down vote up
public JTextArea getDescription() {
	return Description;
}