hiiiiiiiii

JPanel middlePanel = new JPanel ();
middlePanel.setBorder ( new TitledBorder ( new EtchedBorder (), “Display Area” ) );

// create the middle panel components

JTextArea display = new JTextArea ( 16, 58 );
display.setEditable ( false ); // set textArea non-editable
JScrollPane scroll = new JScrollPane ( display );
scroll.setVerticalScrollBarPolicy ( ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS );

//Add Textarea in to middle panel
middlePanel.add ( scroll );

// My code
JFrame frame = new JFrame ();
frame.add ( middlePanel );
frame.pack ();
frame.setLocationRelativeTo ( null );
frame.setVisible ( true );

 

 

package com.lmig.classes;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;

import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;

import com.lmig.classes.OpenClose.OpenL;

public class NewDesign extends JFrame {
static String stringPath = null;
static String savedPath=null;
static StringBuffer stringBuffer=new StringBuffer();
public static void main(String[] args) {
new NewDesign();
}

public NewDesign() {
JFrame window = new JFrame();
window.setLayout(new GridBagLayout());
JButton open = new JButton(“Open”), save = new JButton(“Save”), extract = new JButton(“Extract”),
values = new JButton(“Values”), view = new JButton(“View”);
JPanel top = new JPanel(), middle = new JPanel(), bottom = new JPanel();
JTextField jTextField = new JTextField();
jTextField.setEditable(false);
jTextField.setText(“Before”);
jTextField.setSize(500,50);
top.setBackground(Color.WHITE);
middle.setBackground(Color.GRAY);
bottom.setBackground(Color.DARK_GRAY);

bottom.add(open);
bottom.add(save);
bottom.add(extract);
bottom.add(values);
bottom.add(view);

JTextArea textArea = new JTextArea (14,52);

extract.addActionListener(new ActionListener() {

@Override
public void actionPerformed(ActionEvent e) {
if(stringPath!=null){
Scanner scanner = null;
try {
scanner = new Scanner(new File(stringPath));
} catch (FileNotFoundException e1) {
e1.printStackTrace();
}
while(scanner.hasNext()){
stringBuffer.append(scanner.next());
stringBuffer.append(System.lineSeparator());
}
new ZZ().me(stringBuffer);
}else{
System.out.println(“error”);
}
}
});

open.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
JFileChooser jFileChooser = new JFileChooser();
jFileChooser.setPreferredSize(new Dimension(800, 400));
int value=jFileChooser.showSaveDialog(middle);
jFileChooser.setVisible(true);jTextField.setVisible(true);
if (value == JFileChooser.APPROVE_OPTION) {
stringPath = jFileChooser.getCurrentDirectory() + “\\” + jFileChooser.getSelectedFile().getName();
jTextField.setText(stringPath);
System.out.println(stringPath);
}
if (value == JFileChooser.CANCEL_OPTION) {
jTextField.setText(“”);
}
}
});
save.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
JFileChooser jFileChooser = new JFileChooser();
jFileChooser.setPreferredSize(new Dimension(800, 400));
int value=jFileChooser.showSaveDialog(middle);
jFileChooser.setVisible(true);jTextField.setVisible(true);
if (value == JFileChooser.APPROVE_OPTION) {
stringPath = jFileChooser.getCurrentDirectory() + “\\” + jFileChooser.getSelectedFile().getName();
jTextField.setText(stringPath);
}
if (value == JFileChooser.CANCEL_OPTION) {
jTextField.setText(“”);
}
}
});
top.add(jTextField);

GridBagConstraints c = new GridBagConstraints();
c.fill = GridBagConstraints.BOTH;
c.weightx = 1;
c.weighty = 0.05;
c.gridy = 0;
window.add(top, c);
c.weightx = 1;
c.weighty = 0.90;
c.gridy = 1;
window.add(middle, c);
c.weighty = 0.05;
c.gridy = 2;
window.add(bottom, c);

window.setSize(1000, 600);
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
window.setVisible(true);
}
}