2

I have been trying to write some code (in Java) which is equivalent to this piece of code which is written in C#:

FormWindowState stateOfWindow = FormWindowState.Normal;

(the above piece of code is meant to store the WindowState in the variable stateOfWindow)

Is there some Java code which is equivalent to the above piece of code? (I am using a JFrame)

Questionnaire
  • 656
  • 2
  • 11
  • 25
  • See [`Frame.getExtendedState()`](https://docs.oracle.com/javase/8/docs/api/java/awt/Frame.html#getExtendedState--). See also the `RestoreMe` code on [this answer](http://stackoverflow.com/a/7778332/418556) for serializing the location and size of a frame. – Andrew Thompson May 14 '17 at 17:22
  • 1
    This sounds like an [XY-Problem](https://meta.stackexchange.com/a/66378). What are you trying to achieve? – Turing85 May 14 '17 at 17:22
  • @AndrewThompson I've seen that piece of code. However, it does not allow you to store the window state in a variable, which is what I need my program to do. – Questionnaire May 14 '17 at 17:25
  • @Turing85 I am trying to store the Window State in a variable, as the variable is to be used in a method later on. It has to be done in this way, as I have been assigned a task of translating a program from C# to Java, and there doesn't seem to be any other work-around in this case. – Questionnaire May 14 '17 at 17:26
  • 1
    @AndrewThompson I am not proficient in C# but as far as I am able to see, [`FormWindowState` in an Enum](https://msdn.microsoft.com/en-us/library/system.windows.forms.formwindowstate(v=vs.110).aspx). The method [`Frame.getExtendedState()`](https://docs.oracle.com/javase/8/docs/api/java/awt/Frame.html#getExtendedState--) returns an `int`, representing the same states as the C# equivalent (plus some extra). So you actually CAN store the state in a variable: `int frameState = myFrame.getExtendedState();`. – Turing85 May 14 '17 at 17:32

0 Answers0