How to maximize a window with Swing?

I'd like to know if there is any way to maximize (not just resize) a Swing window (JFrame or similar).
Thanks.

To fill the whole screen, check out toolkit.getWindowSize()

Similar Messages

  • How do a float window with swing?

    How do a float window with swing?
    If you have JBuilderX, the float window likes JBuilderX's structure pane.
    Thanks Advance!

    It can't be resize and must be add to the panel that *.getContentPane()

  • How to maximize application window in Swing?

    Hello,
    I'm trying to make my Swing application occupy the whole screen on start with
    jframe.setExtendedState(JFrame.MAXIMIZED_BOTH);
    jrame.setVisible(true);My system supports this feature (checked this through java.awt.Toolkit).
    Is there a way to make a Swing app take up the whole of the screen, maybe there is a way to do this with new(1.4) features?
    Thank u in advance.

    Another way may be to use Toolkit and to pass the resultant dimensions on to the setSize() method.

  • How do I use windows with my mac

    How do I use windows with my imac?  I need to know which program I need.

    use the built in boot camp or a program such as Parallels or VMware Fusion.

  • How to create a window with its own window border other than the local system window border?

    How to create a window with its own window border other than the local system window border?
    For example, a border: a black line with a width 1 and then a transparent line with a width 5. Further inner, it is the content pane.
    In JavaSE, there seems to have the paintComponent() method for the JFrame to realize the effect.

    Not sure why your code is doing that. I usually use an ObjectProperty<Point2D> to hold the initial coordinates of the mouse press, and set it to null on a mouse release. That seems to avoid the dragging being confused by mouse interaction with other nodes.
    import javafx.application.Application;
    import javafx.application.Platform;
    import javafx.beans.property.ObjectProperty;
    import javafx.beans.property.SimpleObjectProperty;
    import javafx.collections.FXCollections;
    import javafx.event.ActionEvent;
    import javafx.event.EventHandler;
    import javafx.geometry.Point2D;
    import javafx.geometry.Pos;
    import javafx.scene.Node;
    import javafx.scene.Scene;
    import javafx.scene.control.Button;
    import javafx.scene.control.ChoiceBox;
    import javafx.scene.input.MouseEvent;
    import javafx.scene.layout.AnchorPane;
    import javafx.scene.layout.StackPane;
    import javafx.scene.layout.VBox;
    import javafx.scene.paint.Color;
    import javafx.stage.Stage;
    import javafx.stage.StageStyle;
    import javafx.stage.Window;
    public class CustomBorderExample extends Application {
      @Override
      public void start(Stage primaryStage) {
      AnchorPane root = new AnchorPane();
      root.setStyle("-fx-border-color: black; -fx-border-width: 1px; ");
      enableDragging(root);
      StackPane mainContainer = new StackPane();
        AnchorPane.setTopAnchor(mainContainer, 5.0);
        AnchorPane.setLeftAnchor(mainContainer, 5.0);
        AnchorPane.setRightAnchor(mainContainer, 5.0);
        AnchorPane.setBottomAnchor(mainContainer, 5.0);
      mainContainer.setStyle("-fx-background-color: aliceblue;");
      root.getChildren().add(mainContainer);
      primaryStage.initStyle(StageStyle.TRANSPARENT);
      final ChoiceBox<String> choiceBox = new ChoiceBox<>(FXCollections.observableArrayList("Item 1", "Item 2", "Item 3"));
      final Button closeButton = new Button("Close");
      VBox vbox = new VBox(10);
      vbox.setAlignment(Pos.CENTER);
      vbox.getChildren().addAll(choiceBox, closeButton);
      mainContainer.getChildren().add(vbox);
        closeButton.setOnAction(new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent event) {
            Platform.exit();
      primaryStage.setScene(new Scene(root,  300, 200, Color.TRANSPARENT));
      primaryStage.show();
      private void enableDragging(final Node n) {
       final ObjectProperty<Point2D> mouseAnchor = new SimpleObjectProperty<>(null);
       n.addEventHandler(MouseEvent.MOUSE_PRESSED, new EventHandler<MouseEvent>() {
          @Override
          public void handle(MouseEvent event) {
            mouseAnchor.set(new Point2D(event.getX(), event.getY()));
       n.addEventHandler(MouseEvent.MOUSE_RELEASED, new EventHandler<MouseEvent>() {
          @Override
          public void handle(MouseEvent event) {
            mouseAnchor.set(null);
       n.addEventHandler(MouseEvent.MOUSE_DRAGGED, new EventHandler<MouseEvent>() {
          @Override
          public void handle(MouseEvent event) {
            Point2D anchor = mouseAnchor.get();
            Scene scene = n.getScene();
            Window window = null ;
            if (scene != null) {
              window = scene.getWindow();
            if (anchor != null && window != null) {
              double deltaX = event.getX()-anchor.getX();
              double deltaY = event.getY()-anchor.getY();
              window.setX(window.getX()+deltaX);
              window.setY(window.getY()+deltaY);
      public static void main(String[] args) {
      launch(args);

  • How to close open windows with ios7, How to close open windows with ios7

    How to close open windows with ios7, How to close open windows with ios7?

    Guess they thought we needed more exercise so now we have to swip them to close.....miss iOS6. My eyes are blurry now after looking at my phone, and my arms are tired from swipping lol

  • How to maximize a window in Yosemite

    Hi. Today I found out that when you click the maximize button in Yosemite, instead of maximize the window to a predetermined space, the window goes full screen. Is there a way to set it back to the previous behaviour? I'm working with two monitors and it's impossible to work this way.
    If is not possible to configure this button, can I downgrade to Mavericks? Because it's IMPOSSIBLE to work this way.
    Thanks
    PD: I'd love to know who is the "person" that came up with this "brilliant" idea :-(

    I've found the solution in Yosemite's forum:
    Can I restore previous functionality of the Maximize button in Yosemite

  • How to Maximize MDI window in Dev-10g

    Buddies....How can we maximize MDI window (Browser's window) in Dev-10g while calling a form or report?

    hi
    try this
    when-new-form-instance trigger.
    declare
    fm_id formModule;
    begin
    fm_id :=find_form ( :system.current_form);
    set_form_property(fm_id,defer_required_enforcement,property_true);
    set_window_property(forms_Mdi_window,window_state,Maximise);
    set_window_Property(forms_Mdi_window,title,'MDI title');
    set_window_property('window1',window_state,Maximise);
    set_window_property('Window1',Title, 'Form title');
    end;
    sarah

  • How to maximize application window in Flex?

    In Flex 2.0, i am trying to do is to maximize application
    window (browser window) when application starts or when we going to
    next state.
    How can this be done?
    Thanks
    Ramesh

    just try this:
    Application.application.stage.displayState =
    StageDisplayState.FULL_SCREEN;

  • How to maximize a window and can't be able to move it

    Hi everyone,
    I'm doing an HMI and what I want to do is to maximize a window. I can do it in the VI proprieties -> Window Run-Time Position -> Position: Maximized. The problem I get is when I run it, the user can move the window with the title bar.
    I don't want to move the window. The window has to stay at the same place.
    Is there a way to do this (without taking off the title bar)?
    Thank you
    Stephanie

    Thanks everyone for helping me!
    But it doesn't really help me much....
    I want to maximize the window (so in the Window Runtime position, I put "Maximize"). I want a title bar to show the name of the VI (I check the "Window has title bar" in the Window Appareance). I don't want to be able to resize the window (I uncheck the "Allow to resize window" in the Window appareance). When I do the last thing, the window can move and it's exactly want I don't want to do. If I uncheck this option, the user can click on the square and be able to resize and move the window.
    Maybe there's an option somewhere in the proprieties that can disable moving the window? Why the window can move if I maximised the window and I can be able to resize the window? When it's a real maximize, the window can't move.
    Except with the Toolbox (well, I can't use it anyway, because I have version 8.2), is there any other way to do this?
    I'd like to have answers please (event if it's no )
    Thank you very much again
    Stéphanie

  • How to link crystal report with swing

    I am developing applications in swing. I have done a report using crystal report.
    Now i don't know how to link it with swing. can anyone help me to solve this with some examles.
    thanx in advanz

    Hope these links are useful:
    http://www.must.de/default.html?Jareport.htm
    http://www.utdallas.edu/~pxm034000/files/integrating.html

  • How to maximize battery lifetime with Lithium-ion batteries?

    Hi all,
    There are severay discussions about the battery lifetime.
    Toshiba says on http://support.toshiba-tro.de/kb0/FAQ35007L0020R01.htm that:
    Totally discharging the battery pack before charging, will allow the battery pack to be charged to its highest capacity
    But this and other points do not comfirm information about maximum battery lifetime from http://en.wikipedia.org/wiki/Lithium_ion_battery
    Question: What's the best option to maximize battery lifetime with Lithium-ion batteries???????????

    Hi Flutters
    The "best" way to "maximize" battery life is always a tricky issue but there are a few important factors to consider:
    A Li-Ion (lithium-Ion) battery will not suffer from the "memory" effect that many other battery types, including Ni-Cd (Nickel-Cadmium), are well known for. This means that only charging for short times or charging for different periods of time during use will not change the battery's ability to store a charge, but like any chemical process this will break down over time, so the older the battery, the less chance there is of it storing a charge properly.
    Another thing is how to store the battery. The general rule is to discharge any rechargeable battery if it is to be stored for a significant amount of time (say 1 month or more.
    The way a battery pack behaves will also vary according to temperature, so a warm battery pack in a warm room will charge much quicker than a cold battery pack in a cold environment, although you should never artificially warm a battery by maybe heating it in an oven.
    At the end of the day, I would suggest just being sensible and consider what the laptop was designed for; the spec will tell you whether the unit was designed with simple applications such as Office or more demanding tasks such as video editing and other resource-intensive tasks. The harder the processor (and therefore the rest of laptop) is working, the more strain this will be putting on the battery.
    I hope this helps

  • How to close a window with a jbutton?

    hi all!
    im have a login box created with jframe,
    what i want is when i press the submit button and if authentication is success
    i'd like to close the jframe of my login box and open a new window.
    how can i close a jframe window with a jbutton?

    to close the window you can add an anynomous class like this:
    yourButton.addActionListener(
          new ActionListener() {
                  public void actionPerformed( ActionEvnet e ) {
                        System.eixt(0);
    );That's all Buddy, Enjoy

  • How to open new window with required size when clicking on image in a table

    Hi,
    There is an image column in advanced table. i want to open new window with required parameters(size, toolbar, status bar,etc..) and with that transaction context.
    can any one help plzzzzzzzz?
    Thanks
    Raju

    You can also use OAF js function to open modal pop up:
    openWindow(self, '<url>','longTipWin', {width:900, height:400}, true); return false;
    --Mukul                                                                                                                                                                                                                                                                                                                                   

  • How to create popup window with radio buttons and a input field

    Hi Guys,
    Can somebody give some directions to create a stand alone program to create a window popup with 2 radio button and an input field for getting text value. I need to update the text value in a custom table.
    I will call this stand alone program from an user exit. 
    Please give me the guidance how go about it or please give any tutorial you have.
    Thanks,
    Mini

    Hi,
    There are multiple aspects of your requirements. So let's take them one at a time.
    You can achieve it in the report program or you can use a combination of the both along.
    You can create a standalone report program using the ABAP Editor (SE38). In the report program you can call the SAP Module pool program by CALL Screen <screen number>. And then in the module pool program you an create a subscreen and can handle the window popup with 2 radio button and an input field for getting the text.
    For help - Module Pool programs you can search in ABAP Editor with DEMODYNPRO* and you will ge the entire demo code for all dialog related code.
    For Report and other Module pool help you can have a look at the following:
    http://help.sap.com/saphelp_nw70/helpdata/en/47/a1ff9b8d0c0986e10000000a42189c/frameset.htm
    Hope this helps. Let me know if you need any more details.
    Thanks,
    Samantak.

Maybe you are looking for