Swing panels with different sizes - java

I'm trying to put components into panels having different sizes. But, I realized that GridLayout divides the parts with same sizes. How can it be accomplished as explained below image
enter image description here
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class PanelDemo {
PanelDemo() {
// Create a new JFrame container. Use the default
// border layout.
JFrame jfrm = new JFrame("Use Three JPanels with Different Sizes");
// Specify FlowLayout manager.
jfrm.getContentPane().setLayout(new GridLayout(1, 3));
// Give the frame an initial size.
jfrm.setSize(900, 300);
// Terminate the program when the user closes the application.
jfrm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// Create the first JPanel.
JPanel jpnl = new JPanel();
jpnl.setLayout(new GridLayout(2, 4));
// Set the preferred size of the first panel.
jpnl.setPreferredSize(new Dimension(500, 300));
// Make the panel opaque.
jpnl.setOpaque(true);
// Add a blue border to the panel.
jpnl.setBorder(
BorderFactory.createLineBorder(Color.BLUE));
// Create the second JPanel.
JPanel jpnl2 = new JPanel();
//jpnl2.setLayout(new FlowLayout());
// Set the preferred size of the second panel.
jpnl2.setPreferredSize(new Dimension(300, 300));
// Make the panel opaque.
jpnl2.setOpaque(true);
jpnl2.setBorder(
BorderFactory.createLineBorder(Color.RED));
JPanel jpnl3 = new JPanel();
jpnl3.setOpaque(true);
jpnl3.setPreferredSize(new Dimension(100, 300));
jpnl3.setBorder(
BorderFactory.createLineBorder(Color.ORANGE));
// Add the panels to the frame.
jfrm.getContentPane().add(jpnl);
jfrm.getContentPane().add(jpnl3);
jfrm.getContentPane().add(jpnl2);
// Display the frame.
jfrm.setVisible(true);
}
public static void main(String args[]) {
// Create the frame on the event dispatching thread.
SwingUtilities.invokeLater(new Runnable() {
public void run() {
new PanelDemo();
}
});
}
}

import java.awt.*;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
public class TwoPanelWithButtonsLayout {
private JComponent ui = null;
private Insets buttonMargin = new Insets(10,10,10,10);
TwoPanelWithButtonsLayout() {
initUI();
}
public void initUI() {
if (ui!=null) return;
ui = new JPanel(new BorderLayout(4,4));
ui.setBorder(new EmptyBorder(4,4,4,4));
int gap = 5;
JPanel buttons1 = new JPanel(new GridLayout(2, 4, gap, gap));
// 50 is the gap on right, alter as needed
buttons1.setBorder(new EmptyBorder(0, 0, 0, 50));
for (int ii=1; ii<9; ii++) {
buttons1.add(getBigButton("" + ii));
}
ui.add(buttons1, BorderLayout.CENTER);
JPanel buttons2 = new JPanel(new GridLayout(2, 2, gap, gap));
for (int ii=1; ii<5; ii++) {
buttons2.add(getBigButton("" + ii));
}
ui.add(buttons2, BorderLayout.LINE_END);
}
private JButton getBigButton(String text) {
JButton b = new JButton(text);
Font f = b.getFont();
b.setFont(f.deriveFont(f.getSize()*3f));
b.setMargin(buttonMargin);
return b;
}
public JComponent getUI() {
return ui;
}
public static void main(String[] args) {
Runnable r = new Runnable() {
#Override
public void run() {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception useDefault) {
}
TwoPanelWithButtonsLayout o = new TwoPanelWithButtonsLayout();
JFrame f = new JFrame(o.getClass().getSimpleName());
f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
f.setLocationByPlatform(true);
f.setContentPane(o.getUI());
f.pack();
f.setMinimumSize(f.getSize());
f.setVisible(true);
}
};
SwingUtilities.invokeLater(r);
}
}

You could use FlowLayout but if they resize your frame then it will wrap the panels.

Related

How do I create bordered color style panel?

I'm trying to create a canvas for my oval shape, and I want it to be different from the main JFrame color. So far, using setSize upon the panel doesn't work, it ended up creating a small box that I couldn't draw in. Here is the panel design that I intended it to be, with the white-colored part as the main frame.
PanelDesign
As I've said, using all three Layout modes (Border, Flow, and Grid) only creates a yellow small box in the upper middle part of the frame. This is the code that I use.
How can I create the panel design similar to the image posted above?
setTitle("Oval Shape Mover");
setSize(500, 200);
setLayout(new BorderLayout());
JPanel mainpanel, panel1, panel2;
mainpanel = new JPanel();
panel1 = new JPanel();
panel2 = new JPanel();
panel1.setBackground(Color.YELLOW);
mainpanel.add(panel1, BorderLayout.CENTER);
mainpanel.add(panel2);
add(mainpanel);
setVisible(true);
The layouts used to make Java Swing GUIs will more often honor the preferred size than the size. Having said that, a custom rendered component should override (rather than set) getPreferredSize().
This example suggests a preferred size by using a JLabel to display the icon, and empty borders to pad the GUI out.
import java.awt.*;
import javax.swing.*;
import javax.swing.border.*;
import java.net.*;
public class RedDotLayout {
private JComponent ui = null;
String urlToRedCircle = "https://i.stack.imgur.com/wCF8S.png";
RedDotLayout() {
try {
initUI();
} catch (MalformedURLException ex) {
ex.printStackTrace();
}
}
public final void initUI() throws MalformedURLException {
ui = new JPanel(new BorderLayout());
ui.setBackground(Color.YELLOW);
ui.setBorder(new LineBorder(Color.BLACK, 2));
JLabel label = new JLabel(new ImageIcon(new URL(urlToRedCircle)));
label.setBorder(new CompoundBorder(
new LineBorder(Color.GREEN.darker(), 2),
new EmptyBorder(20, 200, 20, 200)));
ui.add(label, BorderLayout.CENTER);
JPanel bottomPanel = new JPanel();
bottomPanel.setBackground(Color.WHITE);
bottomPanel.setBorder(new EmptyBorder(30, 50, 30, 50));
ui.add(bottomPanel, BorderLayout.PAGE_END);
}
public JComponent getUI() {
return ui;
}
public static void main(String[] args) {
Runnable r = () -> {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception useDefault) {
}
RedDotLayout o = new RedDotLayout();
JFrame f = new JFrame(o.getClass().getSimpleName());
f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
f.setLocationByPlatform(true);
f.setContentPane(o.getUI());
f.pack();
f.setMinimumSize(f.getSize());
f.setVisible(true);
};
SwingUtilities.invokeLater(r);
}
}

Break line around JPanel section

Hello I am trying to add a border or a line break separating the north section from the rest of the JPanel. Basically using set border I have a border around the whole window but then want a line from one section of the border straight across horizontally to the other side. when i add a border to a JPanel that is added to BorderLayout.NORTH it puts a whole border inside the section. not the outline of the section. hope you know what i mean.
Attached I have a section of my code that is holding all my JPanel code in it so far. any help I would love, thanks.
import javax.swing.*;
import javax.swing.border.*;
import java.awt.*;
public class GamePanel extends JPanel {
private JTextPane playertext;
private JTextField wealthstring, currentwealth;
public GamePanel() {
super();
setLayout(new BorderLayout());
setBackground(Game.getBackgroundColor());
Border raised = BorderFactory.createRaisedBevelBorder();
Border lowered = BorderFactory.createLoweredBevelBorder();
setBorder(BorderFactory.createCompoundBorder(new EmptyBorder(4, 4, 4, 4), (BorderFactory.createCompoundBorder(raised, lowered))));
add(northpanel(), BorderLayout.NORTH);
add(eastpanel(), BorderLayout.EAST);
}
private JPanel northpanel() {
Font northfont = new Font("Engravers MT", Font.BOLD, 12);
playertext = new JTextPane();
playertext.setFont(northfont);
playertext.setEditable(false);
playertext.setText("Player: \n" + Game.getName());
playertext.setBackground(Game.getBackgroundColor());
playertext.setBorder(new EmptyBorder(10,10,10,10));
wealthstring = new JTextField("Money: ");
wealthstring.setFont(northfont);
wealthstring.setEditable(false);
wealthstring.setHorizontalAlignment(wealthstring.RIGHT);
wealthstring.setBorder(null);
wealthstring.setBackground(Game.getBackgroundColor());
currentwealth = new JTextField();
currentwealth.setFont(northfont);
currentwealth.setEditable(false);
currentwealth.setHorizontalAlignment(wealthstring.RIGHT);
currentwealth.setBackground(Game.getBackgroundColor());
currentwealth.setBorder(null);
String wealthrounded = String.format("%.2f", Game.getMoney());
currentwealth.setText(wealthrounded);
JPanel wealthtext = new JPanel();
wealthtext.setLayout(new GridLayout(2, 1));
wealthtext.setBackground(Game.getBackgroundColor());
wealthtext.setBorder(new EmptyBorder(10,10,10,10));
wealthtext.add(wealthstring);
wealthtext.add(currentwealth);
JPanel northpanel = new JPanel();
northpanel.setLayout(new BorderLayout());
northpanel.setBackground(Game.getBackgroundColor());
northpanel.add(playertext, BorderLayout.WEST);
northpanel.add(wealthtext, BorderLayout.EAST);
return northpanel;
}
private JPanel eastpanel() {
JButton tab1 = new JButton("Tab 1");
JButton tab2 = new JButton("Tab 2");
JButton tab3 = new JButton("Tab 3");
JPanel easttabs = new JPanel();
easttabs.setLayout(new GridLayout(1, 3));
easttabs.add(tab1);
easttabs.add(tab2);
easttabs.add(tab3);
JPanel eastpanels = new JPanel();
eastpanels.setLayout(new BorderLayout());
eastpanels.add(easttabs, BorderLayout.NORTH);
return eastpanels;
}
}
Like this?
For that we would use a JSeparator.
import java.awt.*;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
public class UnderlinePageStart {
private JComponent ui = null;
UnderlinePageStart() {
initUI();
}
public void initUI() {
if (ui!=null) return;
ui = new JPanel(new BorderLayout(4,4));
ui.setBorder(new EmptyBorder(4,4,4,4));
JPanel pageStart = new JPanel(new BorderLayout(2,2));
ui.add(pageStart, BorderLayout.PAGE_START);
pageStart.add(new JLabel("Page Start", SwingConstants.CENTER));
// add a 'horizontal line'
pageStart.add(new JSeparator(), BorderLayout.PAGE_END);
ui.add(new JScrollPane(new JTextArea(5, 25)));
}
public JComponent getUI() {
return ui;
}
public static void main(String[] args) {
Runnable r = new Runnable() {
#Override
public void run() {
UnderlinePageStart o = new UnderlinePageStart();
JFrame f = new JFrame("Underline Page Start");
f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
f.setLocationByPlatform(true);
f.setContentPane(o.getUI());
f.pack();
f.setMinimumSize(f.getSize());
f.setVisible(true);
}
};
SwingUtilities.invokeLater(r);
}
}

Why is extra space being added to the frame?

So I'm adding this code to a JFrame which has other layout managers and components in them.
private JPanel testing123() {
JPanel j = new JPanel(new FlowLayout());
jbtOk = new JButton("OK");
jbtOk.setMnemonic('K');
jbtExit = new JButton("Exit");
jbtExit.setMnemonic('x');
add(jbtOk);
add(jbtExit);
j.add(jbtOk);
j.add(jbtExit);
return j;
}
Without this code, the JFrame looks fine, but when I add it, it adds a large amount of empty space under these two buttons. Why is this happening?
This replicates it:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.TitledBorder;
public class Test extends JFrame implements ActionListener, KeyListener {
JButton jbtOk, jbtExit;
JPanel p = new JPanel(new GridLayout(0,1));
JPanel gui = new JPanel(new BorderLayout(2,2));
public Test() {
super("t");
//setSize(300,300);
setVisible(true);
JPanel test = test();
JPanel testing = testing();
JPanel testing123 = testing123();
p.add(test);
p.add(testing);
p.add(testing123);
this.getContentPane().add(p);
pack();
}
private JPanel test() {
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel labelFields = new JPanel(new BorderLayout(2,2));
labelFields.setBorder(new TitledBorder("m"));
p.add(gui);
p.add(labelFields);
JPanel labels = new JPanel(new GridLayout(0,1,1,1));
labels.setBorder(new TitledBorder("a"));
JPanel fields = new JPanel(new GridLayout(0,1,1,1));
fields.setBorder(new TitledBorder("b"));
p.add(labels);
p.add(fields);
add(fields);
add(p);
return gui;
}
private JPanel testing() {
JPanel guiCenter = new JPanel(new FlowLayout(FlowLayout.CENTER));
guiCenter.setBorder(new TitledBorder("n"));
guiCenter.add(new JScrollPane(new JTextArea(5,30)));
gui.add(guiCenter, BorderLayout.CENTER);
return guiCenter;
}
private JPanel testing123() {
JPanel j = new JPanel(new FlowLayout());
jbtOk = new JButton("OK");
jbtOk.setMnemonic('K');
jbtExit = new JButton("Exit");
jbtExit.setMnemonic('x');
//add(jbtOk);
//add(jbtExit);
j.add(jbtOk);
j.add(jbtExit);
return j;
}
#Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
}
#Override
public void keyPressed(KeyEvent arg0) {
// TODO Auto-generated method stub
}
#Override
public void keyReleased(KeyEvent arg0) {
// TODO Auto-generated method stub
}
#Override
public void keyTyped(KeyEvent arg0) {
// TODO Auto-generated method stub
}
}
"I want to get rid of the extra space under the OK and Exit buttons."
The problem is you are using the GridLayout that will make all the JPanel equal size. What you should do instead is wrap the first four JPanel in GridLayout, then keep the default BorderLayout of the JFrame, add the JPanel to BorderLayout.CENTER of the JFrame and add the buttons JPanel to the BorderLayout.PAGE_END. This should solve the problem
public Test() {
super("t");
setDefaultCloseOperation(EXIT_ON_CLOSE);
JPanel test = test();
JPanel testing = testing();
JPanel testing123 = testing123();
p.add(test);
p.add(testing);
add(p, BorderLayout.CENTER); <---
add(testing123, BorderLayout.PAGE_END); <---
pack();
setVisible(true);
}
Complete running code
import java.awt.*;
import javax.swing.*;
import javax.swing.border.TitledBorder;
public class Test extends JFrame {
JButton jbtOk, jbtExit;
JPanel p = new JPanel(new GridLayout(0, 1));
JPanel gui = new JPanel(new BorderLayout(2, 2));
public Test() {
super("t");
setDefaultCloseOperation(EXIT_ON_CLOSE);
JPanel test = test();
JPanel testing = testing();
JPanel testing123 = testing123();
p.add(test);
p.add(testing);
add(p, BorderLayout.CENTER);
add(testing123, BorderLayout.PAGE_END);
pack();
setVisible(true);
}
private JPanel test() {
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel labelFields = new JPanel(new BorderLayout(2, 2));
labelFields.setBorder(new TitledBorder("m"));
p.add(gui);
p.add(labelFields);
JPanel labels = new JPanel(new GridLayout(0, 1, 1, 1));
labels.setBorder(new TitledBorder("a"));
JPanel fields = new JPanel(new GridLayout(0, 1, 1, 1));
fields.setBorder(new TitledBorder("b"));
p.add(labels);
p.add(fields);
return gui;
}
private JPanel testing() {
JPanel guiCenter = new JPanel(new FlowLayout(FlowLayout.CENTER));
guiCenter.setBorder(new TitledBorder("n"));
guiCenter.add(new JScrollPane(new JTextArea(5, 30)));
gui.add(guiCenter, BorderLayout.CENTER);
return guiCenter;
}
private JPanel testing123() {
JPanel j = new JPanel(new FlowLayout());
jbtOk = new JButton("OK");
jbtOk.setMnemonic('K');
jbtExit = new JButton("Exit");
jbtExit.setMnemonic('x');
j.add(jbtOk);
j.add(jbtExit);
return j;
}
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
new Test();
}
});
}
}

all individual panels are not shown inside root panel

I want to add multiple jpanels to jpanel.So i added a root panel to jscrollpane.and then added all individual jpanels to this root panel.I made jscrollpane's scrolling policy as needed.i.e HORIZONTAL_SCROLLBAR_AS_NEEDED,VERTICAL_SCROLLBAR_AS_NEEDED.
But the problem is all individual panels are not shown inside root panel.
Code:
JScrollPane scPanel=new JScrollPane();
JPanel rootPanel=new JPanel();
rootPanel.setLayout(new FlowLayout());
JPanel indPanel = new JPanel();
rootPanel.add(indPanel);
JPanel indPanel2 = new JPanel();
rootPanel.add(indPanel2);
//.....like this added indPanals to rootPanel.
scPanel.setViewPortView(rootPanel);
//scPanel.setHorizontalScrollPolicy(HORIZONTAL_SCROLLBAR_AS_NEEDED);
And one more thing is, as i scroll the scrollbar the panels are going out of jscrollpane area.
I am not able to see all individual panels,
Please suggest me.
Edit: code snippet from double post:
MosaicFilesStatusBean mosaicFilesStatusBean = new MosaicFilesStatusBean();
DefaultTableModel tableModel = null;
tableModel = mosaicFilesStatusBean.getFilesStatusBetweenDates(startDate, endDate);
if (tableModel != null) {
rootPanel.removeAll();
rootPanel.setLayout(new BoxLayout(rootPanel, BoxLayout.PAGE_AXIS));
for (int tempRow = 0; tempRow < tableModel.getRowCount(); tempRow++) {
int fileIdTemp = Integer.parseInt(tableModel.getValueAt(tempRow, 0).toString());
String dateFromTemp = tableModel.getValueAt(tempRow, 3).toString();
String dateToTemp = tableModel.getValueAt(tempRow, 4).toString();
int processIdTemp = Integer.parseInt(tableModel.getValueAt(tempRow, 5).toString());
int statusIdTemp = Integer.parseInt(tableModel.getValueAt(tempRow, 6).toString());
String operatingDateTemp = tableModel.getValueAt(tempRow, 7).toString();
MosaicPanel tempPanel =
new MosaicPanel(fileIdTemp, dateFromTemp, dateToTemp, processIdTemp, statusIdTemp, operatingDateTemp);
rootPanel.add(tempPanel);
}
rootPanel.revalidate();
}
The main reason, why you couldn't see your JPanel is that you are using FlowLayout as the LayoutManager for the rootPanel. And since your JPanel added to this rootPanel has nothing inside it, hence it will take it's size as 0, 0, for width and height respectively. Though using GridLayout such situation shouldn't come. Have a look at this code example attached :
import java.awt.*;
import javax.swing.*;
public class PanelAddition
{
private void createAndDisplayGUI()
{
JFrame frame = new JFrame("Panel Addition Example");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel contentPane = new JPanel();
contentPane.setLayout(new GridLayout(0, 1));
JScrollPane scroller = new JScrollPane();
CustomPanel panel = new CustomPanel(1);
contentPane.add(panel);
scroller.setViewportView(contentPane);
frame.getContentPane().add(scroller, BorderLayout.CENTER);
frame.pack();
frame.setLocationByPlatform(true);
frame.setVisible(true);
for (int i = 2; i < 20; i++)
{
CustomPanel pane = new CustomPanel(i);
contentPane.add(pane);
contentPane.revalidate();
contentPane.repaint();
}
}
public static void main(String... args)
{
SwingUtilities.invokeLater(new Runnable()
{
public void run()
{
new PanelAddition().createAndDisplayGUI();
}
});
}
}
class CustomPanel extends JPanel
{
public CustomPanel(int num)
{
JLabel label = new JLabel("" + num);
add(label);
}
#Override
public Dimension getPreferredSize()
{
return (new Dimension(200, 50));
}
}
Don't use FlowLayout for the rootPanel. Instead consider using BoxLayout:
JPanel rootPanel=new JPanel();
// if you want to stack JPanels vertically:
rootPanel.setLayout(new BoxLayout(rootPanel, BoxLayout.PAGE_AXIS));
Edit 1
Here's an SSCCE that's loosely based on your latest code posted:
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.util.Random;
import javax.swing.*;
#SuppressWarnings("serial")
public class PanelsEg extends JPanel {
private static final int MAX_ROW_COUNT = 100;
private Random random = new Random();
private JPanel rootPanel = new JPanel();
public PanelsEg() {
rootPanel.setLayout(new BoxLayout(rootPanel, BoxLayout.PAGE_AXIS));
JScrollPane scrollPane = new JScrollPane(rootPanel);
scrollPane.setPreferredSize(new Dimension(400, 400)); // sorry kleopatra
add(scrollPane);
add(new JButton(new AbstractAction("Foo") {
#Override
public void actionPerformed(ActionEvent arg0) {
foo();
}
}));
}
public void foo() {
rootPanel.removeAll();
// rootPanel.setLayout(new BoxLayout(rootPanel, BoxLayout.PAGE_AXIS)); // only need to set layout once
int rowCount = random.nextInt(MAX_ROW_COUNT);
for (int tempRow = 0; tempRow < rowCount ; tempRow++) {
int fileIdTemp = tempRow;
String data = "Data " + (tempRow + 1);
MosaicPanel tempPanel =
new MosaicPanel(fileIdTemp, data);
rootPanel.add(tempPanel);
}
rootPanel.revalidate();
rootPanel.repaint(); // don't forget to repaint if removing
}
private class MosaicPanel extends JPanel {
public MosaicPanel(int fileIdTemp, String data) {
add(new JLabel(data));
}
}
private static void createAndShowGui() {
PanelsEg mainPanel = new PanelsEg();
JFrame frame = new JFrame("PanelsEg");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add(mainPanel);
frame.pack();
frame.setLocationByPlatform(true);
frame.setVisible(true);
}
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGui();
}
});
}
}
This SSCCE works, in that it easily shows removing and adding JPanels to another JPanel that is held by a JScrollPane. If you're still having a problem, you should modify this SSCCE so that it shows your problem.

set size and position for button

There are two buttons
left = new JButton("prev");
right = new JButton("next");
I add them to jframe like this
mainframe.add(left,BorderLayout.WEST);
mainframe.add(right,BorderLayout.EAST);
But there have got height the same as mainframe's height. How to set my own width and height?
And how to set their position(not only in the NORTH,WEST,EAST,SOUTH)?.
How to set my own width and height
Don't do that, instead just constrain the size using the NORTH or SOUTH of a JPanel that itself is added to the EAST or WEST of the outer (parent) layout.
Much like this:
import java.awt.*;
import javax.swing.*;
class BorderGUI {
BorderGUI() {
JPanel gui = new JPanel(new BorderLayout(2,2));
JPanel westConstrain = new JPanel(new BorderLayout(2,2));
// LINE_START will be WEST for l-r languages, otherwise EAST
gui.add(westConstrain, BorderLayout.LINE_START);
JPanel westControls = new JPanel(new GridLayout(0,1,2,2));
for (int ii=1; ii<3; ii++) {
westControls.add( new JButton("" + ii) );
}
westConstrain.add(westControls, BorderLayout.PAGE_START);
JPanel eastConstrain = new JPanel(new BorderLayout(2,2));
gui.add(eastConstrain, BorderLayout.LINE_END);
JPanel eastControls = new JPanel(new GridLayout(0,1,2,2));
for (int ii=1; ii<4; ii++) {
eastControls.add( new JButton("" + ii) );
}
// show at the bottom
eastConstrain.add(eastControls, BorderLayout.PAGE_END);
gui.add( new JScrollPane(new JTextArea(6,10)), BorderLayout.CENTER );
JOptionPane.showMessageDialog(null, gui);
}
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
#Override
public void run() {
new BorderGUI();
}
});
}
}

Categories

Resources