How to reshape JFrame

Hi fellas,
I'd like to create a JFrame looking like a star ( i.e not square ).
How can I reshape the frame ?

yea I didn't see that... no big deal

Similar Messages

  • How to make JFrame become the topmost window?

    I have server that is supposed to show a TOPMOST JFrame window each time it gets a "Show Window" command from client. I use JFrame to create and show the window in the server code:               
    JFrame mainWin = new JFrame();
    mainWin.setResizable( false );
    Container mainContainer = mainWin.getContentPane();
    mainContainer.setLayout( null );
    // add components to mainContainer
    mainWin.setVisible( true );
    mainWin.show();
    mainWin.toFront();
    If I run the server under windows platform, the first created JFrame window is always hiding behind under other application windows. However, the JFrame windows other than the 1st one are always at top.
    The BAD thing is, if I run the server under Macintosh platform, the JFrame windows are always hiding behind the other application windows.
    Does anyone know how to fix the problem? i.e., making the JFrame window appear on top of other windows under any platforms?
    Thanks.
    ZZ
    p.s. I am using JDK version is 1.3.0.

    there is some weirdness with java I've noticed under windows during development. When you start the app from a console window or script, if you change focus to another window before the first java window shows up, it will show up behind the window you changed focus to. If you leave it alone until the window shows, it will be on top. A work around is after you call show(), call toFront().

  • How to use JFrame's setLayeredPane() method?

    I want to custom JFrame's LayeredPane by setLayeredPane() method,but it does't work.
    Anyone who can help me?
    The code as follows:
    import javax.swing.*;
    import java.awt.*;
    public class LayeredTest{
        public static void main(String[] args){
            SwingUtilities.invokeLater(new Runnable(){
                public void run(){
                    new MyFrame().setVisible(true);
    class MyFrame extends JFrame{
        public MyFrame(){
            super("LayeredTest");
            setLayeredPane(new JLayeredPane());           //this line, I want to set the LayeredPane myself;
                                                          //but it doesn't work.
            JPanel panel =new JPanel();
            panel.setPreferredSize(new Dimension(320,240));
            panel.add(new JLabel("Label"));
            panel.add(new JButton("Button"));
            add(panel);
            setDefaultCloseOperation(EXIT_ON_CLOSE);
            pack();   
    }

    Thanks!
    But the very thing I want to know is "How to set Layered Pane(by setLayeredPane() method)",
    not "How to use Layered Pane".

  • How to customize JFrame

    hi guys...im quite new to java swing..i have this problem and hope u can help me with this..
    i now creating an Help frame....i want to have it using the hard coding way...now i want to modify the buttons(or clickable thingy) of the Jframe..
    These are found at the top right portion of the frame..( like the minimize, maximize and close buttons..)
    and i would like to add new button like a question mark like those help frames from other application...
    to really understand what i mean, just right click on your desktop and click properties...and u will see a frame/window with a question mark at
    the top right...
    HOW CAN I DO THIS?!

    I'd been playing around with this (as you can guess) and even after incorporating that line I still get a disabled max button, what am I doing wrong?import java.awt.BorderLayout;
    import java.awt.Color;
    import java.awt.Dimension;
    import java.awt.GradientPaint;
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import java.awt.GridBagConstraints;
    import java.awt.GridBagLayout;
    import java.awt.Insets;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.MouseEvent;
    import java.awt.event.MouseListener;
    import java.awt.event.MouseMotionListener;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JOptionPane;
    import javax.swing.JPanel;
    import javax.swing.SwingUtilities;
    import javax.swing.UIManager;
    import javax.swing.UnsupportedLookAndFeelException;
    import javax.swing.border.BevelBorder;
    import javax.swing.border.EmptyBorder;
    public class HelpFrame
          extends JFrame implements ActionListener, MouseListener, MouseMotionListener {
       JLabel title = new JLabel ("Help Button Frame");
       JButton close = new TitleBarButton ("X");
       JButton help = new TitleBarButton ("?");
       JPanel titleBar;
       JPanel content = new JPanel ();
       int mouseX, mouseY;
       public HelpFrame () {
          try {
             UIManager.setLookAndFeel (UIManager.getSystemLookAndFeelClassName ());
          } catch (UnsupportedLookAndFeelException ex) {
             ex.printStackTrace ();
          } catch (IllegalAccessException ex) {
             ex.printStackTrace ();
          } catch (InstantiationException ex) {
             ex.printStackTrace ();
          } catch (ClassNotFoundException ex) {
             ex.printStackTrace ();
          addMouseMotionListener (this);
          addMouseListener (this);
          // uncomment to remove original borders & title bar
          //setUndecorated (true);
          // and comment this
          setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
          // Added as per Michael's advice
          JFrame.setDefaultLookAndFeelDecorated(true);
          setResizable (false);
          title.setForeground (Color.WHITE);
          help.setToolTipText ("Help");
          help.addActionListener (this);
          close.setToolTipText ("Close");
          close.addActionListener (this);
          titleBar = new JPanel () {
             @Override
             public void paintComponent (Graphics g) {
                super.paintComponent (g);
                Graphics2D g2 = (Graphics2D) g;
                // magic numbers for WinXP default title bar color gradient
                g2.setPaint (new GradientPaint (0, 0, new Color (10, 36, 106),
                      getWidth (), 0, new Color (166, 202, 240)));
                g2.fillRect (0, 0, getWidth (), getHeight ());
          titleBar.setPreferredSize (new Dimension (500, 24));
          titleBar.setBorder (new EmptyBorder (1, 2, 0, 2));
          titleBar.setLayout (new GridBagLayout ());
          titleBar.addMouseListener (this);
          titleBar.addMouseMotionListener (this);
          GridBagConstraints gbc = new GridBagConstraints ();
          gbc.insets = new Insets (2, 5, 2, 0);
          gbc.gridx = 0;
          gbc.gridy = 0;
          gbc.weightx = 1.0;
          gbc.fill = GridBagConstraints.HORIZONTAL;
          titleBar.add (title, gbc);
          gbc.insets = new Insets (2, 2, 2, 2);
          gbc.gridx = 1;
          gbc.weightx = 0.0;
          gbc.fill = GridBagConstraints.NONE;
          titleBar.add (help, gbc);
          gbc.insets = new Insets (2, 0, 2, 0);
          gbc.gridx = 2;
          titleBar.add (close, gbc);
          content.setLayout (new BorderLayout ());
          content.setBorder (new BevelBorder (BevelBorder.RAISED));
          content.setPreferredSize (new Dimension (500, 300));
          setContentPane (content);
          add (titleBar, BorderLayout.NORTH);
       void makeUI () {
          pack ();
          setLocationRelativeTo (null);
          setVisible (true);
       public void actionPerformed (ActionEvent e) {
          if (e.getSource () == close) {
             dispose ();
             System.exit (0);
          } else if (e.getSource () == help) {
             JOptionPane.showMessageDialog (this,
                   "Your help comes here!",
                   "Help",
                   JOptionPane.QUESTION_MESSAGE);
       public void mouseDragged (MouseEvent e) {
          if (e.getSource () == titleBar) {
             setLocation (getX () + e.getX () - mouseX,
                   getY () + e.getY () - mouseY);
       public void mousePressed (MouseEvent e) {
          mouseX = e.getX ();
          mouseY = e.getY ();
       public void mouseReleased (MouseEvent e) { }
       public void mouseMoved (MouseEvent e) {}
       public void mouseClicked (MouseEvent e) {}
       public void mouseEntered (MouseEvent e) {}
       public void mouseExited (MouseEvent e) {}
       public static void main (String[] args) {
          SwingUtilities.invokeLater (new Runnable () {
             public void run () {
                new HelpFrame ().makeUI ();
    class TitleBarButton extends JButton {
       TitleBarButton (String caption) {
          super (caption);
          setPreferredSize (new Dimension (18, 18));
          setMargin (new Insets (2, 2, 2, 2));
          setBorder (new BevelBorder (BevelBorder.RAISED));
          setFocusPainted (false);
          setFocusable (false);
          //setRolloverEnabled (false);
    }Thanks, Darryl

  • How to create Jframe?

    How to create a basic programme that shows JFrame?
    Please guide me.

    Similarly,
    public class ThePanel extends JPanel implements <insert list of listeners here>
    }There are any number of things wrong with having a frame/panel subclass defined this way.
    1. Often coders with any number of disparate buttons make their
    frame or panel listener to them all:
    public class ThePanel extends JPanel implements ActionListenerThen the actionPerformed method is a laundry list of if/then/elseifs. Ugh.
    That's the perfect situation for specific action objects listening to specific controls.
    2. Exposing implementation details: the fact that the panel is listening
    to list selection is not part of the API for the panel, it's an implementation
    detail, yet that's not what this reads as:
    public class ThePanel extends JPanel implements ListSelectionListenerWhat's to stop other code from doing the following?
    unrelatedList.addListSelectionListener(thePanel); //woops, thePanel wasn't meant to listen to *that* list.It's surprising what cruft people won't tolerate in other areas of code are
    happy to commit in Swing code.
    Message was edited by:
    DrLaszloJamf

  • How to bring JFrame to front?

    Hi everybody,
    I have a JFrame which contains a button that opens another JFrame. This second JFrame is actually already created, clicking the button will just make it visible. Does anybody know how I can move this second JFrame to the front? I tried frame.toFront(), but that didn't work.
    Best regards,
    Jethro Borsje

    Read about toFront in the API
    http://java.sun.com/j2se/1.5.0/docs/api/java/awt/Windo
    w.html#toFront
    Some platforms may not permit this VM to place its
    Windows above windows of native applications, or
    Windows of other VMs.
    On Windows OS for example toFront causes the icon on
    the Task Bar to flicker, but the window stays in the
    back.
    The only think that will force the window to front is
    setAlwaysOnTop.
    frame.setAlwaysOnTop(true);
    frame.setAlwaysOnTop(false);
    Thank you very much, that did the trick!

  • How to change JFrame Defult Shape ?

    Hello All,
    JFrame defult shape is rectanguler, i want to change it
    in oval shape or circluer shape or any other shape.
    Any body tell me how it is posible, if any example code then please
    Help.
    i m thanksfull.
    Arif.

    Its somehow a tedious job and I havent tryied that!
    You have to make use of JNI.

  • How to display JFrame objects in a sequence

    Hello,
    I have several classes that extend JFrame each of which represent a GUI screen for an application. I would like to display these screens one after another. I am creating objects from these classes in another class, in the sequence I wish them to be displayed. The problem I am facing is that all the screens are being displayed at once. Please let me know how can I display these screens in the order that I want.
    Please forgive me if I am out of topic as this is my first message posting.
    Thanks,
    Kalyan

    Hello,
    Thanks a lot for your help. I will definitely try it.
    Thanks,
    Kalyan
    hi
    i'm assuming that at any one time there is only one
    JFrame, ie. one screen you describe is displayed at
    any one time and all others are not visible.
    try using CardLayout. CardLayout allows you to add
    multiple components to the layout yet displays only
    one component at a time in whatever order you wish.
    So, have only one JFrame and add the other screens
    perhaps as JPanel objects to the frame.
    check the API docs on CardLayout - its quite nifty.
    Takis

  • How to make JFrame default Maximum size state?

    Hi all,
    Is there any one know how to construct a JFrame that setMaximum when screen show?
    another word mean the JFrame in Maximum state byb default.
    regards,
    elvis
    scjp

    Pheeeewww...
    Don't people ever search the forum and read older posts?
    Both the question and the partly wrong answer have appeared many, many times before.
    In pre-1.4 Java you simply cannot maximize a frame.
    The 'solution' is probably the best you can do, but it does not really maximize the frame:
    * The user can still move/resize it.
    * It does not take into account the size/position of the windows task bar or any other window manager palette windows.
    There also has been a solution that uses the Robot class to simulate a click on the maximize button, but that's a real dirty trick, that won't work in applets and strongly depends on the exact layout of the window's decorations.
    In Merlin you can programatically maximize a frame as well as find out the screen's insets (resulting from the task bar...)
    Stephen

  • How to make JFrame positioned to lower right corner of user's desktop

    I'm a new java user, and I'm working on building a small
    application. When the application is launched, I would
    like the application (JFrame) window to be positioned
    in the lower right corner of the user's desktop. Does
    anyone know how to get the user's desktop size so
    I can position the application.
    Here is a code snippet where I lauch the app.
    public static void main(String args[]) {
    ArchiveRestore mainFrame = new ArchiveRestore();
    mainFrame.setSize(500, 500);
    mainFrame.setTitle("Master Model Automation");
    mainFrame.setVisible(true);
    Thanks
    -cliff

    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    Will get the screen size. The Toolkit class is in the java.awt package.

  • How to make JFrame scrollable?

    How can I make a JFrame scrollable? So that when I resize the JFrame to a smaller size the contents remain accessible? The way it is now is that when I resize a JFrame I can't access the components that fall out of the window (I'm using absolute component positioning within the JFrame). I thought adding two scrollbars to take care of this would be easy, but so far I haven't been able to get it right. Any suggestions would be appreciated.

    Why dont you put all your components in a JPanel, add a scrollpane to it and then add that JPanel to
    ur JFrame.
    += KRR

  • How to make jframe transparent?

    Hi
      some software's uses the monitor as a whiteboard to draw or to type text. How is this possible? I mean i thought that by making a  jframe (full screen) transparent we should be able to do this?   Is my understanding right? if so how to make the jframe transparent? when jframe is transparent will we be able to draw on it?

    Try this:
    public static void main(String[] args) {
      SwingUtilities.invokeLater(new Runnable() {
      @Override public void run() {
      JFrame f = new JFrame();
      f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      f.setUndecorated(true);
      f.setBackground(new Color(0,0,0,0));
      f.setExtendedState(JFrame.MAXIMIZED_BOTH);
      f.add(new JComponent() {
      @Override protected void paintComponent(Graphics g) {
      g.setColor(Color.BLUE);
      ((Graphics2D)g).setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
      g.fillOval(0, 0, getWidth(), getHeight());
      f.setVisible(true);
    Message was edited by: 946128 in respose to PhHein's comment

  • How to make JFrame window un-resizable?

    I create a window using JFrame. I don't want user to re-size the window. How can I do that? Thanks!

    JFrame f = new JFrame();
    f.setResizable(false);
    Jframe entends frame
    setResizable() is a method in frame
    http://java.sun.com/j2se/1.4.2/docs/api/java/awt/Frame.html#setResizable(boolean)

  • How to set JFrame's LayeredPane?

    Hello,eveyone!
    I wat to set JFrame's LayeredPane by JFrame's setLayeredPane() method.
    My code as follow:
    import javax.swing.*;
    import java.awt.*;
    public class LayeredTest{
        public static void main(String[] args){
            SwingUtilities.invokeLater(new Runnable(){
                public void run(){
                    new MyFrame().setVisible(true);
    class MyFrame extends JFrame{
        public MyFrame(){
            super("LayeredTest");
            setLayeredPane(new JLayeredPane());           //this line, I want to set the LayeredPane myself;
                                                          //but it doesn't work.
            JPanel panel =new JPanel();
            panel.setPreferredSize(new Dimension(320,240));
            panel.add(new JLabel("Label"));
            panel.add(new JButton("Button"));
            add(panel);
            setDefaultCloseOperation(EXIT_ON_CLOSE);
            pack();   
    }But the application runs abnormality.
    Any one tells me why and how to modify?
    thanks!
    Message was edited by:
    Eastsun

    The content pane of the JFrame should be added to the layered pane.
    When you set a new layered pane, it doesn't automatically do that.
    Add this after you add the new layered pane:
    layeredPane.add(contentPane, JLayeredPane.FRAME_CONTENT_LAYER);

  • How to run  JFram in IE

    Dear Friends
    I am wondering how to run a Jframe inside an HTML code, Please.
    Also, The frame I have is developed in netBeans.
    Thanx

    I am wondering how to run a Jframe inside an HTML
    code, Please.You can't "run a JFrame in HTML". But you can embed an applet and have that display a JFrame.

Maybe you are looking for

  • IOS 6 Crashed my iPhone 4!! What to do??

    Can anyone help a girl who's not very technically saavy?? I made the HUGE mistake of installing iOS 6 on my iPhone 4 this morning. All seemed to be working fine. This evening I tried to reply to a text, and the screen was blank. So I tried to send a

  • Mobileme widget not working

    I have a page set up in iWeb 09 and have a album page with all our mobileme gallery zI went to add a new mobileme widget and it does not see anything at all. I clicked to move 2 other ones and they are dead now as the others keep working. What is goi

  • My iTunes Account Has Dissapeared from my computer!

    I cannot find my Itunes Store/ Account anywhere on my PC! Anything I can do?

  • How to know an event is meeting or todo or anniversary?

    Hi, Is it possible to know whether an event is Meeting or anniversary or to do using the j2me pim api.(i,e If we are working with a current event means how can we know that event belongs to meeting or todo. regards, kumar

  • Need to get Object key

    Hi All, In transaction 'APPCREATE' im going to create appraisal process. Once i created the appraisal, then 'Appraisal ID' will be generated. Now I need to get the generated appraisal ID. Can i use change document header table for that? I have no ide