List of usage examples for javax.swing JTextArea JTextArea
public JTextArea()
From source file:net.sf.firemox.ui.component.SplashScreen.java
/** * Create a new instance of this class.// www .j a v a 2s . c o m * * @param filename * the picture filename. * @param parent * the splash screen's parent. * @param waitTime * the maximum time before the screen is hidden. */ public SplashScreen(String filename, Frame parent, int waitTime) { super(parent); getContentPane().setLayout(null); toFront(); final JLabel l = new JLabel(new ImageIcon(filename)); final Dimension labelSize = l.getPreferredSize(); l.setLocation(0, 0); l.setSize(labelSize); setSize(labelSize); final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); setLocation(screenSize.width / 2 - labelSize.width / 2, screenSize.height / 2 - labelSize.height / 2); final JLabel mp = new JLabel(IdConst.PROJECT_DISPLAY_NAME); mp.setLocation(30, 305); mp.setSize(new Dimension(300, 30)); final JLabel version = new JLabel(IdConst.VERSION); version.setLocation(235, 418); version.setSize(new Dimension(300, 30)); final JTextArea disclaimer = new JTextArea(); disclaimer.setEditable(false); disclaimer.setLineWrap(true); disclaimer.setWrapStyleWord(true); disclaimer.setAutoscrolls(true); disclaimer.setFont(MToolKit.defaultFont); disclaimer.setTabSize(2); // Then try and read it locally Reader inGPL = null; try { inGPL = new BufferedReader(new InputStreamReader(MToolKit.getResourceAsStream(IdConst.FILE_LICENSE))); disclaimer.read(inGPL, ""); } catch (IOException e) { e.printStackTrace(); } finally { IOUtils.closeQuietly(inGPL); } final JScrollPane disclaimerSPanel = new JScrollPane(); disclaimerSPanel.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); disclaimerSPanel.setViewportView(disclaimer); disclaimerSPanel.setLocation(27, 340); disclaimerSPanel.setPreferredSize(new Dimension(283, 80)); disclaimerSPanel.setSize(disclaimerSPanel.getPreferredSize()); getContentPane().add(disclaimerSPanel); getContentPane().add(version); getContentPane().add(mp); getContentPane().add(l); final int pause = waitTime; final Runnable waitRunner = new Runnable() { public void run() { try { Thread.sleep(pause); while (!bKilled) { Thread.sleep(200); } } catch (InterruptedException e) { // Ignore this error } setVisible(false); dispose(); MagicUIComponents.magicForm.toFront(); } }; // setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { setVisible(false); dispose(); if (MagicUIComponents.magicForm != null) MagicUIComponents.magicForm.toFront(); } }); addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_SPACE) { setVisible(false); dispose(); MagicUIComponents.magicForm.toFront(); } } }); setVisible(true); start(waitRunner); }
From source file:MultiListener.java
public MultiListener() { super(new GridBagLayout()); GridBagLayout gridbag = (GridBagLayout) getLayout(); GridBagConstraints c = new GridBagConstraints(); JLabel l = null;// w w w .java 2s .c o m c.fill = GridBagConstraints.BOTH; c.gridwidth = GridBagConstraints.REMAINDER; l = new JLabel("What MultiListener hears:"); gridbag.setConstraints(l, c); add(l); c.weighty = 1.0; topTextArea = new JTextArea(); topTextArea.setEditable(false); JScrollPane topScrollPane = new JScrollPane(topTextArea); Dimension preferredSize = new Dimension(200, 75); topScrollPane.setPreferredSize(preferredSize); gridbag.setConstraints(topScrollPane, c); add(topScrollPane); c.weightx = 0.0; c.weighty = 0.0; l = new JLabel("What Eavesdropper hears:"); gridbag.setConstraints(l, c); add(l); c.weighty = 1.0; bottomTextArea = new JTextArea(); bottomTextArea.setEditable(false); JScrollPane bottomScrollPane = new JScrollPane(bottomTextArea); bottomScrollPane.setPreferredSize(preferredSize); gridbag.setConstraints(bottomScrollPane, c); add(bottomScrollPane); c.weightx = 1.0; c.weighty = 0.0; c.gridwidth = 1; c.insets = new Insets(10, 10, 0, 10); button1 = new JButton("Blah blah blah"); gridbag.setConstraints(button1, c); add(button1); c.gridwidth = GridBagConstraints.REMAINDER; button2 = new JButton("You don't say!"); gridbag.setConstraints(button2, c); add(button2); button1.addActionListener(this); button2.addActionListener(this); button2.addActionListener(new Eavesdropper(bottomTextArea)); setPreferredSize(new Dimension(450, 450)); setBorder(BorderFactory.createCompoundBorder(BorderFactory.createMatteBorder(1, 1, 2, 2, Color.black), BorderFactory.createEmptyBorder(5, 5, 5, 5))); }
From source file:TreeExpandEventDemo2.java
public TreeExpandEventDemo2() { super(new GridBagLayout()); GridBagLayout gridbag = (GridBagLayout) getLayout(); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.BOTH; c.gridwidth = GridBagConstraints.REMAINDER; c.weightx = 1.0;/* w w w .j a v a 2 s.c om*/ c.weighty = 1.0; c.insets = new Insets(1, 1, 1, 1); demoArea = new DemoArea(); gridbag.setConstraints(demoArea, c); add(demoArea); c.insets = new Insets(0, 0, 0, 0); textArea = new JTextArea(); textArea.setEditable(false); JScrollPane scrollPane = new JScrollPane(textArea); scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); scrollPane.setPreferredSize(new Dimension(200, 75)); gridbag.setConstraints(scrollPane, c); add(scrollPane); setPreferredSize(new Dimension(450, 450)); setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); }
From source file:components.TextAreaDemo.java
private void initComponents() { jLabel1 = new JLabel("Try typing 'spectacular' or 'Swing'..."); textArea = new JTextArea(); setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); textArea.setColumns(20);// w w w. ja v a2 s. c o m textArea.setLineWrap(true); textArea.setRows(5); textArea.setWrapStyleWord(true); jScrollPane1 = new JScrollPane(textArea); GroupLayout layout = new GroupLayout(getContentPane()); getContentPane().setLayout(layout); //Create a parallel group for the horizontal axis ParallelGroup hGroup = layout.createParallelGroup(GroupLayout.Alignment.LEADING); //Create a sequential and a parallel groups SequentialGroup h1 = layout.createSequentialGroup(); ParallelGroup h2 = layout.createParallelGroup(GroupLayout.Alignment.TRAILING); //Add a scroll panel and a label to the parallel group h2 h2.addComponent(jScrollPane1, GroupLayout.Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 212, Short.MAX_VALUE); h2.addComponent(jLabel1, GroupLayout.Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 212, Short.MAX_VALUE); //Add a container gap to the sequential group h1 h1.addContainerGap(); // Add the group h2 to the group h1 h1.addGroup(h2); h1.addContainerGap(); //Add the group h1 to hGroup hGroup.addGroup(Alignment.TRAILING, h1); //Create the horizontal group layout.setHorizontalGroup(hGroup); //Create a parallel group for the vertical axis ParallelGroup vGroup = layout.createParallelGroup(GroupLayout.Alignment.LEADING); //Create a sequential group SequentialGroup v1 = layout.createSequentialGroup(); //Add a container gap to the sequential group v1 v1.addContainerGap(); //Add a label to the sequential group v1 v1.addComponent(jLabel1); v1.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED); //Add scroll panel to the sequential group v1 v1.addComponent(jScrollPane1, GroupLayout.DEFAULT_SIZE, 100, Short.MAX_VALUE); v1.addContainerGap(); //Add the group v1 to vGroup vGroup.addGroup(v1); //Create the vertical group layout.setVerticalGroup(vGroup); pack(); }
From source file:biomine.bmvis2.pipeline.ManualGroupOperation.java
@Override public JComponent getSettingsComponent(SettingsChangeCallback v, VisualGraph graph) { ArrayList<VisualNode> vns = new ArrayList<VisualNode>(); JTextArea text = new JTextArea(); text.append("Group of:\n"); for (VisualNode n : graph.getAllNodes()) { if (nodes.contains(n.getId())) { text.append(n.getName() + "\n"); }//from w ww .j av a 2s . c om } return text; }
From source file:com.github.rholder.gradle.intellij.DependencyViewer.java
public DependencyViewer(Project p, ToolWindow t) { super(true, true); this.project = p; this.toolWindow = t; this.splitter = new Splitter(false, 0.75f); this.information = new JTextArea(); this.toolingLogger = initToolingLogger(); this.dependencyCellRenderer = new DependencyCellRenderer(); this.dependencyCellRenderer.omittedSelected = JBColor.MAGENTA; this.dependencyCellRenderer.omittedUnselected = JBColor.GRAY; this.dependencyCellRenderer.normalSelected = JBColor.foreground(); this.dependencyCellRenderer.normalUnselected = JBColor.BLACK; this.information.setEditable(false); this.shouldPromptForCurrentProject = true; // TODO clean all of this up GradleService gradleService = ServiceManager.getService(project, GradleService.class); gradleService.addListener(new ViewActionListener() { @Override// w w w . j a v a2 s.c om public void refresh() { if (shouldPromptForCurrentProject) { switch (useCurrentProjectBuild()) { case 0: gradleBaseDir = project.getBasePath(); break; default: // do nothing, stay null } shouldPromptForCurrentProject = false; } if (gradleBaseDir == null) { promptForGradleBaseDir(); } updateView(null, null); new SwingWorker<GradleNode, Void>() { protected GradleNode doInBackground() throws Exception { try { Map<String, GradleNode> dependencyMap = loadProjectDependenciesFromModel(gradleBaseDir, toolingLogger); GradleNode rootDependency = dependencyMap.get("root"); GradleNode target = dependencyCellRenderer.selectedGradleNode; GradleNode selectedDependency; if (target != null && target.group != null) { selectedDependency = target; } else { selectedDependency = new GradleNode("No dependency selected"); } updateView(rootDependency, selectedDependency); return rootDependency; } catch (Exception e) { e.printStackTrace(); toolingLogger.log(ExceptionUtils.getFullStackTrace(e)); throw new RuntimeException(e); } } }.execute(); } @Override public void toggleShowReplaced() { dependencyCellRenderer.showReplaced = !dependencyCellRenderer.showReplaced; SwingUtilities.invokeLater(new Runnable() { @Override public void run() { splitter.repaint(); splitter.validate(); } }); } @Override public void reset() { gradleBaseDir = null; refresh(); } }); gradleService.refresh(); setContent(splitter); final ActionManager actionManager = ActionManager.getInstance(); ActionToolbar actionToolbar = actionManager.createActionToolbar("Gradle View Toolbar", (DefaultActionGroup) actionManager.getAction("GradleView.NavigatorActionsToolbar"), true); actionToolbar.setTargetComponent(splitter); setToolbar(actionToolbar.getComponent()); }
From source file:MouseEventDemo.java
public MouseEventDemo() { super(new GridBagLayout()); GridBagLayout gridbag = (GridBagLayout) getLayout(); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.BOTH; c.gridwidth = GridBagConstraints.REMAINDER; c.weightx = 1.0;//from w w w . j a v a2 s. c om c.weighty = 1.0; c.insets = new Insets(1, 1, 1, 1); blankArea = new BlankArea(new Color(0.98f, 0.97f, 0.85f)); gridbag.setConstraints(blankArea, c); add(blankArea); c.insets = new Insets(0, 0, 0, 0); textArea = new JTextArea(); textArea.setEditable(false); JScrollPane scrollPane = new JScrollPane(textArea); scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); scrollPane.setPreferredSize(new Dimension(200, 75)); gridbag.setConstraints(scrollPane, c); add(scrollPane); //Register for mouse events on blankArea and the panel. blankArea.addMouseListener(this); addMouseListener(this); setPreferredSize(new Dimension(450, 450)); setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); }
From source file:SwingMouseMotionEventDemo.java
public SwingMouseMotionEventDemo() { super(new GridBagLayout()); GridBagLayout gridbag = (GridBagLayout) getLayout(); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.BOTH; c.gridwidth = GridBagConstraints.REMAINDER; c.weightx = 1.0;//from www . j a v a 2s . co m c.weighty = 1.0; c.insets = new Insets(1, 1, 1, 1); blankArea = new BlankArea(new Color(0.98f, 0.97f, 0.85f)); gridbag.setConstraints(blankArea, c); add(blankArea); c.insets = new Insets(0, 0, 0, 0); textArea = new JTextArea(); textArea.setEditable(false); JScrollPane scrollPane = new JScrollPane(textArea, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); scrollPane.setPreferredSize(new Dimension(200, 75)); gridbag.setConstraints(scrollPane, c); add(scrollPane); //Register for mouse events on blankArea and panel. blankArea.addMouseMotionListener(this); addMouseMotionListener(this); setPreferredSize(new Dimension(450, 450)); setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); }
From source file:Main.java
private void addComponentsToPane() { JButton button = new JButton("Clear"); button.addActionListener(this); typingArea = new JTextField(20); typingArea.addKeyListener(this); // Uncomment this if you wish to turn off focus // traversal. The focus subsystem consumes // focus traversal keys, such as Tab and Shift Tab. // If you uncomment the following line of code, this // disables focus traversal and the Tab events will // become available to the key event listener. // typingArea.setFocusTraversalKeysEnabled(false); displayArea = new JTextArea(); displayArea.setEditable(false);//from w ww. j ava 2 s . c om JScrollPane scrollPane = new JScrollPane(displayArea); scrollPane.setPreferredSize(new Dimension(375, 125)); getContentPane().add(typingArea, BorderLayout.PAGE_START); getContentPane().add(scrollPane, BorderLayout.CENTER); getContentPane().add(button, BorderLayout.PAGE_END); }
From source file:KeyEventDemo.java
public KeyEventDemo() { super(new BorderLayout()); JButton button = new JButton("Clear"); button.addActionListener(this); typingArea = new JTextField(20); typingArea.addKeyListener(this); //Uncomment this if you wish to turn off focus //traversal. The focus subsystem consumes //focus traversal keys, such as Tab and Shift Tab. //If you uncomment the following line of code, this //disables focus traversal and the Tab events will //become available to the key event listener. //typingArea.setFocusTraversalKeysEnabled(false); displayArea = new JTextArea(); displayArea.setEditable(false);//from w ww . ja va 2 s . c om JScrollPane scrollPane = new JScrollPane(displayArea); scrollPane.setPreferredSize(new Dimension(375, 125)); add(typingArea, BorderLayout.PAGE_START); add(scrollPane, BorderLayout.CENTER); add(button, BorderLayout.PAGE_END); }