EarthWeb
Developer.com
Site
windows 2000
visual c++
java
visual basic
javascripts
recommend it
 
Book
thinking in java
 
Interact
forum
guest book
jobs
jokes
what's new

share code
 
Resource
add resource
modify resource
new resource
 

[Internet Jobs]
-----
Java by E-mail:

Get the weekly e-mail highlights on Java!
-----

-

Have borders on a JWindow/JFrame


Author: Real Gagnon
Author's WebSite: http://tactika.com/realhome/realhome.html

You can't have a border directly on a JWindow or JFrame. You need to put a JPanel with the desired border using the default JWindow/JFrame LayouManager (a BorderLayout). Then the JPanel is extended giving the impression that its borders are the JWindow one.


 import com.sun.java.swing.*;
 import com.sun.java.swing.border.*;
 // import javax.swing.*;
 // import javax.swing.border.*;
 import java.awt.event.*;
 import java.awt.*;

 public class MyWindow{
   public static void main(String s[]) {
     JWindow win = new JWindow();
         
     JPanel pan = new JPanel();
     pan.setBorder(new LineBorder(Color.blue));
     win.getContentPane().add(pan,"Center");
         
     pan.setLayout(new FlowLayout());
     pan.add(new JButton("Hello"));
     pan.add(new JButton("World"));

     win.setSize(200,200);
     win.setVisible(true);
     }
 }



Posted On: 5-Jul-1999

internet.commerce



Acceptable Use Policy

JupiterOnlineMedia

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Web Hosting | Newsletters | Tech Jobs | Shopping | E-mail Offers