Difference between java.exe and javaw.exe
java.exe is the console app while javaw.exe is windows app (console-less). You can’t have Console with javaw.exe.
java.exe is the console app while javaw.exe is windows app (console-less). You can’t have Console with javaw.exe.
You can get the screen size with the Toolkit.getScreenSize() method. Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); double width = screenSize.getWidth(); double height = screenSize.getHeight(); On a multi-monitor configuration you should use this : GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(); int width = gd.getDisplayMode().getWidth(); int height = gd.getDisplayMode().getHeight(); If you want to get the screen resolution in DPI you’ll have … Read more
Pros Swing: part of java library, no need for additional native libraries works the same way on all platforms Integrated GUI Editor in Netbeans and Eclipse good online tutorials by Sun/Oracle Supported by official java extensions (like java OpenGL) Cons Swing: Native look and feel may behave different from the real native system. heavy components … Read more
Use label.setOpaque(true); Otherwise the background is not painted, since the default of opaque is false for JLabel. From the JavaDocs: If true the component paints every pixel within its bounds. Otherwise, the component may not paint some or all of its pixels, allowing the underlying pixels to show through. For more information, read the Java … Read more
There is a lot of possibilities for LaFs : The native for your system The nimbus LaF Web LaF The substance project (forked into the Insubstantial project) Napkin LaF Synthetica Quaqua (looks like aqua from MacOS X) Seaglass JGoodies Liquidlnf The Alloy Look and Feel PgsLookAndFeel JTatoo Jide look and feel etc. Resources : Best … Read more
It should respond to ActionListeners, like this: combo.addActionListener (new ActionListener () { public void actionPerformed(ActionEvent e) { doSomething(); } }); @John Calsbeek rightly points out that addItemListener() will work, too. You may get 2 ItemEvents, though, one for the deselection of the previously selected item, and another for the selection of the new item. Just … Read more
DTO is an abbreviation for Data Transfer Object, so it is used to transfer the data between classes and modules of your application. DTO should only contain private fields for your data, getters, setters, and constructors. DTO is not recommended to add business logic methods to such classes, but it is OK to add some … Read more
Using various LayoutManagers one can provide spacing between various components. 1.) BorderLayout : Overloaded Constructor : BorderLayout(int horizontalGap, int verticalGap) Getter and setter methods For Horizontal Spacing : BorderLayout.getHgap() and BorderLayout.setHgap(int hgap) For Vertical Spacing : BorderLayout.getVgap() and BorderLayout.setVgap() 2.) FlowLayout : Overloaded Constructor : FlowLayout(int align, int hgap, int vgap) Getter and setter methods … Read more
This works for me and is quite simple: Import these: import java.awt.datatransfer.StringSelection; import java.awt.Toolkit; import java.awt.datatransfer.Clipboard; And then put this snippet of code wherever you’d like to alter the clipboard: String myString = “This text will be copied into clipboard”; StringSelection stringSelection = new StringSelection(myString); Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); clipboard.setContents(stringSelection, null);
What will be cleaner and easier to maintain? All things being equal, probably JavaFX – the API is much more consistent across components. However, this depends much more on how the code is written rather than what library is used to write it. And what will be faster to build from scratch? Highly dependent on … Read more