JFrame.setDefaultLookAndFeelDecorated(true);

By : Waseem
Source: Stackoverflow.com
Question!

when i use setDefaultLookAndFeelDecorated(true) method in Java why is the Frame appear FullScreen when i maximize the Frame ? and how can i disaple the FullScreen mode in this method ?

By : Waseem


Answers

Setting setDefaultLookAndFeelDecorated to true causes the decorations to be handled by the look and feel; this means that a System look-and-feel on both Windows and Mac (I have no Linux at hand now) retains the borders you would expect them of a native window, e.g. staying clear of the taskbar in Windows.

When using the Cross Platform look-and-feel, a.k.a. Metal, which is the default on Windows, the Windows version will take over the entire screen, making it look like a full-screen window. On Mac, the OS refuses to give away its own titlebar, and draws a complete Metal frame (including the title bar) in a Mac-native window.

So, in short, if you want to make sure the taskbar gets respected, use the Windows system look-and-feel on Windows. You can set it by using something like

UIManager.setLookAndFeel((LookAndFeel) Class.forName(UIManager.getCrossPlatformLookAndFeelClassName()).newInstance());


If you don't want your JFrame to be maximize-able then then call .setResizable(false); on it.

By : pfranza


This code below working perfectly

import javax.xml.transform.OutputKeys;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;

String formattedXml1 = prettyFormat("<root><child>aaa</child><child/></root>");

public static String prettyFormat(String input) {
    return prettyFormat(input, "2");
}

public static String prettyFormat(String input, String indent) {
    Source xmlInput = new StreamSource(new StringReader(input));
    StringWriter stringWriter = new StringWriter();
    try {
        TransformerFactory transformerFactory = TransformerFactory.newInstance();
        Transformer transformer = transformerFactory.newTransformer();
        transformer.setOutputProperty(OutputKeys.INDENT, "yes");
        transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", indent);
        transformer.transform(xmlInput, new StreamResult(stringWriter));

        String pretty = stringWriter.toString();
        pretty = pretty.replace("\r\n", "\n");
        return pretty;              
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}


This video can help you solving your question :)
By: admin