Resizing windows (JFrame)

Hi,
I am developing data entry screens and would like to ensure that the user cannot resize, maximize or minimize, i.e can only close the window (JFrame).
The reason is that if the user maximizes the screen the data input fields are distributed over the screen and this does not look so great!
Only the minimize option seems to make sense.
How do I do this?
Brgds and happy new year
John

I thought you could use this:
frame.setUndecorated(true);
frame.getRootPane().setWindowDecorationStyle(JRootPane.PLAIN_DIALOG);
frame.setResizable(false);But it looks bad.
If you want to get also an entry in the Task Bar create a JFrame with size 0,0 and setUndecorated(true).
And create your JDialog like this:
               JFrame frame = new JFrame("test");
               frame.setSize(0, 0);
               frame.setUndecorated(true);
               frame.setVisible(true);
               JDialog dialog = new JDialog(frame);
               dialog.setSize(300, 300);
               dialog.setVisible(true);
               dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
               dialog.addWindowListener(new WindowAdapter() {
                    public void windowClosed(WindowEvent e) {
                         System.exit(0);
               });

Similar Messages

  • How to resize window (JFrame) on event

    I've got a swing application that uses tabs (JTabbedPane). It's default size is 200,200, and I need to resize the window to different sizes depending on what tab is selected. I can set the default size, but I can't seem to get access to the window to resize it (setBounds/setSize) at runtime.
    If anybody can tell me how I can go about this, I would greatly appreciate it.
    Matt
    Here's the code:
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.event.*;
    public class TimeTrack_Example extends JFrame {
         Container cp = getContentPane();
      public static void main(String args[]) {
              TimeTrack_Example TT = new TimeTrack_Example();
              TT.setSize(200,200);
      public TimeTrack_Example() {
              JTabbedPane JTPane = new JTabbedPane();
              JTPane.addChangeListener(cl);
                   //Jobs Tab
              JPanel jpJobs = new JPanel();
              JTPane.addTab("Jobs", jpJobs);
                   //Timer Tab
              JPanel jpTimer = new JPanel();
              JTPane.addTab("Timers", jpTimer);
                   //Report Tab
              JPanel jpReport = new JPanel();
              JTPane.addTab("Report", jpReport);
        cp.add(JTPane);
        addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {System.exit(0);}
        pack();
        show();
              //Tab ChangeListener
         ChangeListener cl = new ChangeListener() { 
              public void stateChanged(ChangeEvent e) {
                   int tabID = ((JTabbedPane)e.getSource()).getSelectedIndex();
                   if (tabID == 2) {
                        //???               //here's where I need to change the size
    }

    This is one way:
    create a method, lets call it resizeWindow(). Call this method from inside your ChangeListener.
    public void resizeWindow() {
    this.setSize(300, 400); //whatever values you want
    public void stateChange(ChangeEvent e) {
    if (tabID == 2) {
    resizeWindow();
    }

  • Question to Swing Pros: Resizing of JFrame only with visible Rectangular  ?

    Hello folks,
    quite below is the quoted text message is from Java Substance Forum: http://www.nabble.com/Removing-top-left-substance-menu-and-deactivating-Background-painting-while-Resizing-a-Frame--to17775101.html
    Is it somehow possible to use substance or another LooknFeel with custom titelbar and still keeping a hidden JFrame background resizing? So if i resize a JFrame only a rectangular should be visible not the content of the window should dynamically resize.
    That would be a general Swing question to ask in Swing forums on java.net or on java.sun.com
    Thanks
    Kirill
    ----- Original Message ----
    From: PEL <liquidc4d@...>
    To: users@...
    Sent: Wednesday, June 11, 2008 9:07:36 AM
    Subject: Re: Removing top left substance menu and deactivating Background painting while Resizing a Frame?
    2. You would notice in your screenshots that you're running Substance
    under decorated mode, but Metal (and Windows) under undecorated mode
    (title pane coming from OS). Try running your app under decorated mode in
    Metal and see if the dynamic resizing is the same.
    Ok with decorated(false) the resizing of the frame shows only a border not
    the whole background of the frame, but then i have no stunning
    Glas3DDecoration painter :D
    Is it somehow possible to use substance with 3dglass titelbar and a hidden
    jframe background resizing?

    I've never seen a way to do that in Swing normally.
    Of course, if you could run something allowing transparent windows (some newer version of Java will support it, or Skin L&F, etc), I can imagine how you might fake it by using your own decorations, and on resize, create a transparent window with a border that is your resize window, and use that to resize, and then fix the final size to the real window when done.

  • Auto-resize a jFrame

    Hello!
    I have a jFrame which I want the size of to change so all the components will fit. Pack() didnt work, and neither did getting the jPanels size and setting is as the preffered size. So Now I've out of ideas.. Here's where it will add components later, but I need to resize it so that it will fit the new ones. Any ideas?
    jComboBox1.addItemListener(new java.awt.event.ItemListener() {
                        public void itemStateChanged(java.awt.event.ItemEvent e) {
                             String premium = jComboBox1.getItemAt(jComboBox1.getSelectedIndex()).toString();
                             if (premium == "TestPremiumServer") {
                                                                                    //add components
                             //resize window to fit the new components
                   });

    whenever you add components to an already visible container, these are generally the steps
    container.add(...);
    container.revalidate();
    container.repaint();//sometimes required, if just revalidate() is called, but not if pack() is also called
    container.pack();
    if you have all the above and it's still not working, post your code so we can see exactly what you're doing
    (if the code is long, remove all the unrelated stuff - menu's etc)

  • How do i drag icons and how do i resize windows

    this is my first laptop having been used to emacs before. I can't figure out how to drag items or resize windows when not using a mouse and can't find such simple instructions in the manual.
    thanks.

    In addition to the method described by Jim, you can set options in the Keyboard & Mouse preference panel (in System Preferences) that allow you to get mouse clicks and click lock using the trackpad. Check out those options, many people find they make the trackpad a lot more useful.
    Randall Schulz
    iMac 20" Core Duo; MacBook Pro   Mac OS X (10.4.6)  

  • Is there a way to open an image in a floating, resizable window?

    In previous versions of PDE I could open an image (or for that matter, multiple images) as floating, resizable windows.  Now, images seem anchored.  How can I detact them from the big editing screen, such that I can move them around the computer screen as I could in the past?
    Thanks,
    Haly2k1

      Open Editor and click Edit à Preferences à General
    Then check the box “Allow Floating Documents in Full Edit Mode”
     

  • Resizing Windows Partition - No Longer Booting

    Whenever I attempt to setup a Windows/Linux Dual boot I get hit with this same dilemma. I start off with a NTFS format partition with Windows XP on it. As soon as I resize the partition, it no longer boots. Even before installing linux/grub. I defragmented before attempting this, and I took every precaution. In the end, I'm never able to boot my Windows OS. I can boot Linux from the Grub menu, and I can still access my Windows files.
    As of now I've reformatted back to Windows. I would just like to know what went wrong because I want to attempt another install later on.

    Ward,
    windows is weird in that it notes somewhere the block numbers where the system is installed, and when that moves
    it does not boot anymore.
    Now you are making life more complicated then necessary: if you still have windows resized and installed (and not booting),
    you can use the windows install cd and go into repair mode. It will fix the resized windows.
    If you are starting from scratch, before installing windows, start a Linux live CD, do not install it, start the program
    "gparted" and partition your disk as you want it. Then install windows in one of the partitions.
    Instead of the Linux live CD you can also use a Gparted  stand alone CD:
    http://gparted.sourceforge.net/livecd.php
    Hope it helps.
    Mektub

  • Resizing the JFrame equal Screen size

    Dear Friends,
    I have a problem in resizing the JFrame.
    I am using the standard bounds for JFrame setBounds(0,0,800,600);
    If the Screen size 1024*728 then JFrame will be visible a the corner of the screen.
    I would like to resize by JFrame screen dynamically as per the System screen size.
    Thanks in advance.
    Regards
    Pradeep.

    use this :
    jframe.setBounds(new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()));

  • Slow performance when resizing windows

    Hi I have a macbook pro 2.2ghz with 2gb ram. Certainly capable of resizing windows, however when I resize windows I get very poor performance. I always have to wait for the window to redraw on screen. This is unacceptable. This powerful of a machine can't resize windows in real time? I'm running Tiger 10.4.11. Is this normal behavior? Anyone else experience this? I appreciate any help. Thanks.

    That's not right. What happens when you run your visualizer in iTunes? You should be able to get 60 FPS. Try running your hardware tester once and see if you may have a graphics problem.
    -Bmer
    Mac Owners Support Group - Join us @ MacOSG.com
      Mac611 Mobile Mac Support - about.Mac611.com
       iTunes:MacOSG Podcast | YouTube.MacOSG.com
                       An Apple User Group 
    Have an iPhone or iPod touch? Enter Mac611.com in Safari on it for 'mobile Mac support.'

  • Help resizing window using PS CS4 on PC

    I am trying to figure out a way to put 4 or 6 images on my screen and be able to move them around to compare them.
    Am using Photoshop CS4 on PC and XP Home. I open 4 or 6 files and float all in windows. I then zoom out and make 1 image smaller, so it is smaller than the window. Then match zoom and location to get the zoom ratios the same. Now I have 4 or 6 images that are in windows that are larger than the image.
    Is there any way I can make the windows smaller to be the same as the image other than do each one individually by dragging on the corner? Is there a shortcut to do this? Any way to adjust all the windows at once?
    I realize this is a bit confusing. Let me know if I can clarify the question better. Thanks.
    Matthew Kraus

    Go to Edit>Preferences>General and tick the Zoom Resizes Windows box.

  • Resizing window affects data aquisition

    Hi Guys, got a really annoying problem that I've been trying to solve for about 2 weeks now, I'm hoping someone will be able to help me.
    We communicate through a dll to our data aquisition box (custom). Our custom data aquisition box has an array which we read in a timed loop every 20ms (although the array is present for around 50ms), once read we send a command saying that we have read the data.
    Once we've read the data we put it into a queue. The logger then reads from this queue, all works fine on a normal run. However if we resize any window (not just a labview one) this seems to knock out our Timed loop. i.e. we miss 1-2 arrays worth of data (50-100ms). This is strange as we have it in a Highest priority VI running in the "Data aquisition" thread. We also do lots of other things i.e. read from a TDMS file and read/write to global variables and display data on a graph, this doesn't seems to have much of an affect on the timed loops, its just when we resize a window. Obviously we do not want to risk losing critical data, so we need a way of stopping this from happening?
    Its almost as though the VI is running in the User interface thread and is a lower priority than the resize window method.
    Does anyone have any ideas on how we can solve this issue?
    Thanks in advance
    Joe
    We are collecting data at 1Khz and our Dll is thread safe and is set to "run in any thread".
    Using Labview 2009f3

    Hi Guys,
    Thanks for all your replies. Sorry for late reply, I was out the office yesterday.
    Unfortunately i can not post my source code however i have made a small mock up of how the system generally works, to give you an idea.
    josbone: Our dll is classed as thread safe and we have it running as such - i thought this could be the case to start with. I presume because it is classed as "any thread" it could still be running in the UI thread though?
    Tinnitus: I have attached a mock up that shows the main points in the system. I think I got a little confused on my previous reply. The DAQ holds the data there for 50ms and that is our only chance to read the data(more data comes through and our buffer can only hold 50ms worth). Which if the Timed Loop executes at 20ms should be fine.
    DFGray: I got really excited reading your reply - it sounded like it was a great fix, however, unfortunately it did not work
    Hope the mock code helps
    Regards,
    Joe
    Attachments:
    Streaming example.zip ‏90 KB

  • Resize windows and manage files in save/open dialogs?

    1. How to resize windows by dragging any border or corner?
    2. How to manage files via a Save/SaveAs or Open dialog (rename, delete, copy other files, etc...)?
    My search on these two things only comes up with comparisons and debates about Win vs Mac. Not relevant to the questions! I already run Win XP in Fusion when I have to for work. I don't want to run Windows; I just want to eliminate a couple Mac shortcomings since Apple hasn't. Yet. Maybe it has to do with patents...
    Anyway, does anybody know of a utility or other way to enable these functions in Mac OS 10? (I've tried Pathfinder; it doesn't quite do the trick.)

    I believe you will find a couple of third-party utilities that provide some enhancements for windows. As for file dialogs I can only recommend Default Folder X. You will find these at VersionTracker or MacUpdate.

  • SAP Script  - resize window / paragraph

    Hello Gurus,
    I have two problems related to sap script. ( ver 4.6c)
    I have copied the original order confirmation form from 000 client in diff.languages like FR/DE/EN ( these forms are used by diff. offices in diff. location ) now we have to create a form for our china office location so I copied an existing form ( FR language) to language ZH.
    a. I cannot resize or move the window of the form ZH, to do this I have to convert the original laguage to ZH ( original language of the form is FR) , to change the original language I have to edit the FR language form and use the utilities->convert org.lang option , my question is if I do this process what will happen to our FR language settings users? or is there anyother way to do this ( move or resize window ) without disturbing other forms.
    b. I am using two paragraph settings for printing the item line in the order form, ex. ZZ and IS , if I use IS the item line appears but for ZZ there is no item lines printed on the form. ( blank ) What could be the problem for using ZZ Par.format.
    Any help is appreciated.
    Thanks and best regards,
    A drop in an Ocean

    Try to identify the original language of the SAPscript.
    EX: GOTO SE71, give your form name and language ZH. select radio button Header and click change.
    under adminstrative data, identify the original language. EX: if original language is DE
    GO back to SE71, now give your form name and key in language as DE. Modify all windows here.. i.e. re-size etc., it will automatically gets changed in your ZH language. Also you can create new paragraph formats or change existing paragraph formats here using original language. you can see all changes in form ZH.
    If you want to re-size in "ZH" itself .. try to change original language to ZH.
    I guess, this info will help you to close the thread.
    Regards,
    SaiRam

  • Preview app auto-resize window

    Shift-command-R resizes the image to fit window. How do you resize window to fit an image at it's original size? What a glaring oversight by Apple.

    I don't need the image to be full screen, just the window. And the window is not technically full screen, because you can still see the window borders and the panels. I want the image window with the different image tabs to open as big as my screen. I want the edges to come right up next to my panels and the bottom to go down to the bottom of my screen. For example: I use Mac and when you close a finder window and open a new one, it will open at the same size that you closed it. If you resize it, lets say, to fill your entire screen, close it and then reopen it, it will open the same size as you closed it. I don't want photoshop to open new image windows to the same dimension as the image. I want a grey screen to cover my entire monitor just like in CS3 and before. I really like the tabs, but I want the window to open bigger with grey space arround the image.

  • Bridge CC when copying resizes window to both monitors and enlarges all images to maximum size

    Bridge CC when copying an image resizes window to both monitors and enlarges all images to maximum size.

    Details, please.
    Please read this FAQ for advice on how to ask your questions correctly for quicker and better answers: 
    http://forums.adobe.com/thread/419981?tstart=0
    Thanks!

Maybe you are looking for