swing

can't show JTable

Hi, I'm having small problem (I guess) of showing the JTable panel. I have class contains Object array with: public class Item { String itemDesc = ""; float price = 0; private itemType enmItemType; Object[][] data = {{itemDesc, enmItemType , new Float(price)}}; . . . . } here is the Table class contains the JTable...

Looking for a way to highlight specific words in textareas?

Hi i'm looking for a way to highlight specific words in text kind of like how a text editor might work with syntax highlighting. The highlighting will consist of the text being different colours and/or different styles such as italic, bold or regular. In order to narrow focus, how this might be achieved using Java Swing components. The...

Using JLabels as pseudo buttons.

Currently I am developing a small todo list manager and would like to use labels in place of buttons on the 'context' bar. If any one could provide me with information on how I could go about doing this I would appreciate it greatly. ...

Java Graphics not displaying on successive function calls, why?

Hi, I'm making a visualization for a BST implementation (I posted another question about it the other day). I've created a GUI which displays the viewing area and buttons. I've added code to the BST implementation to recursively traverse the tree, the function takes in coordinates along with the Graphics object which are initially pas...

How to validate a JTextField?

Hi all, how to validate a textfield to enter only 4 digits after the decimal point in Swing. Regards, Chandu ...

Java Swing: How can i check if a row appears on screen before force scrolling to it ?

I am using a Swing JTable, and i want to force scroll to a specific row inside it. That is simple using scrollRowToVisible(...), but i want first to check this row is not already visible on the screen before scrolling to it, as if it is already visible there is no need to force scroll. How can i do that ? ...

Exception thrown while working with JTabbedPane

I'm using a JTabbedPane in my application and I listen to its changes with ChangeListener so that I can know which tab is currently selected. So my stateChanged method is; public void stateChanged(ChangeEvent e) { currentPageIndex = jTabbedPane.getSelectedIndex(); } But while I'm adding new tabs to the JTabbedPane it throws an Arr...

Swing: How to paint focus-rectangle just like current LAF?

This might be a long shot, but does anyone know of a way to paint the dotted line focus-rectangle on my custom component just like the current LAF components do? I'm writing a custom component and I would like it's UI delegate to look very much like the Windows 7 LAF. Thanks. ...

Where about should my main class be created in a project?

The problem is where a class should be created in my code. An example is I have a UI class and a main logic class that controls other objects. Should the main logic class create the UI object, or should the UI object create the instance of the main logic class? An explanation of which method is best and why would be ideal. Thanks. ...

Java Swing automatically gather data from forms

I have a form in Swing with a lot of textfields receiving data. The idea is when a button is clicked, the app gathers all the data from the textfields at once. Do you know a good practice for this? Or is it necessary to gather the data textfield by textfield? ...

JPanel: both implementing my own paintComponent() and rendering children doesn't work

I'm extending a JPanel to display a game board, and adding a JEditorPane at the bottom to hold some status text. Unfortunately, the game board renders just fine, but the JEditorPane is just a blank gray area until I highlight the text in it, when it will render whatever text is highlighted (but not the rest). If I'm understanding Swing...

Aligning all panel components java

I am using the BoxLayout layout manager in java, and have aligned a bunch of components: myLabel.setAlignmentX(Component.LEFT_ALIGNMENT); myTextBox.setAlignmentX(Component.LEFT_ALIGNMENT); myButton.setAlignmentX(Component.LEFT_ALIGNMENT); ... I have a lot of components, and this seems over the top. Is there a shorthand way? I tried t...

BorderLayout problem with JSplitPane after adding JToolbar (Java)

Hello all. Problem: My program layout is fine, as below before I add JToolbar to BorderLayout.PAGE_START Here's a screenshot before JToolbar is added: Here's how it looked like after adding JToolbar: May I know what did I do wrong? Here's the code I used: //Create the text pane and configure it. textPane = new JTextPane()...

Java Swing rendering bug on Windows 7 look-and-feel?

The knob on vertical JSlider's on my Windows 7 machine (with native look-and-feel) is really, really tiny in both directions. Not just skinny but short as well. Can anyone confirm this? Should I report it? If so, where? Thanks! Here is the code for the sample program (in the screen shot): import javax.swing.JFrame; import javax.swing...

how can i display the database data to an jtable(dynamic) in the swings!

we are using hibernate in business layer,but the task is, by using the jtable in swings to display the dynamic data(swings) from the database. code: Criteria criteria=session.createCriteria(User.class); //here user.class is pojo class in hibernate. List studentlist= criteria.list(); System.out.println("records"+studentlist); here t...

Java Positioning a list on a GUI

I'm trying to add a JList to a GUI, but am wondering how to position it? I want it to appear on the right hand side of the TextArea for data that will be sent to the GUI for selection. Can anyone suggest how to do this? Here is the code (note: very new to Java and GUI's) protected static void createAndShowGUI() { GUI predict = ...

a retractable JTextArea with scrollpane

Goodevening how can have a JTextArea like in netbeans (see the pic) my code of the JTextArea: JTextArea infoArea = new JTextArea(10,10); infoArea.setLineWrap(true); infoArea.setFont(police); infoArea.setForeground(Color.YELLOW); infoArea.setBackground(Color.BLACK); infoArea.setEditable(false); JScrollPane scro...

Swt.browser inside of Jpanel

How can I put a swt.browser inside of a Jpanel? ...

How to configure JComboBox not to select FIRST element when created? (Java)

Hi all. Problem: Update: From the Java SE 6 API: public JComboBox() Creates a JComboBox with a default data model. The default data model is an empty list of objects. Use addItem to add items. By default the first item in the data model becomes selected. So I changed to JComboBox(model) as the API says: public JCom...

Why Look and feel is not getting updated properly?

I’m developing a swing application in which I have an option to change the Look and feel of the application on click of a button. Now my problem is when I click the button to change the theme it’s not properly updating the L&F of my app, say my previous theme is “noire” and I choose “MCWin” after it, but the style of the noire theme is s...