List of usage examples for javax.swing JTextArea JTextArea
public JTextArea()
From source file:WindowEventDemo.java
public WindowEventDemo() { super(new BorderLayout()); display = new JTextArea(); display.setEditable(false);//from w ww .ja v a 2 s . co m JScrollPane scrollPane = new JScrollPane(display); scrollPane.setPreferredSize(new Dimension(500, 450)); add(scrollPane, BorderLayout.CENTER); frame.addWindowListener(this); frame.addWindowFocusListener(this); frame.addWindowStateListener(this); checkWM(); }
From source file:DataExchangeTest.java
public DataExchangeFrame() { setTitle("DataExchangeTest"); setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT); // construct a File menu JMenuBar mbar = new JMenuBar(); setJMenuBar(mbar);/*from ww w. jav a 2 s. c om*/ JMenu fileMenu = new JMenu("File"); mbar.add(fileMenu); // add Connect and Exit menu items JMenuItem connectItem = new JMenuItem("Connect"); connectItem.addActionListener(new ConnectAction()); fileMenu.add(connectItem); // The Exit item exits the program JMenuItem exitItem = new JMenuItem("Exit"); exitItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { System.exit(0); } }); fileMenu.add(exitItem); textArea = new JTextArea(); add(new JScrollPane(textArea), BorderLayout.CENTER); }
From source file:MailTest.java
public MailTestFrame() { setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT); setTitle("MailTest"); setLayout(new GridBagLayout()); // we use the GBC convenience class of Core Java Volume 1 Chapter 9 add(new JLabel("From:"), new GBC(0, 0).setFill(GBC.HORIZONTAL)); from = new JTextField(20); add(from, new GBC(1, 0).setFill(GBC.HORIZONTAL).setWeight(100, 0)); add(new JLabel("To:"), new GBC(0, 1).setFill(GBC.HORIZONTAL)); to = new JTextField(20); add(to, new GBC(1, 1).setFill(GBC.HORIZONTAL).setWeight(100, 0)); add(new JLabel("SMTP server:"), new GBC(0, 2).setFill(GBC.HORIZONTAL)); smtpServer = new JTextField(20); add(smtpServer, new GBC(1, 2).setFill(GBC.HORIZONTAL).setWeight(100, 0)); message = new JTextArea(); add(new JScrollPane(message), new GBC(0, 3, 2, 1).setFill(GBC.BOTH).setWeight(100, 100)); comm = new JTextArea(); add(new JScrollPane(comm), new GBC(0, 4, 2, 1).setFill(GBC.BOTH).setWeight(100, 100)); JPanel buttonPanel = new JPanel(); add(buttonPanel, new GBC(0, 5, 2, 1)); JButton sendButton = new JButton("Send"); buttonPanel.add(sendButton);/*from w w w .jav a2 s . c o m*/ sendButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { new SwingWorker<Void, Void>() { protected Void doInBackground() throws Exception { comm.setText(""); sendMail(); return null; } }.execute(); } }); }
From source file:BoxLayoutPane.java
public BoxLayoutPane() { // Use a BorderLayout layout manager to arrange various Box components this.setLayout(new BorderLayout()); // Give the entire panel a margin by adding an empty border // We could also do this by overriding getInsets() this.setBorder(new EmptyBorder(10, 10, 10, 10)); // Add a plain row of buttons along the top of the pane Box row = Box.createHorizontalBox(); for (int i = 0; i < 4; i++) { JButton b = new JButton("B" + i); b.setFont(new Font("serif", Font.BOLD, 12 + i * 2)); row.add(b);// w ww .ja v a2s. c o m } this.add(row, BorderLayout.NORTH); // Add a plain column of buttons along the right edge // Use BoxLayout with a different kind of Swing container // Give the column a border: can't do this with the Box class JPanel col = new JPanel(); col.setLayout(new BoxLayout(col, BoxLayout.Y_AXIS)); col.setBorder(new TitledBorder(new EtchedBorder(), "Column")); for (int i = 0; i < 4; i++) { JButton b = new JButton("Button " + i); b.setFont(new Font("sanserif", Font.BOLD, 10 + i * 2)); col.add(b); } this.add(col, BorderLayout.EAST); // Add column to right of panel // Add a button box along the bottom of the panel. // Use "Glue" to space the buttons evenly Box buttonbox = Box.createHorizontalBox(); buttonbox.add(Box.createHorizontalGlue()); // stretchy space buttonbox.add(new JButton("Okay")); buttonbox.add(Box.createHorizontalGlue()); // stretchy space buttonbox.add(new JButton("Cancel")); buttonbox.add(Box.createHorizontalGlue()); // stretchy space buttonbox.add(new JButton("Help")); buttonbox.add(Box.createHorizontalGlue()); // stretchy space this.add(buttonbox, BorderLayout.SOUTH); // Create a component to display in the center of the panel JTextArea textarea = new JTextArea(); textarea.setText("This component has 12-pixel margins on left and top" + " and has 72-pixel margins on right and bottom."); textarea.setLineWrap(true); textarea.setWrapStyleWord(true); // Use Box objects to give the JTextArea an unusual spacing // First, create a column with 3 kids. The first and last kids // are rigid spaces. The middle kid is the text area Box fixedcol = Box.createVerticalBox(); fixedcol.add(Box.createVerticalStrut(12)); // 12 rigid pixels fixedcol.add(textarea); // Component fills in the rest fixedcol.add(Box.createVerticalStrut(72)); // 72 rigid pixels // Now create a row. Give it rigid spaces on the left and right, // and put the column from above in the middle. Box fixedrow = Box.createHorizontalBox(); fixedrow.add(Box.createHorizontalStrut(12)); fixedrow.add(fixedcol); fixedrow.add(Box.createHorizontalStrut(72)); // Now add the JTextArea in the column in the row to the panel this.add(fixedrow, BorderLayout.CENTER); }
From source file:DocumentEventDemo.java
public DocumentEventDemo() { super(new GridBagLayout()); GridBagLayout gridbag = (GridBagLayout) getLayout(); GridBagConstraints c = new GridBagConstraints(); JButton button = new JButton("Clear"); button.addActionListener(this); textField = new JTextField(20); textField.addActionListener(new MyTextActionListener()); textField.getDocument().addDocumentListener(new MyDocumentListener()); textField.getDocument().putProperty("name", "Text Field"); textArea = new JTextArea(); textArea.getDocument().addDocumentListener(new MyDocumentListener()); textArea.getDocument().putProperty("name", "Text Area"); JScrollPane scrollPane = new JScrollPane(textArea); scrollPane.setPreferredSize(new Dimension(200, 75)); displayArea = new JTextArea(); displayArea.setEditable(false);//w ww . jav a 2 s .co m JScrollPane displayScrollPane = new JScrollPane(displayArea); displayScrollPane.setPreferredSize(new Dimension(200, 75)); c.gridx = 0; c.gridy = 0; c.weightx = 1.0; c.fill = GridBagConstraints.HORIZONTAL; gridbag.setConstraints(textField, c); add(textField); c.gridx = 0; c.gridy = 1; c.weightx = 0.0; c.gridheight = 2; c.fill = GridBagConstraints.BOTH; gridbag.setConstraints(scrollPane, c); add(scrollPane); c.gridx = 1; c.gridy = 0; c.weightx = 1.0; c.weighty = 1.0; gridbag.setConstraints(displayScrollPane, c); add(displayScrollPane); c.gridx = 1; c.gridy = 2; c.weightx = 0.0; c.gridheight = 1; c.weighty = 0.0; c.fill = GridBagConstraints.HORIZONTAL; gridbag.setConstraints(button, c); add(button); setPreferredSize(new Dimension(450, 250)); setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); }
From source file:utybo.easypastebin.windows.MainWindow.java
/** * Creates the window//from w w w.j av a 2 s . c o m */ @SuppressWarnings({ "rawtypes", "unchecked" }) public MainWindow() { EasyPastebin.LOGGER.log("Initializing the window", SinkJLevel.INFO); setTitle("EasyPastebin"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setBounds(100, 100, 664, 431); contentPane = new JPanel(); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); contentPane.setLayout(new BorderLayout(0, 0)); setContentPane(contentPane); JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP); contentPane.add(tabbedPane, BorderLayout.CENTER); JPanel main = new JPanel(); tabbedPane.addTab("EasyPastebin", null, main, null); main.setLayout(null); JScrollPane scrollPane = new JScrollPane(); scrollPane.setBounds(62, 39, 312, 132); main.add(scrollPane); pasteContent = new JTextArea(); pasteContent.setFont(new Font("Monospaced", Font.PLAIN, 11)); pasteContent.setWrapStyleWord(true); pasteContent.setLineWrap(true); pasteContent.setToolTipText("Put your paste here!"); scrollPane.setViewportView(pasteContent); JLabel titleLabel = new JLabel("Title :"); titleLabel.setFont(new Font("Tahoma", Font.PLAIN, 12)); titleLabel.setBounds(10, 11, 42, 21); main.add(titleLabel); pasteTitle = new JTextField(); pasteTitle.setBounds(62, 12, 312, 20); main.add(pasteTitle); pasteTitle.setColumns(10); JLabel lblPaste = new JLabel("Paste :"); lblPaste.setForeground(Color.RED); lblPaste.setFont(new Font("Tahoma", Font.PLAIN, 12)); lblPaste.setBounds(10, 85, 53, 21); main.add(lblPaste); pasteExpireDate = new JComboBox(); pasteExpireDate.setFont(new Font("Tahoma", Font.PLAIN, 12)); pasteExpireDate.setModel(new DefaultComboBoxModel(EnumExpireDate.values())); pasteExpireDate.setBounds(468, 12, 155, 21); main.add(pasteExpireDate); JLabel lblExpireDate = new JLabel("Expire Date :"); lblExpireDate.setFont(new Font("Tahoma", Font.PLAIN, 12)); lblExpireDate.setBounds(384, 14, 81, 14); main.add(lblExpireDate); JLabel lblfieldsInRed = new JLabel("(Fields in red are required)"); lblfieldsInRed.setBounds(72, 182, 302, 14); main.add(lblfieldsInRed); btnSubmit = new JButton("Submit!"); btnSubmit.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { EasyPastebin.LOGGER.log("Starting Submit script", SinkJLevel.INFO); btnSubmit.setEnabled(false); btnSubmit.setText("Please wait..."); boolean success = true; String paste = pasteContent.getText(); String title = pasteTitle.getText(); EnumExpireDate expireDate = (EnumExpireDate) pasteExpireDate.getSelectedItem(); if (paste.equals("") || paste.equals(" ") || paste.equals(null)) { pastebinUrl.setText("ERROR"); JOptionPane.showMessageDialog(null, "You cannot send empty pastes!", "Error while processing paste", JOptionPane.ERROR_MESSAGE); } else { try { EasyPastebin.LOGGER.log("Setting options", SinkJLevel.INFO); Map map = new HashMap<String, String>(); map.put("api_dev_key", HttpHelper.API_KEY); map.put("api_option", "paste"); map.put("api_paste_code", paste); if (!(expireDate.equals(null) || expireDate.equals(EnumExpireDate.NEVER))) map.put("api_paste_expire_date", expireDate.getRawName()); if (!(title.equals("") || title.equals(" ") || title.equals(null))) map.put("api_paste_name", title); EasyPastebin.LOGGER.log("Sending paste", SinkJLevel.INFO); String actionResult = HttpHelper.sendPost("http://pastebin.com/api/api_post.php", map) .asString(); EasyPastebin.LOGGER.log("Paste sent, checking output", SinkJLevel.INFO); // Exception handlers if (actionResult.equals("Bad API request, invalid api_option")) { success = false; EasyPastebin.LOGGER.log( "The output is an error message : " + actionResult + ". Submit script failed!", SinkJLevel.ERROR); JOptionPane.showMessageDialog(null, "Error while processing paste. Incorrect Pastebin option!", "Error", JOptionPane.ERROR_MESSAGE); } if (actionResult.equals("Bad API request, invalid api_dev_key")) { success = false; EasyPastebin.LOGGER.log( "The output is an error message : " + actionResult + ". Submit script failed!", SinkJLevel.ERROR); JOptionPane.showMessageDialog(null, "Error while processing paste. Incorrect dev key! Try again with a more recent version!", "Error", JOptionPane.ERROR_MESSAGE); } if (actionResult.equals("Bad API request, IP blocked")) { success = false; EasyPastebin.LOGGER.log( "The output is an error message : " + actionResult + ". Submit script failed!", SinkJLevel.ERROR); JOptionPane.showMessageDialog(null, "Error while processing paste. Your IP is blocked!", "Error", JOptionPane.ERROR_MESSAGE); } if (actionResult.equals( "Bad API request, maximum number of 25 unlisted pastes for your free account")) { success = false; EasyPastebin.LOGGER.log( "The output is an error message : " + actionResult + ". Submit script failed!", SinkJLevel.ERROR); } if (actionResult.equals( "Bad API request, maximum number of 10 private pastes for your free account")) { success = false; EasyPastebin.LOGGER.log( "The output is an error message : " + actionResult + ". Submit script failed!", SinkJLevel.ERROR); } if (actionResult.equals("Bad API request, api_paste_code was empty")) { success = false; EasyPastebin.LOGGER.log( "The output is an error message : " + actionResult + ". Submit script failed!", SinkJLevel.ERROR); } if (actionResult.equals("Bad API request, maximum paste file size exceeded")) { success = false; EasyPastebin.LOGGER.log( "The output is an error message : " + actionResult + ". Submit script failed!", SinkJLevel.ERROR); JOptionPane.showMessageDialog(null, "Error while processing paste. Your paste is too big!", "Error", JOptionPane.ERROR_MESSAGE); } if (actionResult.equals("Bad API request, invalid api_expire_date")) { success = false; EasyPastebin.LOGGER.log( "The output is an error message : " + actionResult + ". Submit script failed!", SinkJLevel.ERROR); JOptionPane.showMessageDialog(null, "Error while processing paste. Invalid expire date!", "Error", JOptionPane.ERROR_MESSAGE); } if (actionResult.equals("Bad API request, invalid api_paste_private")) { success = false; EasyPastebin.LOGGER.log( "The output is an error message : " + actionResult + ". Submit script failed!", SinkJLevel.ERROR); JOptionPane.showMessageDialog(null, "Error while processing paste. Invalid privacy value!", "Error", JOptionPane.ERROR_MESSAGE); } if (actionResult.equals("Bad API request, invalid api_paste_format")) { success = false; EasyPastebin.LOGGER.log( "The output is an error message : " + actionResult + ". Submit script failed!", SinkJLevel.ERROR); JOptionPane.showMessageDialog(null, "Error while processing paste. Invalid format!", "Error", JOptionPane.ERROR_MESSAGE); } // END // Starting display stuff if (success == false) { EasyPastebin.LOGGER.log("Submit script failed : success == false", SinkJLevel.ERROR); pastebinUrl.setText("ERROR"); } if (success == true) { EasyPastebin.LOGGER.log("Paste sent! Starting display script!", SinkJLevel.INFO); pastebinUrl.setText(actionResult); JOptionPane.showMessageDialog(null, "Paste successfully sent!", "Done!", JOptionPane.INFORMATION_MESSAGE); EasyPastebin.LOGGER.log("Display script finished! Paste URL is : " + actionResult, SinkJLevel.INFO); } } catch (ClientProtocolException e) { EasyPastebin.LOGGER.log("Unexpected error! " + e, SinkJLevel.ERROR); JOptionPane.showMessageDialog(null, "Error while processing paste : " + e, "Error", JOptionPane.ERROR_MESSAGE); e.printStackTrace(); } catch (IOException e) { EasyPastebin.LOGGER.log("Unexpected error! " + e, SinkJLevel.ERROR); JOptionPane.showMessageDialog(null, "Error while processing paste : " + e, "Error", JOptionPane.ERROR_MESSAGE); e.printStackTrace(); } catch (MissingParamException e) { EasyPastebin.LOGGER.log("Unexpected error! " + e, SinkJLevel.ERROR); JOptionPane.showMessageDialog(null, "Error while processing paste : " + e + "! This is a severe programming error! Try again with a more recent version!", "Error", JOptionPane.ERROR_MESSAGE); e.printStackTrace(); } } EasyPastebin.LOGGER.log("Re-enabling the Submit button ", SinkJLevel.INFO); btnSubmit.setEnabled(true); btnSubmit.setText("Submit another paste!"); EasyPastebin.LOGGER.log("Finished submit script! Success : " + success, SinkJLevel.INFO); } }); btnSubmit.setBounds(386, 45, 237, 44); main.add(btnSubmit); pastebinUrl = new JTextField(); pastebinUrl.setText("The paste's URL will be shown here!"); pastebinUrl.setEditable(false); pastebinUrl.setBounds(384, 198, 239, 32); main.add(pastebinUrl); pastebinUrl.setColumns(10); JPanel about = new JPanel(); tabbedPane.addTab("About", null, about, null); JLabel label = new JLabel("EasyPastebin"); label.setBounds(12, 12, 623, 39); label.setHorizontalAlignment(SwingConstants.CENTER); label.setFont(new Font("Dialog", Font.PLAIN, 25)); JLabel lblTheEasiestWay = new JLabel("The easiest way to use Pastebin.com"); lblTheEasiestWay.setBounds(12, 63, 623, 32); lblTheEasiestWay.setFont(new Font("Dialog", Font.PLAIN, 16)); lblTheEasiestWay.setHorizontalAlignment(SwingConstants.CENTER); about.setLayout(null); about.add(label); about.add(lblTheEasiestWay); JButton btnForkM = new JButton("Fork me on Github!"); btnForkM.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { goToUrl("https://github.com/utybo/EasyPastebin"); } }); btnForkM.setBounds(12, 117, 623, 25); about.add(btnForkM); JButton btnCheckOutUtybos = new JButton("Check out utybo's projects!"); btnCheckOutUtybos.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { goToUrl("http://utybo.github.io/"); } }); btnCheckOutUtybos.setBounds(12, 154, 623, 25); about.add(btnCheckOutUtybos); JButton btnGoToPastebincom = new JButton("Go to Pastebin.com!"); btnGoToPastebincom.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { goToUrl("http://www.pastebin.com"); } }); btnGoToPastebincom.setBounds(12, 191, 623, 25); about.add(btnGoToPastebincom); JLabel lblcUtybo = new JLabel( "This soft was made by utybo. It uses Apache's libraries for the interaction with Pastebin's API"); lblcUtybo.setFont(new Font("Dialog", Font.PLAIN, 10)); lblcUtybo.setHorizontalAlignment(SwingConstants.CENTER); lblcUtybo.setBounds(12, 324, 623, 15); about.add(lblcUtybo); JLabel lblClickMeTo = new JLabel("Click me to go to Apache's licence official website"); lblClickMeTo.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { goToUrl("http://www.apache.org/licenses/LICENSE-2.0"); } }); lblClickMeTo.setHorizontalAlignment(SwingConstants.CENTER); lblClickMeTo.setFont(new Font("Dialog", Font.PLAIN, 10)); lblClickMeTo.setBounds(12, 342, 623, 15); about.add(lblClickMeTo); setVisible(true); EasyPastebin.LOGGER.log("Done!", SinkJLevel.INFO); }
From source file:gtu._work.ui.JUnitMakerUI.java
private void initGUI() { try {/* w w w .jav a 2 s .com*/ GroupLayout thisLayout = new GroupLayout((JComponent) getContentPane()); getContentPane().setLayout(thisLayout); this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); { jTextField1 = new JTextField(); } { jLabel1 = new JLabel(); jLabel1.setText("Class"); } { jTextField2 = new JTextField(); } { jLabel2 = new JLabel(); jLabel2.setText("Package"); } { jTextField3 = new JTextField(); } { jLabel3 = new JLabel(); jLabel3.setText("fieldName"); } { jTextArea1 = new JTextArea(); } { jButton1 = new JButton(); jButton1.setText("execute"); jButton1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { jButton1ActionPerformed(evt); } }); } { jButton3 = new JButton(); jButton3.setText("validate"); jButton3.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { jButton3ActionPerformed(evt); } }); } { jTextField4 = new JTextField(); } { jLabel4 = new JLabel(); jLabel4.setText("dest"); } { jButton2 = new JButton(); jButton2.setText("choice"); jButton2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { jButton2ActionPerformed(evt); } }); } thisLayout.setVerticalGroup(thisLayout.createSequentialGroup().addContainerGap() .addGroup(thisLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(jTextField1, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 25, GroupLayout.PREFERRED_SIZE) .addComponent(jLabel1, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup(thisLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(jTextField2, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 25, GroupLayout.PREFERRED_SIZE) .addComponent(jLabel2, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup(thisLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(jTextField3, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 25, GroupLayout.PREFERRED_SIZE) .addComponent(jLabel3, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup(thisLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(jTextField4, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 25, GroupLayout.PREFERRED_SIZE) .addComponent(jLabel4, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(jButton2, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jTextArea1, GroupLayout.PREFERRED_SIZE, 164, GroupLayout.PREFERRED_SIZE) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup(thisLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(jButton1, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE) .addGroup(GroupLayout.Alignment.LEADING, thisLayout.createSequentialGroup() .addComponent(jButton3, GroupLayout.PREFERRED_SIZE, 24, GroupLayout.PREFERRED_SIZE) .addGap(0, 0, Short.MAX_VALUE))) .addGap(6)); thisLayout.setHorizontalGroup(thisLayout.createSequentialGroup().addContainerGap().addGroup(thisLayout .createParallelGroup() .addGroup(thisLayout.createSequentialGroup().addGroup(thisLayout.createParallelGroup() .addComponent(jLabel4, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 85, GroupLayout.PREFERRED_SIZE) .addComponent(jLabel3, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 85, GroupLayout.PREFERRED_SIZE) .addComponent(jLabel2, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 85, GroupLayout.PREFERRED_SIZE) .addComponent(jLabel1, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 85, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup(thisLayout.createParallelGroup() .addGroup(GroupLayout.Alignment.LEADING, thisLayout.createSequentialGroup() .addComponent(jTextField4, GroupLayout.PREFERRED_SIZE, 200, GroupLayout.PREFERRED_SIZE) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButton2, GroupLayout.PREFERRED_SIZE, 73, GroupLayout.PREFERRED_SIZE)) .addGroup(thisLayout.createSequentialGroup().addComponent(jTextField3, GroupLayout.PREFERRED_SIZE, 279, GroupLayout.PREFERRED_SIZE)) .addGroup(thisLayout.createSequentialGroup().addComponent(jTextField2, GroupLayout.PREFERRED_SIZE, 279, GroupLayout.PREFERRED_SIZE)) .addGroup(thisLayout.createSequentialGroup().addComponent(jTextField1, GroupLayout.PREFERRED_SIZE, 279, GroupLayout.PREFERRED_SIZE))) .addGap(0, 0, Short.MAX_VALUE)) .addGroup( thisLayout.createSequentialGroup() .addComponent(jTextArea1, GroupLayout.PREFERRED_SIZE, 376, GroupLayout.PREFERRED_SIZE) .addGap(0, 0, Short.MAX_VALUE)) .addGroup(GroupLayout.Alignment.LEADING, thisLayout.createSequentialGroup().addGap(78) .addComponent(jButton3, GroupLayout.PREFERRED_SIZE, 82, GroupLayout.PREFERRED_SIZE) .addGap(73) .addComponent(jButton1, GroupLayout.PREFERRED_SIZE, 82, GroupLayout.PREFERRED_SIZE) .addGap(0, 61, Short.MAX_VALUE))) .addContainerGap(17, 17)); this.setSize(421, 380); } catch (Exception e) { e.printStackTrace(); } }
From source file:com.fisher.mainFrame.java
private void initComponents() { // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents // Generated using JFormDesigner Evaluation license - nick xu dialogPane = new JPanel(); contentPanel = new JPanel(); scrollPaneLogArea = new JScrollPane(); logArea = new JTextArea(); buttonBar = new JPanel(); startButton = new JButton(); stopButton = new JButton(); //======== this ======== setTitle("Fish Transform Trading"); Container contentPane = getContentPane(); contentPane.setLayout(new BorderLayout()); //======== dialogPane ======== {//from w ww . j ava 2 s .c om dialogPane.setBorder(new EmptyBorder(12, 12, 12, 12)); dialogPane.setPreferredSize(new Dimension(758, 900)); // JFormDesigner evaluation mark dialogPane.setBorder(new javax.swing.border.CompoundBorder( new javax.swing.border.TitledBorder(new javax.swing.border.EmptyBorder(0, 0, 0, 0), "JFormDesigner Evaluation", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.BOTTOM, new java.awt.Font("Dialog", java.awt.Font.BOLD, 12), java.awt.Color.red), dialogPane.getBorder())); dialogPane.addPropertyChangeListener(new java.beans.PropertyChangeListener() { public void propertyChange(java.beans.PropertyChangeEvent e) { if ("border".equals(e.getPropertyName())) throw new RuntimeException(); } }); dialogPane.setLayout(new BorderLayout()); //======== contentPanel ======== { //======== scrollPaneLogArea ======== { scrollPaneLogArea.setViewportView(logArea); } GroupLayout contentPanelLayout = new GroupLayout(contentPanel); contentPanel.setLayout(contentPanelLayout); contentPanelLayout.setHorizontalGroup(contentPanelLayout.createParallelGroup() .addComponent(scrollPaneLogArea, GroupLayout.DEFAULT_SIZE, 734, Short.MAX_VALUE)); contentPanelLayout .setVerticalGroup(contentPanelLayout.createParallelGroup() .addGroup(contentPanelLayout .createSequentialGroup().addComponent(scrollPaneLogArea, GroupLayout.PREFERRED_SIZE, 225, GroupLayout.PREFERRED_SIZE) .addGap(0, 476, Short.MAX_VALUE))); } dialogPane.add(contentPanel, BorderLayout.CENTER); //======== buttonBar ======== { buttonBar.setBorder(new EmptyBorder(12, 0, 0, 0)); buttonBar.setLayout(new GridBagLayout()); ((GridBagLayout) buttonBar.getLayout()).columnWidths = new int[] { 0, 85, 80 }; ((GridBagLayout) buttonBar.getLayout()).columnWeights = new double[] { 1.0, 0.0, 0.0 }; //---- startButton ---- startButton.setText("Start"); startButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { startButtonActionPerformed(e); } }); buttonBar.add(startButton, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 5), 0, 0)); //---- stopButton ---- stopButton.setText("Stop"); stopButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { stopButtonActionPerformed(e); } }); buttonBar.add(stopButton, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); } dialogPane.add(buttonBar, BorderLayout.SOUTH); } contentPane.add(dialogPane, BorderLayout.CENTER); pack(); setLocationRelativeTo(getOwner()); // JFormDesigner - End of component initialization //GEN-END:initComponents }
From source file:i18nplugin.TranslatorEditor.java
private void createGui() { setLayout(new FormLayout("fill:min:grow", "fill:min:grow, pref")); CellConstraints cc = new CellConstraints(); // Top//from w w w. jav a 2 s . c o m PanelBuilder topPanel = new PanelBuilder(new FormLayout("fill:10dlu:grow", "pref, 5dlu, fill:pref:grow")); topPanel.setBorder(Borders.DLU4_BORDER); topPanel.addSeparator(mLocalizer.msg("original", "Original text"), cc.xy(1, 1)); mOriginal = new JTextArea(); mOriginal.setWrapStyleWord(false); mOriginal.setEditable(false); topPanel.add(new JScrollPane(mOriginal), cc.xy(1, 3)); // Bottom PanelBuilder bottomPanel = new PanelBuilder( new FormLayout("fill:10dlu:grow", "pref, 5dlu, fill:pref:grow")); bottomPanel.setBorder(Borders.DLU4_BORDER); bottomPanel.addSeparator(mLocalizer.msg("translation", "Translation"), cc.xy(1, 1)); mTranslation = new JTextArea(); mTranslation.getDocument().addDocumentListener(new DocumentListener() { public void changedUpdate(DocumentEvent e) { updateState(); } public void insertUpdate(DocumentEvent e) { updateState(); } public void removeUpdate(DocumentEvent e) { updateState(); } }); mOriginal.setBackground(mTranslation.getBackground()); mOriginal.setForeground(mTranslation.getForeground()); bottomPanel.add(new JScrollPane(mTranslation), cc.xy(1, 3)); // Splitpane final JSplitPane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT); split.setBorder(null); split.setTopComponent(topPanel.getPanel()); split.setBottomComponent(bottomPanel.getPanel()); SwingUtilities.invokeLater(new Runnable() { public void run() { split.setDividerLocation(0.5); } }); add(split, cc.xy(1, 1)); // translation state PanelBuilder panel = new PanelBuilder(new FormLayout("pref, 2dlu, fill:10dlu:grow", "pref, 3dlu, pref")); panel.setBorder(Borders.DLU4_BORDER); panel.addSeparator(mLocalizer.msg("state", "State"), cc.xyw(1, 1, 3)); mIcon = new JLabel(); panel.add(mIcon, cc.xy(1, 3)); mState = new JLabel("-"); panel.add(mState, cc.xy(3, 3)); add(panel.getPanel(), cc.xy(1, 2)); }
From source file:gtu._work.etc.SqlReplacerUI.java
private void initGUI() { try {/*from w w w .ja v a 2s .c o m*/ BorderLayout thisLayout = new BorderLayout(); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); getContentPane().setLayout(thisLayout); { jTabbedPane1 = new JTabbedPane(); getContentPane().add(jTabbedPane1, BorderLayout.CENTER); { jPanel1 = new JPanel(); BorderLayout jPanel1Layout = new BorderLayout(); jPanel1.setLayout(jPanel1Layout); jTabbedPane1.addTab("jPanel1", null, jPanel1, null); { jScrollPane1 = new JScrollPane(); jPanel1.add(jScrollPane1, BorderLayout.CENTER); jScrollPane1.setPreferredSize(new java.awt.Dimension(387, 246)); { jTextArea1 = new JTextArea(); jScrollPane1.setViewportView(jTextArea1); jTextArea1.setText(""); } } } { jPanel2 = new JPanel(); FlowLayout jPanel2Layout = new FlowLayout(); jPanel2.setLayout(jPanel2Layout); jTabbedPane1.addTab("jPanel2", null, jPanel2, null); { replaceFromText = new JTextField(); jPanel2.add(replaceFromText); replaceFromText.setPreferredSize(new java.awt.Dimension(266, 22)); } { replaceToText = new JTextField(); jPanel2.add(replaceToText); replaceToText.setPreferredSize(new java.awt.Dimension(266, 22)); } { execute = new JButton(); jPanel2.add(execute); execute.setText("execute"); execute.setPreferredSize(new java.awt.Dimension(149, 42)); execute.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { try { String text = jTextArea1.getText(); if (StringUtils.isBlank(text)) { JCommonUtil._jOptionPane_showMessageDialog_error("area empty!"); return; } String fromTxt = replaceFromText.getText(); String toTxt = StringUtils.defaultString(replaceToText.getText()); if (StringUtils.isBlank(fromTxt)) { JCommonUtil._jOptionPane_showMessageDialog_error("fromTxt empty!"); return; } StringBuffer sb = new StringBuffer(); Pattern ptn = Pattern.compile("(.){0,1}" + fromTxt + "(.){0,1}", Pattern.CASE_INSENSITIVE); Matcher mth = null; String[] scopeStrs = { ",", " ", "(", ")", "[", "]" }; BufferedReader reader = new BufferedReader(new StringReader(text)); for (String line = null; (line = reader.readLine()) != null;) { mth = ptn.matcher(line); while (mth.find()) { String scope1 = mth.group(1); String scope2 = mth.group(2); boolean ok1 = scope1.length() == 0 || StringUtils.indexOfAny(scope1, scopeStrs) != -1; boolean ok2 = scope2.length() == 0 || StringUtils.indexOfAny(scope2, scopeStrs) != -1; if (ok1 && ok2) { mth.appendReplacement(sb, scope1 + toTxt + scope2); } } mth.appendTail(sb); sb.append("\n"); } reader.close(); jTextArea1.setText(sb.toString()); } catch (Exception e) { JCommonUtil.handleException(e); } } }); } } } pack(); setSize(400, 300); } catch (Exception e) { //add your error handling code here e.printStackTrace(); } }