List of usage examples for javax.swing JTextArea JTextArea
public JTextArea()
From source file:view.ResultsPanel.java
public ResultsPanel(final MainControler controler, String[] command, String resultsName) { this.resultsName = resultsName; this.controler = controler; this.command = command; modeTable = new JTable(0, 2); DefaultTableModel model = new MyTableModel(); model.addColumn("Stoichiometry"); model.addColumn("Enzyme name"); model.addColumn("Equation"); modeTable.setModel(model);/*ww w . j ava 2 s. c o m*/ JPanel logPanel = new JPanel(new BorderLayout()); log = new JTextArea(); log.setEditable(false); log.setBackground(new Color(0, 0, 0)); log.setForeground(new Color(255, 255, 255)); logPanel.add(new JLabel("Genereted log", JLabel.CENTER), BorderLayout.PAGE_START); logPanel.add(new JScrollPane(log), BorderLayout.CENTER); addToProject.setName("add"); addToProject.setToolTipText("Attach this result to the project"); removeFromProject.setName("remove"); removeFromProject.setToolTipText("Remove this result from the project"); removeFromProject.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { removeFromProject(); updateToolbar(); } }); addToProject.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { addToProject(); updateToolbar(); } }); if (!resultsName.startsWith("saved/")) { isAttached = false; } else { isAttached = true; } filterButton.setToolTipText("Filter the results"); filterButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { FilterFrame ff = new FilterFrame(GeneralFrame.getInstance(controler), allModes, filter, controler); if (ff.okPressed()) { displayFrame(ff.getNewModes(), ff.getIndices()); } } }); scriptButton.setToolTipText("Download the command as a script"); scriptButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String scriptString = makeScript(); new Download(scriptString, "Download the command as a script", ""); } }); download = new JButton(new ImageIcon("src/icons/download.png")); download.setToolTipText("Download results"); histoButton.setToolTipText("Statistics"); searchField.setMaximumSize(new Dimension(20, 30)); readLog(); allModes = readResultsFile(); List<Integer> indices = new ArrayList<Integer>(); for (int i = 0; i < allModes.size(); i++) { indices.add((i + 1)); } displayFrame(allModes, indices); }
From source file:gtu._work.ui.RegexCatchReplacer.java
private void initGUI() { try {//from ww w . ja v a2 s . c om { } BorderLayout thisLayout = new BorderLayout(); getContentPane().setLayout(thisLayout); this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); { jTabbedPane1 = new JTabbedPane(); getContentPane().add(jTabbedPane1, BorderLayout.CENTER); { jPanel1 = new JPanel(); BorderLayout jPanel1Layout = new BorderLayout(); jPanel1.setLayout(jPanel1Layout); jTabbedPane1.addTab("source", null, jPanel1, null); { jScrollPane1 = new JScrollPane(); jPanel1.add(jScrollPane1, BorderLayout.CENTER); { replaceArea = new JTextArea(); jScrollPane1.setViewportView(replaceArea); replaceArea.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { JPopupMenuUtil.newInstance(replaceArea).applyEvent(evt) .addJMenuItem("load from file", true, new ActionListener() { Thread newThread; public void actionPerformed(ActionEvent arg0) { if (newThread != null && newThread.getState() != Thread.State.TERMINATED) { JCommonUtil._jOptionPane_showMessageDialog_error( "file is loading!"); return; } final File file = JCommonUtil._jFileChooser_selectFileOnly(); if (file == null) { JCommonUtil._jOptionPane_showMessageDialog_error( "file is not correct!"); return; } String defaultCharset = Charset.defaultCharset().displayName(); String chst = (String) JCommonUtil._jOptionPane_showInputDialog( "input your charset!", defaultCharset); final Charset charset2 = Charset.forName( StringUtils.defaultIfEmpty(chst, defaultCharset)); newThread = new Thread(Thread.currentThread().getThreadGroup(), new Runnable() { public void run() { try { loadFromFileSb = new StringBuilder(); BufferedReader reader = new BufferedReader( new InputStreamReader( new FileInputStream(file), charset2)); for (String line = null; (line = reader .readLine()) != null;) { loadFromFileSb.append(line + "\n"); } reader.close(); replaceArea .setText(loadFromFileSb.toString()); JCommonUtil ._jOptionPane_showMessageDialog_info( "load completed!"); } catch (Exception e) { JCommonUtil.handleException(e); } } }, "" + System.currentTimeMillis()); newThread.setDaemon(true); newThread.start(); } }).show(); } }); } } } { jPanel2 = new JPanel(); BorderLayout jPanel2Layout = new BorderLayout(); jPanel2.setLayout(jPanel2Layout); jTabbedPane1.addTab("param", null, jPanel2, null); { exeucte = new JButton(); jPanel2.add(exeucte, BorderLayout.SOUTH); exeucte.setText("exeucte"); exeucte.setPreferredSize(new java.awt.Dimension(491, 125)); exeucte.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { exeucteActionPerformed(evt); } }); } { jPanel3 = new JPanel(); GroupLayout jPanel3Layout = new GroupLayout((JComponent) jPanel3); jPanel3.setLayout(jPanel3Layout); jPanel2.add(jPanel3, BorderLayout.CENTER); { repFromText = new JTextField(); } { repToText = new JTextField(); } jPanel3Layout.setHorizontalGroup(jPanel3Layout.createSequentialGroup() .addContainerGap(25, 25) .addGroup(jPanel3Layout.createParallelGroup() .addGroup(jPanel3Layout.createSequentialGroup().addComponent(repFromText, GroupLayout.PREFERRED_SIZE, 446, GroupLayout.PREFERRED_SIZE)) .addGroup(jPanel3Layout.createSequentialGroup().addComponent(repToText, GroupLayout.PREFERRED_SIZE, 446, GroupLayout.PREFERRED_SIZE))) .addContainerGap(20, Short.MAX_VALUE)); jPanel3Layout.setVerticalGroup(jPanel3Layout.createSequentialGroup().addContainerGap() .addComponent(repFromText, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE) .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(repToText, GroupLayout.PREFERRED_SIZE, 24, GroupLayout.PREFERRED_SIZE) .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)); } { addToTemplate = new JButton(); jPanel2.add(addToTemplate, BorderLayout.NORTH); addToTemplate.setText("add to template"); addToTemplate.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { prop.put(repFromText.getText(), repToText.getText()); reloadTemplateList(); } }); } } { jPanel4 = new JPanel(); BorderLayout jPanel4Layout = new BorderLayout(); jPanel4.setLayout(jPanel4Layout); jTabbedPane1.addTab("result", null, jPanel4, null); { jScrollPane2 = new JScrollPane(); jPanel4.add(jScrollPane2, BorderLayout.CENTER); jScrollPane2.setPreferredSize(new java.awt.Dimension(491, 283)); { DefaultTableModel resultAreaModel = JTableUtil.createModel(true, "match", "count"); resultArea = new JTable(); jScrollPane2.setViewportView(resultArea); JTableUtil.defaultSetting(resultArea); resultArea.setModel(resultAreaModel); } } } { jPanel5 = new JPanel(); BorderLayout jPanel5Layout = new BorderLayout(); jPanel5.setLayout(jPanel5Layout); jTabbedPane1.addTab("template", null, jPanel5, null); { jScrollPane3 = new JScrollPane(); jPanel5.add(jScrollPane3, BorderLayout.CENTER); { templateList = new JList(); jScrollPane3.setViewportView(templateList); reloadTemplateList(); } templateList.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { if (templateList.getLeadSelectionIndex() == -1) { return; } Entry<Object, Object> entry = (Entry<Object, Object>) JListUtil .getLeadSelectionObject(templateList); repFromText.setText((String) entry.getKey()); repToText.setText((String) entry.getValue()); } }); templateList.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent evt) { JListUtil.newInstance(templateList).defaultJListKeyPressed(evt); } }); } } { jPanel6 = new JPanel(); FlowLayout jPanel6Layout = new FlowLayout(); jPanel6.setLayout(jPanel6Layout); jTabbedPane1.addTab("result1", null, jPanel6, null); { resultBtn1 = new JButton(); jPanel6.add(resultBtn1); resultBtn1.setText("to String[]"); resultBtn1.setPreferredSize(new java.awt.Dimension(105, 32)); resultBtn1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { JTableUtil tableUtil = JTableUtil.newInstance(resultArea); int[] rowPoss = tableUtil.getSelectedRows(); DefaultTableModel model = tableUtil.getModel(); List<Object> valueList = new ArrayList<Object>(); for (int ii = 0; ii < rowPoss.length; ii++) { valueList.add(model.getValueAt(rowPoss[ii], 0)); } String reult = valueList.toString().replaceAll("[\\s]", "") .replaceAll("[\\,]", "\",\"").replaceAll("[\\[\\]]", "\""); ClipboardUtil.getInstance().setContents(reult); } }); } { resultBtn2 = new JButton(); jPanel6.add(resultBtn2); resultBtn2.setText("TODO"); resultBtn2.setPreferredSize(new java.awt.Dimension(105, 32)); resultBtn2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { System.out.println("resultBtn1.actionPerformed, event=" + evt); //TODO add your code for resultBtn1.actionPerformed JCommonUtil._jOptionPane_showMessageDialog_info("TODO"); } }); } } } this.setSize(512, 350); JCommonUtil.setFont(repToText, repFromText, replaceArea, templateList); JCommonUtil.frameCloseDo(this, new WindowAdapter() { public void windowClosing(WindowEvent paramWindowEvent) { if (StringUtils.isNotBlank(repFromText.getText())) { prop.put(repFromText.getText(), repToText.getText()); } try { prop.store(new FileOutputStream(propFile), "regexText"); } catch (Exception e) { JCommonUtil.handleException("properties store error!", e); } setVisible(false); dispose(); } }); } catch (Exception e) { e.printStackTrace(); } }
From source file:edu.ku.brc.specify.utilapps.DataModelClassGenerator.java
/** * @param dataClass//from w w w .j av a 2 s. co m * @param tableId */ public DataModelClassGenerator(final Class<?> dataClass) { this.dataClass = dataClass; Class<?>[] baseClasses = { Boolean.class, Integer.class, Double.class, String.class, Float.class, Character.class, Short.class, Byte.class, BigDecimal.class, Date.class, Calendar.class }; for (Class<?> cls : baseClasses) { baseClassHash.put(cls.getSimpleName(), true); } int cnt = 0; for (Field field : dataClass.getDeclaredFields()) { if (field.getType() == String.class || Collection.class.isAssignableFrom(field.getType())) { cnt++; } } Font font = new Font("Courier", Font.PLAIN, 10); logArea = new JTextArea(); logArea.setFont(font); tableIdTxt = new JTextField(10); devTxt = new JTextField(10); PanelBuilder outer = new PanelBuilder(new FormLayout("p,2px,p,2px,f:p:g", "200px:g,4px,f:300px:g,4px,p")); PanelBuilder pb = new PanelBuilder(new FormLayout("p,2px,p,2px,l:p:g,2px,l:p", UIHelper.createDuplicateJGoodiesDef("p", "2px", cnt + 2))); CellConstraints cc = new CellConstraints(); pb.add(new JLabel("Table Id"), cc.xy(1, 1)); pb.add(tableIdTxt, cc.xywh(3, 1, 3, 1)); pb.add(new JLabel("Dev"), cc.xy(1, 3)); pb.add(devTxt, cc.xywh(3, 3, 3, 1)); int y = 5; for (Field field : dataClass.getDeclaredFields()) { if (field.getType() == String.class) { UIRow row = new UIRow(DataType.String, field); pb.add(new JLabel(field.getName()), cc.xy(1, y)); pb.add(row.getSizetxt(), cc.xywh(3, y, 1, 1)); y += 2; rows.add(row); fieldRowhash.put(field, row); } if (Collection.class.isAssignableFrom(field.getType())) { UIRow row = new UIRow(DataType.Set, field); pb.add(new JLabel(field.getName()), cc.xy(1, y)); pb.add(row.getSizetxt(), cc.xywh(3, y, 3, 1)); pb.add(new JLabel("(Set)", SwingConstants.LEFT), cc.xy(7, y)); y += 2; rows.add(row); fieldRowhash.put(field, row); } } JButton processBtn = UIHelper.createButton("Process"); JButton cancelBtn = UIHelper.createButton("Cancel"); processBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { process(); } }); cancelBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { setVisible(false); } }); pb.getPanel().setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); JPanel panel = ButtonBarFactory.buildGrowingBar(new JButton[] { processBtn, cancelBtn }); outer.add(new JScrollPane(pb.getPanel(), ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED), cc.xywh(1, 1, 5, 1)); outer.add(new JScrollPane(logArea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED), cc.xywh(1, 3, 5, 1)); outer.add(panel, cc.xy(5, 5)); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); JPanel p = new JPanel(new BorderLayout()); p.add(outer.getPanel(), BorderLayout.CENTER); setContentPane(p); //setSize(500,500); pack(); setSize(500, getSize().height); }
From source file:sample.fa.ScriptRunnerApplication.java
void createGUI() { Box buttonBox = Box.createHorizontalBox(); JButton loadButton = new JButton("Load"); loadButton.addActionListener(this::loadScript); buttonBox.add(loadButton);/* ww w . ja v a 2s. co m*/ JButton saveButton = new JButton("Save"); saveButton.addActionListener(this::saveScript); buttonBox.add(saveButton); JButton executeButton = new JButton("Execute"); executeButton.addActionListener(this::executeScript); buttonBox.add(executeButton); languagesModel = new DefaultComboBoxModel(); ScriptEngineManager sem = new ScriptEngineManager(); for (ScriptEngineFactory sef : sem.getEngineFactories()) { languagesModel.addElement(sef.getScriptEngine()); } JComboBox<ScriptEngine> languagesCombo = new JComboBox<>(languagesModel); JLabel languageLabel = new JLabel(); languagesCombo.setRenderer((JList<? extends ScriptEngine> list, ScriptEngine se, int index, boolean isSelected, boolean cellHasFocus) -> { ScriptEngineFactory sef = se.getFactory(); languageLabel.setText(sef.getEngineName() + " - " + sef.getLanguageName() + " (*." + String.join(", *.", sef.getExtensions()) + ")"); return languageLabel; }); buttonBox.add(Box.createHorizontalGlue()); buttonBox.add(languagesCombo); scriptContents = new JTextArea(); scriptContents.setRows(8); scriptContents.setColumns(40); scriptResults = new JTextArea(); scriptResults.setEditable(false); scriptResults.setRows(8); scriptResults.setColumns(40); JSplitPane jsp = new JSplitPane(JSplitPane.VERTICAL_SPLIT, scriptContents, scriptResults); JFrame frame = new JFrame("Script Runner"); frame.add(buttonBox, BorderLayout.NORTH); frame.add(jsp, BorderLayout.CENTER); frame.pack(); frame.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { System.exit(0); } }); frame.setVisible(true); }
From source file:StoppUhr.java
private void initGUI() { try {// ww w. ja v a 2 s .c om AnchorLayout thisLayout = new AnchorLayout(); getContentPane().setLayout(thisLayout); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); this.setPreferredSize(new java.awt.Dimension(609, 394)); { jPanel3 = new JPanel(); GridBagLayout jPanel3Layout = new GridBagLayout(); jPanel3.setLayout(jPanel3Layout); getContentPane().add(jPanel3, new AnchorConstraint(668, 811, 978, 19, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL)); jPanel3.setPreferredSize(new java.awt.Dimension(384, 94)); { jScrollPane1 = new JScrollPane(); jPanel3.add(jScrollPane1, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jScrollPane1.setPreferredSize(new java.awt.Dimension(300, 90)); { jTextArea = new JTextArea(); jScrollPane1.setViewportView(jTextArea); jTextArea.setText(""); } } { jTextFieldStNr = new JTextField(); jPanel3.add(jTextFieldStNr, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jTextFieldStNr.setText(""); jTextFieldStNr.setPreferredSize(new java.awt.Dimension(150, 90)); jTextFieldStNr.setHorizontalAlignment(JTextField.CENTER); jTextFieldStNr.setFont(new Font(Font.DIALOG, Font.BOLD, 40)); } jPanel3Layout.rowWeights = new double[] { 0.1 }; jPanel3Layout.rowHeights = new int[] { 7 }; jPanel3Layout.columnWeights = new double[] { 0.1, 0.1 }; jPanel3Layout.columnWidths = new int[] { 7, 7 }; } { jPanel2 = new JPanel(); GridBagLayout jPanel2Layout = new GridBagLayout(); jPanel2Layout.rowWeights = new double[] { 0.1, 0.1 }; jPanel2Layout.rowHeights = new int[] { 7, 7 }; jPanel2Layout.columnWeights = new double[] { 0.1 }; jPanel2Layout.columnWidths = new int[] { 7 }; jPanel2.setLayout(jPanel2Layout); getContentPane().add(jPanel2, new AnchorConstraint(47, 821, 721, 27, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL)); jPanel2.setPreferredSize(new java.awt.Dimension(363, 178)); { uhrzeitAusgabe = new JLabel(); jPanel2.add(uhrzeitAusgabe, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); uhrzeitAusgabe.setText("00:00:00"); uhrzeitAusgabe.setFont(new Font(Font.DIALOG, Font.BOLD, uhrFontSize)); } { stoppuhrAusgabe = new JLabel(); jPanel2.add(stoppuhrAusgabe, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); stoppuhrAusgabe.setText("00:00:00"); stoppuhrAusgabe.setFont(new Font(Font.DIALOG, Font.BOLD, uhrFontSize)); } } { jPanel1 = new JPanel(); GridBagLayout jPanel1Layout = new GridBagLayout(); getContentPane().add(jPanel1, new AnchorConstraint(48, 987, 954, 820, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL)); jPanel1Layout.rowWeights = new double[] { 0.1, 0.1, 0.1, 1.0, 0.1 }; jPanel1Layout.rowHeights = new int[] { 1, 1, 1, 1, 1 }; jPanel1Layout.columnWeights = new double[] { 0.1 }; jPanel1Layout.columnWidths = new int[] { 7 }; jPanel1.setLayout(jPanel1Layout); jPanel1.setPreferredSize(new java.awt.Dimension(100, 330)); { startButton = new JButton(); jPanel1.add(startButton, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); startButton.setPreferredSize(new java.awt.Dimension(90, 30)); startButton.setText("Start"); } { resetButton = new JButton(); jPanel1.add(resetButton, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); resetButton.setText("Reset"); resetButton.setPreferredSize(new java.awt.Dimension(90, 30)); } { jPanel4 = new JPanel(); GridBagLayout jPanel4Layout = new GridBagLayout(); jPanel1.add(jPanel4, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jPanel4.setPreferredSize(new java.awt.Dimension(51, 81)); jPanel4Layout.rowWeights = new double[] { 0.1, 0.1, 0.1 }; jPanel4Layout.rowHeights = new int[] { 7, 7, 7 }; jPanel4Layout.columnWeights = new double[] { 0.1 }; jPanel4Layout.columnWidths = new int[] { 7 }; jPanel4.setLayout(jPanel4Layout); { plusButton = new JButton(); jPanel4.add(plusButton, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); plusButton.setText("+"); plusButton.setPreferredSize(new java.awt.Dimension(50, 30)); } { minusButton = new JButton(); jPanel4.add(minusButton, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); minusButton.setText("-"); minusButton.setPreferredSize(new java.awt.Dimension(50, 30)); } { jLabelFontSize = new JLabel(); jPanel4.add(jLabelFontSize, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabelFontSize.setFont(new Font(Font.DIALOG, Font.PLAIN, 10)); jLabelFontSize.setText("Font Size"); } } } this.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent evt) { thisWindowClosing(evt); } }); startButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { startButtonListener(evt); } }); resetButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { resetButtonListener(evt); } }); jTextFieldStNr.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { try { stNrFieldListener(evt); } catch (IOException e) { e.printStackTrace(); } } }); plusButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { plusButtonListener(evt); } }); minusButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { minusButtonListener(evt); } }); pack(); this.setSize(609, 394); } catch (Exception e) { //add your error handling code here e.printStackTrace(); } }
From source file:WindowEventDemo.java
private void addComponentsToPane() { display = new JTextArea(); display.setEditable(false);// w w w . jav a 2s . c o m JScrollPane scrollPane = new JScrollPane(display); scrollPane.setPreferredSize(new Dimension(500, 450)); getContentPane().add(scrollPane, BorderLayout.CENTER); addWindowListener(this); addWindowFocusListener(this); addWindowStateListener(this); checkWM(); }
From source file:gui.QTLResultsPanel.java
/** QTLResultsPanel(). * /*from ww w .j ava2s . com*/ * @param qtlResult = the QTL results to show. * @param order = the ordered result data this QTL was created from. */ public QTLResultsPanel(QTLResult qtlResult, OrderedResult order) { this.qtlResult = qtlResult; this.order = order; // Trait listbox traitModel = new DefaultListModel<Trait>(); for (Trait trait : qtlResult.getTraits()) { traitModel.addElement(trait); } traitList = new JList<Trait>(traitModel); traitList.addListSelectionListener(this); traitList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); JScrollPane sp1 = new JScrollPane(traitList); sp1.setPreferredSize(new Dimension(125, 50)); // Details text box details = new JTextArea(); details.setFont(new Font("Monospaced", Font.PLAIN, 11)); details.setMargin(new Insets(2, 5, 2, 5)); details.setEditable(false); details.setTabSize(6); JScrollPane sp4; if (AppFrame.tpmmode == AppFrame.TPMMODE_QTL) { simpleDetails = new JScrollPane(); simpleDetails.setFont(new Font("Monospaced", Font.PLAIN, 11)); simplesplit = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); simpleright = new JTextArea(); simpleright.setFont(new Font("Monospaced", Font.PLAIN, 11)); simpleright.setMargin(new Insets(2, 5, 2, 5)); simpleright.setEditable(false); simpleright.setTabSize(6); simplesplit.setRightComponent(new JScrollPane(simpleright)); simplesplit.setLeftComponent(simpleDetails); sp4 = new JScrollPane(simplesplit); } else { // TPM MODE NONSNP simpleright = new JTextArea(); simpleright.setFont(new Font("Monospaced", Font.PLAIN, 11)); simpleright.setMargin(new Insets(2, 5, 2, 5)); simpleright.setEditable(false); sp4 = new JScrollPane(simpleright); } lodDetails = new JTextArea(); lodDetails.setFont(new Font("Monospaced", Font.PLAIN, 11)); lodDetails.setMargin(new Insets(2, 5, 2, 5)); lodDetails.setEditable(false); lodDetails.setTabSize(6); JScrollPane sp3 = new JScrollPane(lodDetails); JTabbedPane tabs = new JTabbedPane(); JScrollPane sp2 = new JScrollPane(details); tabs.add(sp2, "Full Model"); tabs.add(sp4, "Simple Model"); tabs.add(sp3, "LOD Details"); // The splitpane splits = new JSplitPane(JSplitPane.VERTICAL_SPLIT); splits.setTopComponent(new JPanel()); splits.setBottomComponent(tabs); splits.setResizeWeight(0.5); // pane2 JSplitPane splits2 = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); splits2.setLeftComponent(sp1); splits2.setRightComponent(splits); setLayout(new BorderLayout()); add(new GradientPanel("QTL Analysis Results"), BorderLayout.NORTH); // add(sp1, BorderLayout.WEST); // add(splits); add(splits2); add(toolbar = new QTLResultsToolBar(this), BorderLayout.EAST); }
From source file:net.sf.profiler4j.console.util.task.LongTaskExecutorDialog.java
/** * This method initializes statusTextArea * //w w w .j a v a2s.c om * @return javax.swing.JTextArea */ private JTextArea getStatusTextArea() { if (statusTextArea == null) { statusTextArea = new JTextArea(); statusTextArea.setBackground(java.awt.SystemColor.info); statusTextArea.setFont(new java.awt.Font("Monospaced", java.awt.Font.PLAIN, 11)); statusTextArea.setEditable(false); } return statusTextArea; }
From source file:TextFieldDemo.java
/** * This method is called from within the constructor to initialize the form. *//*from w w w .j a va2s . com*/ private void initComponents() { entry = new JTextField(); textArea = new JTextArea(); status = new JLabel(); jLabel1 = new JLabel(); setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); setTitle("TextFieldDemo"); textArea.setColumns(20); textArea.setLineWrap(true); textArea.setRows(5); textArea.setWrapStyleWord(true); textArea.setEditable(false); jScrollPane1 = new JScrollPane(textArea); jLabel1.setText("Enter text to search:"); 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 container gap to the sequential group h1 h1.addContainerGap(); // Add a scroll pane and a label to the parallel group h2 h2.addComponent(jScrollPane1, GroupLayout.Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 450, Short.MAX_VALUE); h2.addComponent(status, GroupLayout.Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 450, Short.MAX_VALUE); // Create a sequential group h3 SequentialGroup h3 = layout.createSequentialGroup(); h3.addComponent(jLabel1); h3.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED); h3.addComponent(entry, GroupLayout.DEFAULT_SIZE, 321, Short.MAX_VALUE); // Add the group h3 to the group h2 h2.addGroup(h3); // Add the group h2 to the group h1 h1.addGroup(h2); h1.addContainerGap(); // Add the group h1 to the hGroup hGroup.addGroup(GroupLayout.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 v1 SequentialGroup v1 = layout.createSequentialGroup(); // Add a container gap to the sequential group v1 v1.addContainerGap(); // Create a parallel group v2 ParallelGroup v2 = layout.createParallelGroup(GroupLayout.Alignment.BASELINE); v2.addComponent(jLabel1); v2.addComponent(entry, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE); // Add the group v2 tp the group v1 v1.addGroup(v2); v1.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED); v1.addComponent(jScrollPane1, GroupLayout.DEFAULT_SIZE, 233, Short.MAX_VALUE); v1.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED); v1.addComponent(status); v1.addContainerGap(); // Add the group v1 to the group vGroup vGroup.addGroup(v1); // Create the vertical group layout.setVerticalGroup(vGroup); pack(); }
From source file:ExtendedDnDDemo.java
private JPanel createArea() { String text = "This is the text that I want to show."; JTextArea area = new JTextArea(); area.setText(text);/*from w w w . j av a 2 s. c o m*/ area.setDragEnabled(true); JScrollPane scrollPane = new JScrollPane(area); scrollPane.setPreferredSize(new Dimension(400, 100)); JPanel panel = new JPanel(new BorderLayout()); panel.add(scrollPane, BorderLayout.CENTER); panel.setBorder(BorderFactory.createTitledBorder("Text Area")); return panel; }