look-and-feel

How can I make a java FileDialog accept directories as its FileType in OS X?

ぃ、小莉子 提交于 2019-11-28 01:52:57
I am trying to switch from using a JFileChooser to a FileDialog when my app is being run on a mac so that it will use the OS X file chooser. So far I have the following code: FileDialog fd = new FileDialog(this); fd.setDirectory(_projectsBaseDir.getPath()); fd.setLocation(50,50); fd.setFile(?); fd.setVisible(true); File selectedFile = new File(fd.getFile()); What would I put in for the question ? so that my file chooser would allow any directory to be the input for file chooser (the method that follows already checks to make sure that the directory is the right kind of directory I just want to

Change background and text color of JMenuBar and JMenu objects inside it

放肆的年华 提交于 2019-11-28 00:29:44
How can I set custom background color for JMenuBar and JMenu objects inside it? I tried .setBackgroundColor and it does not work! D180 Create a new class that extends JMenuBar : public class BackgroundMenuBar extends JMenuBar { Color bgColor=Color.WHITE; public void setColor(Color color) { bgColor=color; } @Override protected void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2d = (Graphics2D) g; g2d.setColor(bgColor); g2d.fillRect(0, 0, getWidth() - 1, getHeight() - 1); } } Now you use this class instead of JMenuBar and set the background color with setColor() . You would

Good-looking Java Swing Look&Feel?

主宰稳场 提交于 2019-11-28 00:03:10
问题 I'm working on an open-source Java Web Start application, and I'd like to give it a consistent theme across platforms. Metal is totally ugly, and I'm not particularly happy with Substance (esp. performance). What are the best Swing Look&Feel options out there today? 回答1: I like the 'Nimbus Look&Feel'(2nd image) introduced in Java 6 Update 10 very much and it is contained in SUN's vanilla J2SE of J6u10 and later by default! Another advantage is, that it is painted entirely using Java 2d which

How to improve look and feel of JAVA swing GUI?

泪湿孤枕 提交于 2019-11-27 19:04:25
I am working on a project that uses Java Swing. The default look and feel of the Java Swing GUI is very boring. Is there any way I can use a better look and feel? Something like on web pages... Frederik Wordenskjold You can set the look and feel to reflect the platform: try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { e.printStackTrace(); } If this is not nice enough for you, take a look at SWT for Eclipse . Look at the Java tutorial for setting the look and feel . In addition to those mentioned there, recent Java 6 releases also include the

Windows native File chooser in java

我的梦境 提交于 2019-11-27 17:02:42
问题 Apparently, there are (at least?) two different native File choosers on Windows (10). There is this one, which is used by JFileChooser and other programs: And there is that one, for example used by Chrome: I like it much more than the first one because: You can directly enter your file path at the top Your can search the folder The direct access on the left contains the whole file tree How do I get it in Java? 回答1: Use the JavaFX library FileChooser fileChooser = new FileChooser(); fileChoose

Can we ape the GTK+ 2.0 button style in Java Swing?

*爱你&永不变心* 提交于 2019-11-27 16:22:34
The problem with Java Swing is the look and feels (Metal, Nimbus, GTK...), the worst out there compared to SWT, Windows, Mac and Gnome Tool Kit, and getting good looking widgets is utopist, yet I am asking the question though. I need to know if there is a possibility to tweak a JButton to look like a default GTK button. Otherwise, can we give the JButton text a style (a shadow for example)? public class myTweakedButton extends JButton { // Override style attributes here. } Here is the style applied by GTK to the button widget: style "button" { xthickness = 3 ythickness = 3 bg[NORMAL] = shade

setOpaque() in java

天大地大妈咪最大 提交于 2019-11-27 09:20:25
Can anyone explain why Nimbius treats the setOpaque() differently than other java LaF's. Its breaking my code because components that are normally transparent no longer are. EDIT: The problem seems to only deal with JTextAreas (which is what I need) or similar components. EDIT EDIT: This is a screen of the actual application. When applying trashgod's solution, the background still does not show through. EDIT EDIT EDIT: I tried trashgod's suggestion to override the paint(). I toiled with this for hours, and could not get it to work. I was able to get the background to show through, but the

Automatically increasing font size in Swing

半城伤御伤魂 提交于 2019-11-27 07:16:00
问题 I would like to know if there are methods of automatically increasing the font size based on the size of a component. I have this gui here: Hovewer if i increase the size of the frame, it becomes like this: the font size doesn't increase. and i don't have an idea on how to make this work. 回答1: Some L&Fs support a sizeVariant, illustrated here with com.apple.laf.AquaLookAndFeel . Alternatively, you can scale the font to fill the space allocated by your chosen layout, as shown here. 来源: https:/

customizing jtable cellrenderer with table's cell header color

℡╲_俬逩灬. 提交于 2019-11-27 07:10:58
问题 That's a question really similar to this previous post of mine. I need to customize some cell of a JTable, in a way that they would look like a table header cell. I'm using Nimbus look and feel and I'm trying to retrieve the color of JTable's editor: public class HeaderCellRenderer extends JLabel implements TableCellRenderer{ @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { System.out.println("OK"

How to set jframe look and feel

天大地大妈咪最大 提交于 2019-11-27 06:07:54
问题 I am kind of confused on where to put this : try { UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel"); } catch(Exception e){ } I did not extend the JFrame class but used JFrame f = new JFrame(); Thanks :D 回答1: Most common place to put this, is right inside your static void main(String[] args) method. Like so: public static void main(String[] args) { try { UIManager.setLookAndFeel("com.sun