swing

Java Swing MVC question

I'm following this MVC model: http://java.sun.com/developer/technicalArticles/javase/mvc/ In my model I have an "ArrayList shapes" field and I need the shapes in my view. Is the only way of getting my shapes by getting them in the modelPropertyChange method? public void modelPropertyChange(PropertyChangeEvent evt) { if (evt.getPr...

code for searching from file using GUI

hi everyone, I'm looking for a code that allows me to search from file , for example, in my program which is shoes shop's program . I should design and implement interfaces which have to search data from file TXT. the idea is that when I choose one item like type of shoes the program should display all other times such as color, size an...

marquee in title bar in JFrame

Hi! I am just wondering how can I make the title bar of a JFrame to be Marquee . Is it possible to do that? Thanks a lot! ...

scala event swing :: chicken or egg

hello, how can I handle a situation, where a filed listens to a buttons that is not declared yet? val detail = new BoxPanel(Orientation.Vertical){ listenTo(button) } val seznam = new BoxPanel(Orientation.Vertical){ val button = new Button("But"){ reactions += { case ButtonClicked(_) => detail.conten...

Why I cannot add a JPanel to JFrame?

Here is the code: import javax.swing.SwingUtilities; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JLabel; import java.awt.event.*; import java.awt.*; public class GameWindow { private String[] players; private JFrame frame; // Constructor. public GameWindow(String[] players) { this.players = players;...

Webkit browser in a Java app

Hi all, I was wondering if there was a Java swing component that uses webkit. Is it possible to create a webkit browser in Java - must I use JavaFX ? ...

Java GUI component to display an XML

What component would you choose to display XML data in a AWT/Swing Java GUI? Requirements: Editable Basic Syntax Highlight (tags vs.literals) Pretty-print (i.e. don't display everything in the same line if the XML contains no linebreaks). ...

How to use BigDecimal in swing GUIs?

I'm using BigDecimal to represent product prices in a Java SE application. What swing component(s) should I use in order to allow the user to input numbers with only two decimal places and bound it to a BigDecimal variable/Object's property. (Checking that as the user types)? I've been playing with JTextField, JFormattedTextField, Numb...

Swing & Batik: Create an ImageIcon from an SVG file?

Simply put, I'm looking for a way to make an ImageIcon from an SVG file using the batik library. I don't want to have to raster the SVG to disk first, I just want to be able to pull an svg out of the jar file and have it land as a UI element. I feel like this should be reasonably easy, but the batik javadocs aren't telling me what I ne...

Stealing the contents of another application's tree view

I have an application with a very large TreeView control in Java. I want to get the contents of the tree control in a list (just strings not a JList) of XPath-like elements of leaves only. Here's an example root |-Item1 |-Item1.1 |-Item1.1.1 (leaf) |-Item1.2 (leaf) |-Item2 |-Item2.1 (leaf) Would output: /Item1/Item1.1/I...

Force repaint after button click

consider this piece of scala swing code detail.reactions += { case ButtonClicked(but) => detail.contents += new Label(but.text) detail.background = new java.awt.Color(0,255,0) } the detail is of FlowPanel type. When the button is clicked, the color is instantly repainted, but the Label is not. It gets visible as I click the...

Java - Lock Aspect Ratio of JFrame

Is it possible to lock the aspect ratio of a JFrame in Java Swing? For example, if my window is 200px by 200px, and the user wants to resize it, I want the ratio between the width and the height at 1:1, so that if the new width is 400px, the new height is forced to 400px. I'm aware of ComponentListener and componentResized, but I'm hav...

how to change swing look and feel in netbeans

i am new to netbeans ide , i have a swing desktop application and i want to change the default java look and feel (for it) to substance look and feel ( or other) , so how to add substance jar file to my project (i want to deploy the project to jar file) , and set a look and feel from it . thanks ...

ResultSet in JTable

How display ResultSet in JTable. i using this code /*String [] record= new String[ColCount]; for (i=0; i<ColCount; i++) { record[i]=rset1.getString(i+1); } cell[i] = rset1.getString("loginname"); cell[i] = rset1.getString( "role"); System.out.println(cell[i][0]); //ItemGroup = rset1.getString( "Status"); } System.out.println(...

Can't drag to resize JTable columns

Long story short, I'm making a custom Swing component that's basically a JTable with a panel on its side. The table should of course be scrollable and have a table header, but since I only want the header to be above the actual JTable and not above the side panel, I had to pull some tricks to make it work. But that part works fine. H...

What is best practice (and implications) for packaging projects into JAR's?

What is considered best practice deciding how to define the set of JAR's for a project (for example a Swing GUI)? There are many possible groupings: JAR per layer (presentation, business, data) JAR per (significant?) GUI panel. For significant system, this results in a large number of JAR's, but the JAR's are (should be) more re-usable -...

Styling HTML in a JEditorPane or JTextPane

I want to display HTML in a JEditorPane or JTextPane, but I want the style (font size) to come from the Look and Feel. Is there a way to do this, or do you have to use embedded HTML styling? Here is an example: epText = new JEditorPane("text/html", content); StyleSheet ss = ((HTMLEditorKit)epText.getEditorKit()).getStyleSheet(); ss.a...

How can I remove a JPanel from a JFrame?

Recently I asked here how to add a new JPanel to JFrame. The answer helped me to get a working code. But not I have a related question: "How can I remove an old JPanel". I need that because of the following problem. A new JPanel appears appears when I want (either time limit is exceeded or user press the "Submit" button). But in several...

Is there any way in Java to enforce a minimum window size?

Is there any way in Java to enforce a minimum window size? The last article I can find is from 1999, and has some complicated code to mimic the behaviour... http://www.javaworld.com/javaworld/javaqa/1999-10/03-qa-window.html Surely there is a simple method that can be used? ...

Introduce Delay after keyReleased() event

So, I'm working with swing and I need to find a clean (non-CPU-hogging-way) to introduce a delay on a text field. Basically, users will enter a number into this field and the keyReleased() event checks that the input fits a few parameters and then assigns the value to a data storage element in the program. If the data is invalid, it di...