I am creating my IDE using a JTabbedPane. As i add tabs to my JTabbedPane, some titles are longer and some are shorter. This results in quite an ugly title length with some really long titles.
An example where i add a Pane to my JTabbedPane:
codes.addTab("", icon, scroll.get(scroll.size() - 1));
This results in this output when i run the program:
As you can see, The longer titled tabs make the title tab quite long and ugly. And when i add too many tabs, this happens:
Question: Am i able to fix or scale the title size like maybe restrict the length of title is its too long? Also maybe a left right arrow on too many files? Just like this:
If you want to set the tab's size, it would be a little complicated because in some way you should override the default behavior of the JTabbedPane paint() method family and the LookAndFeel you use. I want to tell it is not that ugly you think, because manu IDEs such as Eclipse or Intellij also have different length tab sizes for the source files:
Eclipse:
So don't worry about size.
But about placement of the tabs, you must use the following method to change the tab placement's layout:
tabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
You can add some SplitPanes to you newly hatched IDE to make it mode professional. Try the following snippet:
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Toolkit;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JSplitPane;
import javax.swing.JTabbedPane;
import javax.swing.JTextArea;
import javax.swing.JToolBar;
import javax.swing.UIManager;
public class MainWindow extends JFrame {
private static final int FRAME_WIDTH = 1024;
private static final int FRAME_HEIGHT = 600;
public MainWindow() {
Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
setBounds(dim.width/2-FRAME_WIDTH/2, dim.height/2-FRAME_HEIGHT/2, FRAME_WIDTH, FRAME_HEIGHT);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//
this.setLayout(new BorderLayout(4, 4));
//
JToolBar toolBar = new JToolBar();
toolBar.add(new JButton("Test"));
toolBar.add(new JButton("Test"));
toolBar.add(new JButton("Test"));
toolBar.add(new JButton("Test"));
JPanel northPanel = new JPanel();
northPanel.add(toolBar);
//
JPanel southPanel = new JPanel();
JLabel statusLabel = new JLabel("Test Status...");
southPanel.add(statusLabel);
//
this.add(northPanel, BorderLayout.NORTH);
this.add(southPanel, BorderLayout.SOUTH);
//
JPanel westPanel = new JPanel(new BorderLayout());
JPanel eastPanel = new JPanel(new BorderLayout());
JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
splitPane.setLeftComponent(eastPanel);
splitPane.setRightComponent(westPanel);
splitPane.setDividerLocation(250);
splitPane.setContinuousLayout(true);
this.add(splitPane, BorderLayout.CENTER);
//
JTabbedPane tabbedPane = new JTabbedPane();
tabbedPane.addTab("MyNewIdeTabbedPaneTest.java", new JTextArea());
tabbedPane.addTab("MyFrame.java", new JTextArea());
tabbedPane.addTab("JButton.java", new JTextArea());
tabbedPane.addTab("Main.java", new JTextArea());
tabbedPane.addTab("MyNewIdeTabbedPaneTest.java", new JTextArea());
tabbedPane.addTab("MyFrame.java", new JTextArea());
tabbedPane.addTab("JButton.java", new JTextArea());
tabbedPane.addTab("Main.java", new JTextArea());
tabbedPane.addTab("MyNewIdeTabbedPaneTest.java", new JTextArea());
tabbedPane.addTab("MyFrame.java", new JTextArea());
tabbedPane.addTab("JButton.java", new JTextArea());
tabbedPane.addTab("Main.java", new JTextArea());
tabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
tabbedPane.setAutoscrolls(false);
//tabbedPane.setTabLayoutPolicy(JTabbedPane.WRAP_TAB_LAYOUT); Also try this in comparison with above line
westPanel.add(tabbedPane, BorderLayout.CENTER);
}
public static void main(String[] args) {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception e) {
e.printStackTrace();
}
MainWindow mw = new MainWindow();
mw.setVisible(true);
}
}
Good Luck.
you can align your title to the left like this :
JLabel tabLabel = new JLabel("Tab", JLabel.LEFT);
//add new label at set location
jTabbedPane.setTabComponentAt(0, tabLabel);
If you want more information check this link the answer is very complet.
Hope i helps you
EDIT :You can also limit the lenght of your title it's an other possibility
You can also follow this tutorial made by Oracle it's pretty simple
Related
I am trying to build a GUI that looks something like this:
Main idea is to have buttons on the side and a table displaying results.
Here is the code I have so far:
public class GUI {
private JButton usdJpyButton = new JButton("USD/JPY");
private JButton usdGbpButton = new JButton("USD/GBP");
public void mainScreen(){
JFrame frame = new JFrame("Window");
frame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
frame.setSize(900,600);
frame.setResizable(false);
frame.setLocationRelativeTo(null);
GridLayout layout = new GridLayout(0,4);
frame.setLayout(layout);
JPanel sidePanel = new JPanel(new GridBagLayout());
sidePanel.setBackground(Color.black);
GridBagConstraints cons = new GridBagConstraints();
cons.insets = new Insets(50,0,0,0);
cons.gridy = 1;
cons.anchor = GridBagConstraints.NORTH;
sidePanel.add(usdJpyButton);
cons.gridy = 2;
sidePanel.add(usdGbpButton);
frame.add(sidePanel);
frame.setVisible(true);
}
The buttons are not aligned and I am not sure which layout manager I should use for the best results. Also each button will have an action listener to a different table so do I need to create seperate JPanels for each table??
I am not sure which layout manager I should use for the best results.
Rarely do you ever use a single layout manager. Generally you will nest panels each using a different layout manager to achieve your desired effect.
Read the section from the Swing tutorial on Layout Managers for working examples of each layout manager.
In this case you would probably need two panels, one for the buttons and one for the panels to display when you click on the button.
So for the buttons you might create a panel using BorderLayout. Then you create a second panel using a GridLayout. You add your buttons to the panel with the GridLayout. Then you add this panel to the PAGE_START of the BorderLayout. Then you add this panel to the LINE_START of the BorderLayout used by the content pane of the frame.
Then for the panel to display each table you would use a CardLayout. Then you create a separate panel for each currency table and add it to the CardLayout. You would add this panel to the CENTER of the BorderLayout of the content pane.
Then in the ActionListener of your buttons you swap the panel in the CardLayout based on the button that was clicked.
Again, the tutorial link I provided has working examples of the BorderLayout, GridLayout and CardLayout.
I would recommend MigLayout manager.
It is not particularly difficult to do it with this manager.
package com.zetcode;
import java.awt.EventQueue;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JFrame;
import static javax.swing.JFrame.EXIT_ON_CLOSE;
import javax.swing.JOptionPane;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import net.miginfocom.swing.MigLayout;
public class InstaMetrixEx extends JFrame implements ActionListener {
public InstaMetrixEx() {
initUI();
}
private void initUI() {
JButton btn1 = new JButton("Client Overview");
JButton btn2 = new JButton("Seo Reports");
JButton btn3 = new JButton("Social media reports");
JButton btn4 = new JButton("Campaigns");
JButton btn5 = new JButton("Webmaster tools");
JButton btn6 = new JButton("Dashboard");
JButton btn7 = new JButton("Tasks");
JComboBox combo1 = new JComboBox();
combo1.addItem("Bulk actions");
JButton btn8 = new JButton("Submit");
JTable table = new JTable(20, 7);
JScrollPane spane = new JScrollPane(table);
createLayout(btn1, combo1, btn8, btn2, btn3, btn4,
btn5, btn6, btn7, spane );
setTitle("InstaMetrixEx");
setLocationRelativeTo(null);
setDefaultCloseOperation(EXIT_ON_CLOSE);
}
private void createLayout(JComponent... arg) {
setLayout(new MigLayout());
add(arg[0], "sgx");
add(arg[1], "gapx 10lp, split 2");
add(arg[2], "wrap");
add(arg[3], "split 6, aligny top, flowy, sgx");
add(arg[4], "sgx");
add(arg[5], "sgx");
add(arg[6], "sgx");
add(arg[7], "sgx");
add(arg[8], "sgx");
add(arg[9], "gapx 10lp, spanx, wrap, push, grow");
pack();
}
#Override
public void actionPerformed(ActionEvent e) {
JOptionPane.showMessageDialog(this, "Button clicked",
"Information", JOptionPane.INFORMATION_MESSAGE);
}
public static void main(String[] args) {
EventQueue.invokeLater(() -> {
InstaMetrixEx ex = new InstaMetrixEx();
ex.setVisible(true);
});
}
}
Screenshot:
Hey guys my buttons and textarea will not display on JFrame when compiled, i have tried everything and searched this site but no luck. Any help would be greatly appreciated. Due to them not letting me post without more detail i am just adding this part so i can hit the submit button.
import java.awt.BorderLayout;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JFrame;
import javax.swing.JTextField;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JTextArea;
public class DataManager extends JFrame {
private String students[] = {"John Smith","Ken Hanson","Michael Li","John Andersen","Fiona Harris","Angela Lim","Bob London","Sydney Shield","Tina Gillard",
"Ross Brinns","Scott Cairns","Grant Peterson","David Power","Joshua Kane","Alan Newton","Frady Morgan","Quinn Perth"};
private int english[] = {80,52,71,61,39,62,31,46,60,26,77,40,58,38,94,90,97};
private int maths[] = {60,45,77,90,45,55,66,87,31,42,65,55,80,71,51,55,95};
private int total[];
private JButton sortNameButton;
private JButton sortTotalButton;
private JTextField searchTextField;
private JButton statisticsButton;
private JButton exitButton;
private JTextArea infoTextArea;
private JPanel jPan;
public DataManager() {
super("Data Manager ");
jPan = new JPanel();
sortNameButton = new JButton("Sort By Name");
sortTotalButton = new JButton("Sort By Total");
searchTextField = new JTextField("Search");
statisticsButton = new JButton("Statistics");
exitButton = new JButton("Exit");
infoTextArea = new JTextArea();
setLayout(new BorderLayout());
jPan.add(sortNameButton, BorderLayout.NORTH);
jPan.add(sortTotalButton, BorderLayout.NORTH);
jPan.add(searchTextField, BorderLayout.NORTH);
jPan.add(statisticsButton, BorderLayout.NORTH);
jPan.add(exitButton, BorderLayout.NORTH);
jPan.add(infoTextArea, BorderLayout.CENTER);
}
public static void main(String[] args) {
DataManager frame = new DataManager();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(800,600);
frame.setVisible(true);
} // End of main method.
} // End of DataManager class
You add your JButtons to the jPan JPanel but never add the jPan to anything -- it must be added to your JFrame, to this to be seen.
jPan.add(sortNameButton);
jPan.add(sortTotalButton);
jPan.add(searchTextField);
jPan.add(statisticsButton);
jPan.add(exitButton);
jPan.add(infoTextArea);
add(jPan); // don't forget this! ************
Note other problems:
You set the JFrame's layout to BorderLayout -- it's already using BorderLayout
You add components to your jPan JPanel with BorderLayout constants, but it's not using a BorderLayout.
If it were, many buttons would not be seen since many are added to the same BorderLayout position and will cover the previous component added there.
In other words, read the tutorials as you're making wrong assumptions.
Better would be something like:
// setLayout(new BorderLayout());
jPan.setLayout(new BorderLayout());
JPanel northPanel = new JPanel(); // **** to hold buttons
northPanel.add(sortNameButton);
northPanel.add(sortTotalButton);
northPanel.add(searchTextField);
northPanel.add(statisticsButton);
northPanel.add(exitButton);
jPan.add(northPanel, BorderLayout.PAGE_START);
jPan.add(infoTextArea, BorderLayout.CENTER);
I'm currently developing a small utility with the following GUI:
Right now i have a container (JPanel) with the BorderLayout layout that holds everything in place. The i have another 2 JPanels placed on BorderLayout.NORTH and BorderLayout.SOUTH respectively, each whith the GridLayout (2 columns by 1 row). The table is on the main container placed at the CENTER of it.
Do you think this is the best approach? I'm having a rough time dealing with spacing between the components and the borders of the frame.
Right now i have this code:
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JSeparator;
import javax.swing.JTable;
import javax.swing.SwingUtilities;
public class GUI extends JFrame {
private JButton loadFileBtn = new JButton("Load File");
private JButton generateReportBtn = new JButton("Generate Report");
private JButton exitBtn = new JButton("Exit");
private JLabel fileNameLbl = new JLabel("File Name Here");
private JMenuBar menuBar = new JMenuBar();
private JMenu fileMI = new JMenu("File");
private JMenuItem openFileMenu = new JMenuItem("Open File");
private JSeparator separator = new JSeparator();
private JMenuItem exitMenu = new JMenuItem("Exit");
private JMenu reportMI = new JMenu("Report");
private JMenuItem generateReportMenu = new JMenuItem("Generate Report");
private JMenu helpMI = new JMenu("Help");
private JMenuItem aboutMenu = new JMenuItem("About");
private JTable table = new JTable(5, 2);
private JPanel mainPanel = new JPanel(new BorderLayout(10, 10));
private JPanel panel1 = new JPanel(new BorderLayout());
private JPanel panel2 = new JPanel(new GridLayout(1, 2));
private JPanel panel3 = new JPanel(new GridLayout(1, 2));
public GUI() {
super("Sample GUI");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(new Dimension(300, 300));
setResizable(false);
setLayout(new BorderLayout(10, 10));
fileMI.add(openFileMenu);
fileMI.add(separator);
fileMI.add(exitMenu);
reportMI.add(generateReportMenu);
helpMI.add(aboutMenu);
menuBar.add(fileMI);
menuBar.add(reportMI);
menuBar.add(helpMI);
setJMenuBar(menuBar);
panel1.add(table, BorderLayout.CENTER);
panel2.add(fileNameLbl);
panel2.add(loadFileBtn);
panel3.add(generateReportBtn);
panel3.add(exitBtn);
mainPanel.add(panel2, BorderLayout.NORTH);
mainPanel.add(panel1, BorderLayout.CENTER);
mainPanel.add(panel3, BorderLayout.SOUTH);
add(mainPanel);
}
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
#Override
public void run() {
GUI app = new GUI();
app.setVisible(true);
}
});
}
}
What do you think would be the best approach to do this?
Any help would be appreciated. Thanks.
UPDATE:
Right now, i have the following GUI
I want the components to space away from the borders evenly, like in the mockup.
2 things you can use to make this happen:
Use BorderFactory.createEmptyBorder(int, int, int, int)
Use the 4-args constructor of GridLayout
There are other LayoutManager's which can bring the same functionality (like GridBagLayout, or using nested BorderLayout), but if you feel comfortable with the current LayoutManager's, there is no imperious need to change to those. The way you did is also acceptable.
You might consider wrapping the table in a JScrollPane to make it nicer, with headers and scrollbars if ever needed.
Small example code:
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridLayout;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JSeparator;
import javax.swing.JTable;
import javax.swing.SwingUtilities;
public class GUI extends JFrame {
private JButton loadFileBtn = new JButton("Load File");
private JButton generateReportBtn = new JButton("Generate Report");
private JButton exitBtn = new JButton("Exit");
private JLabel fileNameLbl = new JLabel("File Name Here");
private JMenuBar menuBar = new JMenuBar();
private JMenu fileMI = new JMenu("File");
private JMenuItem openFileMenu = new JMenuItem("Open File");
private JSeparator separator = new JSeparator();
private JMenuItem exitMenu = new JMenuItem("Exit");
private JMenu reportMI = new JMenu("Report");
private JMenuItem generateReportMenu = new JMenuItem("Generate Report");
private JMenu helpMI = new JMenu("Help");
private JMenuItem aboutMenu = new JMenuItem("About");
private JTable table = new JTable(5, 2);
private JPanel mainPanel = new JPanel(new BorderLayout(10, 10));
private JPanel panel1 = new JPanel(new BorderLayout());
private JPanel panel2 = new JPanel(new GridLayout(1, 2, 10, 10));
private JPanel panel3 = new JPanel(new GridLayout(1, 2, 10, 10));
public GUI() {
super("Sample GUI");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(new Dimension(300, 300));
setResizable(false);
setLayout(new BorderLayout(10, 10));
fileMI.add(openFileMenu);
fileMI.add(separator);
fileMI.add(exitMenu);
reportMI.add(generateReportMenu);
helpMI.add(aboutMenu);
menuBar.add(fileMI);
menuBar.add(reportMI);
menuBar.add(helpMI);
setJMenuBar(menuBar);
panel1.add(table, BorderLayout.CENTER);
panel2.add(fileNameLbl);
panel2.add(loadFileBtn);
panel3.add(generateReportBtn);
panel3.add(exitBtn);
mainPanel.add(panel2, BorderLayout.NORTH);
mainPanel.add(panel1, BorderLayout.CENTER);
mainPanel.add(panel3, BorderLayout.SOUTH);
mainPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
add(mainPanel);
}
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
#Override
public void run() {
GUI app = new GUI();
app.setVisible(true);
}
});
}
}
In the past, I have found that using MigLayout, solves all my problems
Here's how I would arrange your GUI. This is just one way. It's not the only way.
The JTable goes inside of a JScrollPane.
Button2 and Button3 go inside of a button JPanel with a FlowLayout.
Label and Button1 go inside of a label JPanel with a FlowLayout.
File, Report, and Help are JMenuItems on a JMenuBar.
The main JPanel has a BoxLayout with a Y_AXIS orientation.
Add the label JPanel, the JScrollPane, and the button JPanel to the main JPanel.
The best way is to create a GUI is to code in a way you and others will understand . Take a look at this Guide to Layout Managers. You can use different layout managers for different components. This will help you setting correct spacing.
If your problem is just the spacing around the components, set its Insets.
Hi I am trying to create an interface consisting of a JComboBox and a JTextField. I have sorted out the code to add a label to the JComboBox but I am having trouble adding a label to the text field. Any help would be appreciated.
import javax.swing. *;
import java.awt.event. *;
import java.awt.FlowLayout;
import java.lang.Math;
public class AreaFrame3 extends JFrame
{
public static void main(``String[]args)
{
//Create array containing shapes
String[] shapes ={"(no shape selected)","Circle","Equilateral Triangle","Square"};
//Use combobox to create drop down menu
JComboBox comboBox=new JComboBox(shapes);
JPanel panel1 = new JPanel(new FlowLayout()); //set frame layout
JLabel label1 = new JLabel("Select shape:");
panel1.add(label1);
panel1.add(comboBox);
JTextField text = new JTextField(10); //create text field
JFrame frame=new JFrame("Area Calculator Window");//create a JFrame to put combobox
frame.setLayout(new FlowLayout()); //set layout
frame.add(panel1);
frame.add(text);
JButton button = new JButton("GO"); //create GO button
frame.add(button);
//set default close operation for JFrame
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//set JFrame ssize
frame.setSize(400,250);
//make JFrame visible. So we can see it
frame.setVisible(true);
}
}
Here is one way to do it. Simply put all the widgets in your panel1 in appropriate order.
In the long run this is probably not very much maintainable and you would want to have a better LayoutManager than FlowLayout, but if you just want to learn Swing, this may be a good start. If you feel that FlowLayout is not good enough, take a look at the LayoutManager tutorial. My personal favourites are: BorderLayout and GridBagLayout. MigLayout may also be a good one, but I have never used it and it is not part of the JVM.
import java.awt.FlowLayout;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
public class AreaFrame3 {
protected void initUI() {
// Create array containing shapes
String[] shapes = { "(no shape selected)", "Circle", "Equilateral Triangle", "Square" };
// Use combobox to create drop down menu
JComboBox comboBox = new JComboBox(shapes);
JLabel label1 = new JLabel("Select shape:");
JPanel panel1 = new JPanel(new FlowLayout()); // set frame layout
JLabel label2 = new JLabel("Text label:");
JTextField text = new JTextField(10); // create text field
panel1.add(label1);
panel1.add(comboBox);
panel1.add(label2);
panel1.add(text);
JFrame frame = new JFrame("Area Calculator Window");// create a JFrame to put combobox
frame.setLayout(new FlowLayout()); // set layout
frame.add(panel1);
JButton button = new JButton("GO"); // create GO button
frame.add(button);
// set default close operation for JFrame
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
// make JFrame visible. So we can see it
frame.setVisible(true);
}
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
#Override
public void run() {
new AreaFrame3().initUI();
}
});
}
}
Here is my code to add to component (JTextArea and JList) to a panel and put it on the frame. Can I divide half/half by BorderLayout?
If yes why mine looks messy one stays up one down?
What is the other alternative?
Regards,
Bernard
import java.awt.*;
import javax.swing.BorderFactory;
import javax.swing.border.Border;
import javax.swing.JList;
import javax.swing.JScrollPane;
import javax.swing.JPanel;
import javax.swing.JFrame;
import javax.swing.JTextArea;
public class SimpleBorder {
public static void main(String[] args) {
JFrame frame = new JFrame();
frame.setSize(500,500);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Border etched = (Border) BorderFactory.createEtchedBorder();
String[] items = {"A", "B", "C", "D"};
JList list = new JList(items);
JTextArea text = new JTextArea(10, 40);
JScrollPane scrol = new JScrollPane(text);
JScrollPane scrol2 = new JScrollPane(list);
JPanel panel= new JPanel();
panel.add(scrol2,BorderLayout.WEST);
panel.add(scrol, BorderLayout.EAST);
panel.setBorder(etched);
frame.add(panel);
frame.setVisible(true);
}
}
The default Layout manager for JPanel is FlowLayout, so adding components without actually setting the layout to an instance of BorderLayout will produce unexpected results.
To get a half/half layout you could use GridLayout:
JPanel panel= new JPanel(new GridLayout(1, 2));
You must use a different LayoutManager, BorderLayout will not allow you add components that use only 50% of the visible space. I personally use GridBagLayout, which allows you to specify many parameters (free space distribution, new lines of components, alignment, etc.).
You should set the LayoutManager of your JPanel to BorderLayout first (only ContentPanes i.e frame#getContentPane() have a default layout of BorderLayout):
JPanel panel= new JPanel(new BorderLayout());
panel.add(scrol2,BorderLayout.WEST);
panel.add(scrol, BorderLayout.EAST);
panel.setBorder(etched);