JFrame.setSize() problem

I'm facing a strange problem. I have a class derived from JFrame which is the main application frame window. Problem is I'm not able to set its size arbitrarily e.g. in following call to setSize(...) even if I replace 700 with 100 OR 1000 or whatever, the frame is always displayed of some fixed size . I can't find out why .. any clues ?
JGuessFrame() {
this.setSize(700, 700);   
// Center the window on the screen
setLocationRelativeTo(null);
setDefaultLookAndFeelDecorated(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}

try this:
JGuessFrame() {
this.setSize(700, 700);
// Center the window on the screen
setLocationRelativeTo(null);
setDefaultLookAndFeelDecorated(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.pack(); // maybe this will help
// if not then try this
this.repaint();

Similar Messages

  • JFrame applications problem

    Hi, i'm just starting out writing swing applications and i'm having a few problems.
    Don't bother answering this if you think i'm too stupid because i don't want to waste your time.
    Whenever i write a swing application, it compiles but when i try to run it i get: <b>Exception in thread "main" java.lang.NoSuchMethodError: main</b>
    Heres my code:
    <code>
    import java.awt.*;
    import javax.swing.*;
    public class swingframe extends JFrame
         private JButton but;
         public swingframe()
                   Container c=getContentPane();
                   c.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 5));
                   c.setBackground(Color.black);
                   but = new JButton("Wyld Stallyns Rule!!!");
                   but.setBackground(Color.green);
                   c.add(but);
    </code>
    Sorry again if i'm wasting your time.
    <b>Thanks</b>

    import java.awt.*;
    import javax.swing.*;
    public class SwingFrame extends JFrame{
       private JButton but;
       public SwingFrame(){
          Container c=getContentPane();
          c.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 5));
          c.setBackground(Color.black);
          but = new JButton("Wyld Stallyns Rule!!!");
          but.setBackground(Color.green);
          c.add(but);
          this.setSize(200, 200);
          this.setDefaultCloseOperation( EXIT_ON_CLOSE );
       public static void main(String []args){
          new SwingFrame().show();
    }

  • JFrame refesh problem

    I was building a huge app... And at one point, a problem appeared. Spent hours on it. Then I cut it down to the most simple element.
    I have an app, this is all it does: creates a frame and changes the color of the background. Yet for some reason, I need to resize for the background color to be applied.
    JFrame APP_FRAME = new JFrame();          
    APP_FRAME.getContentPane().setBackground( Color.black );
    APP_FRAME.setBackground( Color.black );
    APP_FRAME.setVisible( true );
    APP_FRAME.setSize( 645, 512 );
    That's all it is! The black background doesn't apply unless I resize! It works when I set the background color directly on the frame rather than the ContentPane... But later on, I add tons of things in my ContentPane, and I still have the bug of having to resize to get an initial display.
    I would appreciate any help, I can't believe I'm stuck on such a detail!
    Thanks in advance,
    JN

    Still nothing...
    I created a whole new program:
    import java.awt.Color;
    import javax.swing.JFrame;
    JFrame frm = new JFrame();
    frm.setVisible(true);
    frm.getContentPane().setBackground(Color.blue);
    frm.pack();
    frm.setSize(640,480);
    as simple as it gets.. My windows appears in 640X480 but with a gray background. Why doesn't it start off in blue! :-(

  • JFrame Repaint problem

    I am new to Java Swing and I have a problem.
    I have a GUI program which extends JFrame and contains some business logic. In the middle of executing the business logic, I need to display a chart and I used another JFrame to display the chart. The chart did display but once the control return back to the original process, the chart Jframe turn blank. How can I get the display of the chart until user closes it?
    public class ChangeMetric extend JFrame implements ActionListener {
    public void actionPerformed(ActionEvent event) {
    JFrame jf = new JFrame();
    JPanel jp = new JPanel();
    jp.setSize(500,500);
    jf.getContentPane().add(jp);
    jf.setVisible(true);
    JOptionPane.showConfirmDialog(null, "Report has been saved to : " + path + "\n " +
                   "Do you want another report?", "Completed", JOptionPane.YES_NO_OPTION);
    //Jf turn blank after the JoptionPane displayed.
    Thanks in advance.
    Alex

    I need to display a chart and I used another JFrame to display the chart.An application should only have a single JFrame. Use a JDialog instead. You create it the same way you do a JFrame, the only difference is you specify the frame as the owner.
    Jf turn blank after the JoptionPane displayed.Then you must be doing something really wierd in your code. There is no reason for the option pane to have any effect on your dialog.
    And when you post your SSCCE, don't forget to use the Code Formatting Tags so the posted code retains its original formatting. That is done by selecting the code and then clicking on the "Code" button above the question input area.

  • Undecorated jframe resize problem

    i created a custom jframe look by setting a jframe to undecorated and designing my own maximize/minimize/close buttons and other things to improve its appearence
    the problem is that when set to undercorated all the default resizing/move methods are gone
    i tried implementing my own resize methods, they seem to work but it flashes like crazy while resizing
    anyone have any idea how to stop all the flashing or a better way to implement this?
    the following is a small example of the problem i am having, i only implemented the north resize part so the code can be easier to read.
    thnx in advance
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.imageio.*;
    import java.io.*;
    import java.awt.image.BufferedImage;
    public class TestFrame extends JFrame implements MouseMotionListener, MouseListener
         Point sp;
         int     compStartHeight;
         int minHeight = 100;
         JPanel frameContent = new JPanel();
         public TestFrame()
              super("testing frame");
              setSize(600, 600);
              setContentPane(frameContent);
              frameContent.setBackground(Color.black);
              frameContent.setLayout(new BoxLayout(frameContent, BoxLayout.Y_AXIS));     
              setUndecorated(true);
              addMouseMotionListener(this);
              addMouseListener(this);
              JButton testButton = new JButton("TEST");
              JButton testButton2 = new JButton ("TEST2");
              frameContent.add(testButton);
              frameContent.add(Box.createVerticalGlue());
              frameContent.add(testButton2);
              setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              setVisible(true);
         public void mouseMoved(MouseEvent e)
              Point p = e.getPoint();
              if (p.y > e.getComponent().getSize().height - 5)
                   setCursor( Cursor.getPredefinedCursor( Cursor.N_RESIZE_CURSOR ));
              else
                   setCursor( Cursor.getPredefinedCursor( Cursor.DEFAULT_CURSOR));
         public void mouseDragged(MouseEvent e)
              Point p = e.getPoint();
              int compWidth = getSize().width;
              if (getCursor().getType() == Cursor.N_RESIZE_CURSOR)
                   int nextHeight = compStartHeight+p.y-sp.y;
                   if (nextHeight > minHeight)
                        setSize(compWidth,nextHeight);
                        validate();
              else
                   int x = getX()+p.x-sp.x;     
                   int y = getY()+p.y-sp.y;     
                   setLocation(x,y);
         public void mousePressed(MouseEvent e)
              sp = e.getPoint();
              compStartHeight = getSize().height;
         public void mouseEntered(MouseEvent e)
        public void mouseExited(MouseEvent e)
              if (sp == null)
                   setCursor( Cursor.getPredefinedCursor( Cursor.DEFAULT_CURSOR));
        public void mouseClicked(MouseEvent e)
        public void mouseReleased(MouseEvent e)
              sp = null;
         public static void main(String[] args)
         new TestFrame();
    }

    I doubt there is a faster / easier way to resize.
    Have you tried adding
    public boolean isDoubleBuffered()
      return true;
    }To over-ride Component.isDoubleBuffered. This should sort out your flickering problem.
    Bamkin

  • JFrame setlocation problems on linux

    When you drag a JFrame, you can move it anywhere you want, even if some of its boundary goes outside the screen...
    Fortunately It's true on windows, mac and linux SUN JREs.
    On windows and mac, you get the same effect if you decide to do it programatically with for example :
    package testframe;
    import javax.swing.JFrame;
    public class Main {
        public static void main(String[] args) {
        JFrame jf=new JFrame();
        jf.setVisible(true);
        jf.setSize(400, 400);
        jf.setLocation(-300, 50);
    }But this code doesn't work as expected on linux distros. I tried on kde, gnome and xfce, and I always get the same problem : the JRE (probably because of calls to window manager) refuses to place the window a little bit outside the screen boundaries. So in my example, jf.setLocation(-300,50) have the same effect as jf.setLocation(0,50).
    Of course, when the windows appear at the (0,50) coordinates, it's always possible on linux to move it manually to a negative x-coordinate place.
    setBounds method will lead to the same trouble...
    Of course this piece of code is only here to show exactly what's wrong on linux sun jre's. In my "real code", I need to deal with undecorated Jframes, so I have to manage myself the mousepressed and mousedragged events on my custom titlebar, and I would really want the linux version of my application behave the same as windows and mac versions ...
    The weird thing is that if I try to do that with JWindows in place of JFrames, it work's fine on Linux as well. But the problem is not here : in my case I need JFrames...
    Anyone knows how to fix this on linux ?

    When you drag a JFrame, you can move it anywhere you want, even if some of its boundary goes outside the screen...
    Fortunately It's true on windows, mac and linux SUN JREs.
    On windows and mac, you get the same effect if you decide to do it programatically with for example :
    package testframe;
    import javax.swing.JFrame;
    public class Main {
        public static void main(String[] args) {
        JFrame jf=new JFrame();
        jf.setVisible(true);
        jf.setSize(400, 400);
        jf.setLocation(-300, 50);
    }But this code doesn't work as expected on linux distros. I tried on kde, gnome and xfce, and I always get the same problem : the JRE (probably because of calls to window manager) refuses to place the window a little bit outside the screen boundaries. So in my example, jf.setLocation(-300,50) have the same effect as jf.setLocation(0,50).
    Of course, when the windows appear at the (0,50) coordinates, it's always possible on linux to move it manually to a negative x-coordinate place.
    setBounds method will lead to the same trouble...
    Of course this piece of code is only here to show exactly what's wrong on linux sun jre's. In my "real code", I need to deal with undecorated Jframes, so I have to manage myself the mousepressed and mousedragged events on my custom titlebar, and I would really want the linux version of my application behave the same as windows and mac versions ...
    The weird thing is that if I try to do that with JWindows in place of JFrames, it work's fine on Linux as well. But the problem is not here : in my case I need JFrames...
    Anyone knows how to fix this on linux ?

  • JFrame decorations problem

    Greetings:
    I've found searching at the net, that it is suggested "that the L&F (rather than the system) decorate all windows. This must be invoked before creating the JFrame. Native look and feels will ignore this hint". The command that does this is the static JFrame.setDefaultLookAndFeelDecorated(true); .
    If I install Metal L&F as default, and then go to Full Screen and change the L&F, it partially WORKS (the Metal L&Fdecorations are set like in an InternalFrame); but if I set the System L&F as default and change the L&F, the new L&F does not recive its propper decorations but rather the system ones.
    Could anyone help me in this issue?
    Thanks a lot in advanced.
    Javier
    // java scope
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.border.*;
    import com.sun.java.swing.plaf.motif.*;
    public abstract class LandFTest {
       public static void main(String[] args) {
          try {UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } //UIManager.getCrossPlatformLookAndFeelClassName()
          catch (Exception e) { }
          SwingUtilities.invokeLater(new Runnable() {
             public void run() { JFrame.setDefaultLookAndFeelDecorated(true);
                                 MainWin myWindow = new MainWin(" Look & Feel Test");
                                 myWindow.pack();
                                 myWindow.setVisible(true); }
    class MainWin extends JFrame {
          public Box mainLayout = new MainComponent(this);
             public JScrollPane mainLayoutScrollPane = new JScrollPane(mainLayout);
          public Boolean FullScrnOn=false;
       public MainWin (String mainWin_title) {
          Container framePanel = this.getContentPane();
          this.setTitle(mainWin_title);
          this.setLocationRelativeTo(null);
          this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          framePanel.add(mainLayoutScrollPane,BorderLayout.CENTER);
    class MainComponent extends Box {
          Box controls_Box = Box.createHorizontalBox();
          Box lfControl_Box = Box.createVerticalBox();
          JRadioButton landfRadioButton1 = new JRadioButton(" Metal skin (Java)"),
                       landfRadioButton2 = new JRadioButton(" System skin",true),
                       landfRadioButton3 = new JRadioButton(" Motif skin");
          ButtonGroup lanfFButtonGroup = new ButtonGroup();
          JButton fullScrnButton = new JButton("Full Screen On");
    public MainComponent(MainWin refFrame){
          super(BoxLayout.Y_AXIS);
          this.initMainCompopent(refFrame);
          this.setMainComponent();
       public void initMainCompopent (MainWin refFrame) {
           LookAndFeel_ActionListener landFListener = new LookAndFeel_ActionListener(lanfFButtonGroup, refFrame);
           FullScreen_ActionListener fullSCrnListener = new FullScreen_ActionListener(refFrame);
          lfControl_Box.setBorder(BorderFactory.createTitledBorder(" Look & Feel Control "));
          landfRadioButton1.setActionCommand("Java");
             landfRadioButton1.addActionListener(landFListener);
             lanfFButtonGroup.add(landfRadioButton1);
          landfRadioButton2.setActionCommand("System");
             landfRadioButton2.addActionListener(landFListener);
             lanfFButtonGroup.add(landfRadioButton2);
          landfRadioButton3.setActionCommand("Motif");
             landfRadioButton3.addActionListener(landFListener);
             lanfFButtonGroup.add(landfRadioButton3);
          fullScrnButton.addActionListener(fullSCrnListener);
          fullScrnButton.setAlignmentX(Component.CENTER_ALIGNMENT);
       public void setMainComponent () {
          controls_Box.add(Box.createHorizontalGlue());
          controls_Box.add(lfControl_Box);
             lfControl_Box.add(landfRadioButton1);
             lfControl_Box.add(landfRadioButton2);
             lfControl_Box.add(landfRadioButton3);
          controls_Box.add(Box.createHorizontalGlue());
          this.add(Box.createVerticalGlue());
          this.add(controls_Box);
          this.add(Box.createVerticalGlue());
          this.add(fullScrnButton);
          this.add(Box.createVerticalGlue());
    class LookAndFeel_ActionListener implements ActionListener {
          private ButtonGroup eventButtonGroup;
          private MainWin eventFrame;
       public LookAndFeel_ActionListener (ButtonGroup buttonGroup, MainWin eventFrame) {
          this.eventButtonGroup = buttonGroup;
          this.eventFrame = eventFrame;
       public void actionPerformed(ActionEvent event) {
          String command = eventButtonGroup.getSelection().getActionCommand();
          GraphicsDevice scrnDevice = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
          eventFrame.dispose();
          if (command.equals("System")) {
            try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); }
            catch (Exception e) { }
          else { if (command.equals("Java")) {
                   try { UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());}
                   catch (Exception e) { }
                 else { if (command.equals("Motif")) {
                          try { UIManager.setLookAndFeel(new MotifLookAndFeel()); }
                          catch (Exception e) { }
                        else { }
          SwingUtilities.updateComponentTreeUI(eventFrame);
          if (eventFrame.FullScrnOn){ try {scrnDevice.setFullScreenWindow(eventFrame); }
                                      finally {  }
          } else { JFrame.setDefaultLookAndFeelDecorated(true); }
          eventFrame.setVisible(true);
          //eventFrame.getRootPane().setWindowDecorationStyle(JRootPane.FRAME);
    class FullScreen_ActionListener implements ActionListener {
          private MainWin eventFrame;
       public FullScreen_ActionListener (MainWin eventFrame) {
          this.eventFrame = eventFrame;
       public void actionPerformed(ActionEvent event) {
             MainComponent mainFrameLayout = (MainComponent)eventFrame.mainLayout;
             GraphicsDevice scrnDevice = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
          if (!eventFrame.FullScrnOn){
             if (scrnDevice.isFullScreenSupported()) {
                // Enter full-screen mode with an undecorated JFrame
                eventFrame.dispose();
                eventFrame.setUndecorated(true);
                eventFrame.setResizable(false);
                mainFrameLayout.fullScrnButton.setText("Full Screen Off");
                eventFrame.FullScrnOn=!eventFrame.FullScrnOn;
                try {scrnDevice.setFullScreenWindow(eventFrame); }
                finally {  }
             } else { JOptionPane.showMessageDialog(eventFrame, "Full Screen mode is not allowed \nby the system in this moment.",
                                                                " Full Screen Info", JOptionPane.INFORMATION_MESSAGE); }
          else { // Return to Windowed mode mode with JFrame decorations
                  eventFrame.dispose();
                  eventFrame.setUndecorated(false);
                  eventFrame.setResizable(true);
                  mainFrameLayout.fullScrnButton.setText("Full Screen On");
                  eventFrame.FullScrnOn=!eventFrame.FullScrnOn;
                  try { scrnDevice.setFullScreenWindow(null); }
                  finally { }
          eventFrame.setVisible(true);
    }

    Greetings:
    Thanks a lot for your kind answer:
    After reading your reply, I've done some studies directly in the API in how does the L&F's are managed. Of what I've understood (please correct me if I'm wrong), the things are as follow:
    i) System and Motif Look and Feel's does NOT support decorations, so that's why you should let the JVM do the decoration work (that is, use myFrame.setUndecorated(false); ).
    In this case, it does not matter if you use JFrame.setDefaultLookAndFeelDecorated(true); before the creation of the frame: it won't show decorations if you don't use the command mentioned.
    ii) Metal (Java) Look and Feel DOES support decorations; that's why, if you use JFrame.setDefaultLookAndFeelDecorated(true); before the creation of the frame, you'll see it's own decorations. In this case, you should use myFrame.setUndecorated(true); so the L&F does all the decorating work, avoiding the weird sitiuation of showing double decorating settings (L&F's and native system's).
    iii) So, the real problem here would be if you want to have, as a user choice, that the System/Motif L&F's will be available together with the Java's (Metal). I've made the next variation to my code, so that this will be possible:
    class LookAndFeel_ActionListener implements ActionListener {
    private ButtonGroup eventButtonGroup;
    private MainWin eventFrame;
    public LookAndFeel_ActionListener (ButtonGroup buttonGroup, MainWin eventFrame) {
    this.eventButtonGroup = buttonGroup;
    this.eventFrame = eventFrame;
    public void actionPerformed(ActionEvent event) {
    String command = eventButtonGroup.getSelection().getActionCommand();
    GraphicsDevice scrnDevice = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
    eventFrame.dispose();
    if (command.equals("System")) {
    try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    eventFrame.setUndecorated(false); // make sure the native system controls decorations as this L&F doesnt's manage one's.
    catch (Exception e) { }
    else { if (command.equals("Java")) {
    try { UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); }
    catch (Exception e) { }
    eventFrame.setUndecorated(true); // make sure the L&F controls decorations as it actually has one's.
    else { if (command.equals("Motif")) {
    try { UIManager.setLookAndFeel(new MotifLookAndFeel()); }
    catch (Exception e) { }
    eventFrame.setUndecorated(false); // make sure the native system controls decorations as this L&F doesnt's manage one's.
    else { }
    SwingUtilities.updateComponentTreeUI(eventFrame);
    if (eventFrame.FullScrnOn){ try {scrnDevice.setFullScreenWindow(eventFrame); }
    finally { }
    } else { }
    eventFrame.setVisible(true);
    }iv) The issue here is that, as I needed to use myFrame.dispose() (the JVM says that it is not possible to use setUndecorated(false); in a displayable frame), I recieve and error:
    Exception in thread "AWT-EventQueue-0" java.lang.IllegalStateException: Buffers have not been created
    at sun.awt.windows.WComponentPeer.getBackBuffer(WComponentPeer.java:846)
    at java.awt.Component$FlipBufferStrategy.getBackBuffer(Component.java:3815)
    at java.awt.Component$FlipBufferStrategy.updateInternalBuffers(Component.java:3800)
    at java.awt.Component$FlipBufferStrategy.revalidate(Component.java:3915)
    at java.awt.Component$FlipBufferStrategy.revalidate(Component.java:3897)
    at java.awt.Component$FlipBufferStrategy.getDrawGraphics(Component.java:3889)
    at javax.swing.BufferStrategyPaintManager.prepare(BufferStrategyPaintManager.java:508)
    at javax.swing.BufferStrategyPaintManager.paint(BufferStrategyPaintManager.java:264)
    at javax.swing.RepaintManager.paint(RepaintManager.java:1220)
    at javax.swing.JComponent.paint(JComponent.java:1015)
    and, yet, the Metal (Java's) L&F keeps without decorations. Is it there a way to solve this without having to create a new instance of the frame and use JFrame.setDefaultLookAndFeelDecorated(true); before the creation of such new instance of the frame for the Metal's (Java) L&F?
    Thanks again for al lthe help: this was, definetelly, something not obvious to figure out (or to find a hint on the net).
    Regards,

  • JFrame minimizing problem

    I am writing an application where i have many JFrames on the screen at the same time. The problem is that when i click on a menu item in one of the screens the rest of them get minimized. Is there any way of preventing this without using JInternalFrames.

    can you please supply source code, I may not be able to help but other's can.

  • JFrame Dispose Problem

    Hello everyone,
    This is probably a really easily answerable question and I think the reason is that I have the problem is because I'm getting a stack overflow but I am not sure how to solve it.
    So, my program is a simple login and logout program
    A login JFrame creates a new Main JFrame when log in is pressed, then login is disposed.
    When a user logs out of the main frame, a new Login Frame is created and the Main Frame disposed
    The problem is that when the user logs in again, the main frame is created but the login frame remains even though dispose is called,
    why is this?
    Any help at all is greatly appreciated!
    Cheers

    why is this?You have a bug in your code.
    For more help create a [SSCCE (Short, Self Contained, Compilable and Executable, Example Program)|http://sscce.org], that demonstrates the incorrect behaviour.
    Don't forget to use the Code Formatting Tags so the posted code retains its original formatting. That is done by selecting the code and then clicking on the "Code" button above the question input area.

  • JFrame setResizable problem

    hi everybody,
    i'm using j2sdk1.4.2_03 and i want a JFrame all time maximized, i used:
    frame.setExtendedState(Frame.MAXIMIZED_BOTH);
    frame.setResizable(false);
    but if i double click on the upper bar the window is still resizable, do anybody of you know where is my problem?
    thanks

    http://developer.java.sun.com/developer/bugParade/bugs/4465093.html

  • JFrame Icon problem

    Hi I have manage to create a JFrame Icon & display it properly by running java <filename>.java it did show the frame & icon. But when i Put it into a JAR file, it cannot locate the Icon anymore (the icon folder are also in the jar file). How do I ask my testFrame.java file reference the icon in the jar file?

    try doing it this way
    import java.net.URL;
    import java.awt.*;
    import javax.swing.*;
    import javax.imageio.ImageIO;
    class Testing extends JFrame
      public Testing()
        Image img;
        try
          URL url = new URL(getClass().getResource("Save.gif"), "Save.gif");
          if (url != null)
            img = ImageIO.read(url);
            setIconImage(img);
        catch(Exception e){/*do nothing - default will display*/}
        setSize(100,100);
        setLocation(400,300);
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        JPanel p = new JPanel();
        getContentPane().add(p);
      public static void main(String[] args){new Testing().setVisible(true);}
    }

  • JFrame movability problem...

    Hi All.
    How to make the JFrame immovable.
    that is ,the frame should not be dragged or resized by the user.
    Kindly help me out to sove this problem.
    I tried frame.setResizable(false);
    but it does not worked out.
    Regards,
    Sdivyya

    javax.swing.JWindow.....

  • JFrame setUndecorated problem

    I set my JFrame undecorated like this:
    jframe.removeNotify();
    jframe.setUndecorated(true);
    jframe.setVisible(true);This works great, only my textFields get unselectable when i use removeNotify(). When i don't use removeNotify, my frame doesn't get undecorated. When i click on a button, the textfields are selectable again.
    How can i solve dis problem?

    oeps. it's the textfields are selectable again when an other frame is opened and the focus had gone back to the frame with the textFields.
    Probably it has something to do with a focus.... ???

  • JFrame restoration problem.

    Hello everyone!!
    My problem is:
    I have a jframe inside of that there's a jpanel.
    the jpanel mouse listener calls a method in a different class that uses the graphic reference of the jpanel to draw. once I minimize and maximize the jframe the drawing disappear. once I click on the area where drawing used to be it appears again.
    I have an inner window listener class in the jframe which calls the same method in the same instance of the other class but nothing happens until I click on the area on the mouse listener calls the method!!
    please help.

    Go through ths tutorial:
    The Java&#8482; Tutorials: [Performing Custom Painting|http://java.sun.com/docs/books/tutorial/uiswing/painting/index.html]
    After that, if you still have a question, post a SSCCE that clearly demonstrates the problem.
    db

  • SetSize problem!

    hi all
    Is there any reason for setSize doesn�t work?
    i dont why, its not working for me! :-(
    i have a class which extends JFrame and ihv added setSize(600,500) in constructor, juzt after super(title) !
    someone please help me!
    thanks and regards
    sarathy

    hi im so sorry to post this lengthy code.
    in the constructor part, im reading a text file to load the list box.
    import javax.swing.*;  
    import javax.swing.event.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    import org.jfree.ui.RefineryUtilities;
    public class ChartMaster extends JFrame implements ActionListener, ListSelectionListener {
         JList pfoList;
         String[] selectedPFO;
         * Create the GUI and show it.  For thread safety, this method should be invoked
          * from the event-dispatching thread (main in my case)
         public ChartMaster(String title) {
              super(title);
              setSize(800,600);
              //Create GUI look and feel as that of OS look and feel
              try {
                   UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
              } catch (Exception e) {e.printStackTrace(); }
            //Make sure we have nice window decorations.
            setDefaultLookAndFeelDecorated(true);
            //Create and set up the window.
            setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              Container c = getContentPane();
              c.setLayout(new BorderLayout());
              //List box
              DefaultListModel listModel =  loadDefaultListModel("PFOList.txt");
              pfoList = new JList(listModel);
            pfoList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION );
            pfoList.setSelectedIndex(0);
            pfoList.addListSelectionListener(this);
            pfoList.setVisibleRowCount(5);
              JScrollPane listScroller = new JScrollPane(pfoList);
            listScroller.setPreferredSize(new Dimension(150, 400));
            listScroller.setAlignmentX(LEFT_ALIGNMENT);
              JPanel listPane = new JPanel();
            listPane.setLayout(new BoxLayout(listPane, BoxLayout.PAGE_AXIS));
            JLabel label = new JLabel("Select the PFO(s):");
            label.setLabelFor(pfoList);
            listPane.add(label);
            listPane.add(Box.createRigidArea(new Dimension(0,5)));
            listPane.add(listScroller);
            listPane.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
              //Date selection
              JPanel rightPanel = new JPanel();
            rightPanel.setLayout(new BoxLayout(rightPanel, BoxLayout.PAGE_AXIS));
              JLabel jl = new JLabel("Date selection");
            rightPanel.add(Box.createRigidArea(new Dimension(0,5)));
              JRadioButton forMonthYear = new JRadioButton("For the Month and Year");
              JRadioButton duringMonthYear = new JRadioButton("During the Month and Year");
              ButtonGroup bg = new ButtonGroup();
              bg.add(forMonthYear);
              bg.add(duringMonthYear);
              rightPanel.add(jl);
              rightPanel.add(forMonthYear);
              rightPanel.add(duringMonthYear);
              //rightPanel.add(
              //Bottom buttons
              JButton button = new JButton("Show me Chart");
            button.addActionListener(this);
              c.add(listPane, BorderLayout.WEST);
              c.add(rightPanel,BorderLayout.CENTER);
              c.add(button,BorderLayout.SOUTH);
            //Display the window.
              pack();
              //RefineryUtilities.centerFrameOnScreen(this);
              setVisible(true);
         public void valueChanged(ListSelectionEvent lse){
              //System.out.println("List event: " + lse);
              Object[] selectedObj = pfoList.getSelectedValues();
              selectedPFO = new String[selectedObj.length];
              for( int i=0; i < selectedObj.length; i++){
                   selectedPFO[i] = (String)selectedObj;
    public void actionPerformed(ActionEvent e) {
                   Code to determine what are all the excel sheets to be read goes here
                   it depends on choices made in the User Interface and File organization!
                   ADD SOME MORE COMMENTS LATER
              PFOBeta.main(new String[]{"Nothing"});
              /*for( int i=0; i < selectedPFO.length; i++){
                   System.out.println(selectedPFO[i]);
         public static DefaultListModel loadDefaultListModel(String cfgFileName){
              DefaultListModel listModel = new DefaultListModel();
              try{
                   BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(cfgFileName)));
                   String pfo = br.readLine();
                   while(pfo != null){
                        listModel.addElement(pfo);
                        pfo = br.readLine();
                   br.close();
              }catch(Exception e){ System.out.println(e);}
              return listModel;
    public static void main(String[] args) {
              ChartMaster cm = new ChartMaster("Process Group Tool");

Maybe you are looking for

  • New to Solaris 9 - Need some help, if some one could answer my question plz

    Hello! During the installation when I set that the computer is not networked, everything (SMC) seems to work absolutely fine. But when I set the option that the computer is networked, The SMC (Solaris management Console) doesn;t startup. it says agai

  • ERROR in JDBC adapter...

    HI My call to a stored proc in SQLServer fails with SQL exception Error processing request in sax parser: Error when executing statement for table/stored proc. 'EmployeeFetch': java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Can't s

  • About T500 - 2055T501

    I'm living in Romania, and I want to buy a laptop T500. And yesterday, I found one that has model 2055T501 with the configuration : Thinkpad T500 (PN 2055T501) - Intel Core 2 Duo Processor P8600 (2.40GHz 1066MHz 3MBL2) 25W - 15.4" WSXGA (1680x1050) -

  • Constant Selections and Exception Aggregation

    Hi, Can You please tell me 1) what is constant selections? 2) what is Exception Aggregations? Thanks and Regards. Naresh.

  • NavigationBar in "Maps" app

    hello. I'm a newbie for developping iPhone app. Following is my question: When I push "direction" button which is located at the bottom of "Maps" app, a navigation bar is shown (this bar has 2 textFields). How can I custom navigationBar like this ? p