Anybody can tell me some websites about investigating the Swing or other UI deeply?

Can anybody tell me some websites about investigating the Swing or other UI deeply
Thank you,everybody in advance.

Posted On: Thursday 27th of September 2012 03:02:10 AM Total Views:  325
View Complete with Replies

Related Messages:

create a jtable which can combine and split and the image change also   (273 Views)
hi newbie here and would like to know how to create a jtable with default images and with specific column and rows that if you combine the cells the image enlarge and when split the image decreases.
Why can't i create a new object?   (232 Views)
I am having a simple error. I want to create a jframe to say a player already exists and have created a class in its own right. I am new to swing, so am not even sure if this is the right thing to do Anyway there is an error when i try to create a new object and i cant for the life of me figure out what it is public void mouseClicked(MouseEvent e) { String firstname = txtFirstname.getText(); String secondname = txtSurname.getText(); if(!(Players.usercheck(firstname, secondname))) { Players.addplayer(firstname, secondname); PlayerAdded pla = new PlayerAdded(firstname, secondname); pla.setVisible(true); } else { UserExists userexists = new UserExists(); userexists.setvisible(true); } } });
i try to get the VK_TAB in jtextfield but i cant,here is the code what i doing wrong? the other keys   (270 Views)
this is the code... private void jTextField18KeyReleased(java.awt.event.KeyEvent evt) { // TODO add your handling code here: if(evt.getKeyCode()==KeyEvent.VK_CONTROL){ jTextField3.setFocusable(true); jTextField3.requestFocusInWindow(); } } buy the way i generate the code with netbeans...
can we display images in sequence which will gives perception of motion in frame's contentPane ?   (228 Views)
can we display images in frame which can give perception of motion very similar to videos ....i short can we display sequence of images so that it is played like a video i have tried but ..the images where over lapping other and GUI gets hanged does any one has done that before
BoxLayout can't be shared exception?   (159 Views)
, I'm learning Java from Head First and I'm trying to write a simple GUI program that first asks if the user wants to load a game or start completely over. After that, the user gets to change the values of his character. If the user selected Restore, the TextFields contain the information that he saved last time the game was played. However, in the method gameGui(), the JVM throws an exception at me saying that Boxlayout can't be shared. I do not understand that at all. Maybe somebody can help =) The code(Don't worry, the bulk of it is just Swing ;) import javax.swing.*; import*; import java.awt.*; import java.awt.event.*; public class SaveGame { JFrame frame; JPanel panel; static SaveGame game; GameCharacter character; JTextField nameField; JTextField powerField; JTextField weaponField; public static void main(String[] args) { game = new SaveGame(); game.setStartupGui(); } public void setStartupGui(){ try{ UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception ex) {} frame = new JFrame("Adventure SaveGame"); panel = new JPanel(); JLabel label = new JLabel("Do you want to start over or restore a savegame"); label.setFont(new Font("serif", Font.BOLD, 18)); JButton startButton = new JButton("Start Over"); startButton.addActionListener(new StartListener()); JButton restoreButton = new JButton("Restore Savegame"); restoreButton.addActionListener(new RestoreListener()); panel.add(startButton); panel.add(restoreButton); frame.getContentPane().add(BorderLayout.CENTER, label); frame.getContentPane().add(BorderLayout.SOUTH, panel); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(400,400); frame.setVisible(true); } //Method I get the error in below: public void gameGui() { frame.getContentPane().remove(); panel.remove(); panel.setLayout(new FlowLayout()); JLabel nameLabel = new JLabel("Name"); JLabel powerLabel = new JLabel("Power #:"); JLabel weaponLabel = new JLabel("Weapon:"); nameField = new JTextField("Name",10); powerField = new JTextField("Power",5); weaponField = new JTextField("Weapon",10); nameField.setText(character.getName()); powerField.setText(character.getPower()); weaponField.setText(character.getWeapon()); JButton saveButton = new JButton("Save"); saveButton.addActionListener(new SaveListener()); JButton exitButton = new JButton("Exit"); exitButton.addActionListener(new ExitListener()); JPanel labelPanel = new JPanel(); JPanel fieldPanel = new JPanel(); JPanel buttonPanel = new JPanel(); labelPanel.setLayout(new BoxLayout(labelPanel, BoxLayout.Y_AXIS)); labelPanel.add(nameLabel); labelPanel.add(powerLabel); labelPanel.add(weaponLabel); panel.add(labelPanel); fieldPanel.setLayout(new BoxLayout(labelPanel, BoxLayout.Y_AXIS)); fieldPanel.add(nameField); fieldPanel.add(powerField); fieldPanel.add(weaponField); panel.add(fieldPanel); buttonPanel.add(saveButton); buttonPanel.add(exitButton); frame.getContentPane().add(BorderLayout.CENTER, panel); frame.getContentPane().add(BorderLayout.SOUTH, buttonPanel); frame.repaint(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(400,400); frame.setVisible(true); } //--------------------------------------------------------------------------------------------------------------------------------- class SaveListener implements ActionListener { public void actionPerformed(ActionEvent ev) { String name = nameField.getText(); String power = powerField.getText(); String weapon = weaponField.getText(); character.setName(name); character.setPower(power); character.setWeapon(weapon); try { FileOutputStream fs = new FileOutputStream("Savegame.ser"); ObjectOutputStream os = new ObjectOutputStream(fs); os.writeObject(character); os.close(); } catch(Exception ex) {ex.printStackTrace();} } } class ExitListener implements ActionListener { public void actionPerformed(ActionEvent ev) { System.exit(0); } } class StartListener implements ActionListener { public void actionPerformed(ActionEvent ev) { character = new GameCharacter(); game.gameGui(); } } class RestoreListener implements ActionListener { public void actionPerformed(ActionEvent ev) { try { FileInputStream fs = new FileInputStream("Savegame.ser"); ObjectInputStream os = new ObjectInputStream(fs); Object one = os.readObject(); character = (GameCharacter) one; os.close(); } catch(FileNotFoundException fex) { character = new GameCharacter();} catch(Exception ex) {ex.printStackTrace();} finally { game.gameGui();} } } }
java.lang.ClassCastException: javax.swing.KeyStroke cannot be cast to java.lang.Comparable   (182 Views)
The SWING frame work that i am using is working fine with jre1.6.When i try to run it through jre1.7 getting the below exception . java.lang.ClassCastException: javax.swing.KeyStroke cannot be cast to java.lang.Comparable at Source) at java.util.TreeMap.put(Unknown Source) at java.util.TreeSet.add(Unknown Source) Can any one help to reslove this ..
Change canvas background colour at button click   (233 Views)
I am developing Java applet, which have canvas in it. I want to change background color of canvas at one button click. i have changed it using c.offscreen.setColor(back); c.offscreen.fillRect(0, 0, c.getWidth(), c.getHeight()); c.repaint();
How can I change DefaultCellEditor#setClickCountToStart(int) for DefaultTreeCellEditor   (145 Views)
because TreeCellEditor is availble only at 3rd. mouse click my SSCCE demonstrate a.m. issue import java.awt.BorderLayout; import javax.swing.*; import javax.swing.tree.DefaultTreeCellEditor; import javax.swing.tree.DefaultTreeCellRenderer; import javax.swing.tree.TreeCellEditor; public class TreeEdit { public static void main(String args[]) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Object array[] = {Boolean.TRUE, Boolean.FALSE, ""}; JTree tree = new JTree(array); tree.setEditable(true); tree.setRootVisible(true); DefaultTreeCellRenderer renderer = (DefaultTreeCellRenderer) tree.getCellRenderer(); String elements[] = {"A", "B", "C", "D"}; JComboBox comboBox = new JComboBox(elements); comboBox.setEditable(true); TreeCellEditor comboEditor = new DefaultCellEditor(comboBox); TreeCellEditor editor = new DefaultTreeCellEditor(tree, renderer, comboEditor); tree.setCellEditor(editor); JScrollPane scrollPane = new JScrollPane(tree); frame.add(scrollPane, BorderLayout.CENTER); frame.setSize(300, 150); frame.setVisible(true); } }
how to create java application that scans picture with handyscan   (230 Views)
I am creating a java application such that if the user when run the application and when prompt to scan the user will scan by pressing a button on the handyscan magiscscan miscns(a handheld scanner by skypix handheld) and the scanned image will appear on the screen
I can't make my JTextArea Scrollable   (209 Views)
I am supposed to display data from a file into a JTextArea. To make it scrollable, I put it into a JScrollPane, but as soon as I input the data read from the file into JTextArea, the text goes out of bounds. If i don't put anything in the JTextArea, and enter text from keyboard, it remains scrollable, but if I set text read from a file, it's scroll doesn't work. Please help.
fillRect method, can't call it properly   (183 Views)
i m writing a java applet that accepts 4 parameters to draw a rectangle - x, y, width, height my problem is, i don't know how to call it in another method - square of asterisks, it needs a variable Graphics g to be supplied, but i don't know where to give this "g" variable! import java.awt.* ; import java.awt.event.* ; import javax.swing.* ; public class ex_6_21 extends JApplet implements ActionListener{ public void squareOfAsterisks(Graphics g, int x,int y, int width, int height){ super.paint(g) ; g.fillRect(x,y,width,height) ; } JTextField x,y,width, height ; JTextArea outputArea ; public void init(){ Container c = getContentPane() ; c.setLayout(new FlowLayout()) ; x = new JTextField(4) ; x.setEditable(true) ; c.add(x) ; y = new JTextField(4) ; y.setEditable(true) ; c.add(y) ; width = new JTextField(4) ; width.setEditable(true) ; c.add(width) ; height = new JTextField(4) ; height.setEditable(true) ; height.addActionListener(this) ; c.add(height) ; outputArea = new JTextArea() ; outputArea.setText("") ; c.add(outputArea) ; } public void actionPerformed(ActionEvent e){ int x_i = Integer.parseInt(x.getText()) ; int y_i = Integer.parseInt(y.getText()) ; int width_i = Integer.parseInt(width.getText()) ; int height_i = Integer.parseInt(height.getText()) ; Graphics g ; squareOfAsterisks( Graphics g, x_i, y_i, width_i, height_i) ; } }
Trying to run class in JFrame   (94 Views)
I've been trying for the last several days to get either an instance of a class (or an applet which does the same thing) to run in an application I have written. It's a pretty robust piece of software, which may be why I'm not able to implement it successfully. I posted about this yesterday but sadly didn't end up with a working solution. My IDEAL would be to run this plugin in a frame, I assume. The applet was, I had hoped, the easier of the two solutions but after spending about 20 hours trying to get this to work I may have been mistaken. I'm very new to Java, sort of learning by trial-by-fire, and up until now, it was going OK. I'm probably missing something very simple. I'll try to explain it as best I can: The plugin is called JTA. It's an SSH terminal that can run as an applet or independantly. From the website, There are two ways to operate the program. One is to simply start it and to configure everything within the application or to give arguments, like host and port, on the command line. The first way may be the least complicated as the menu entries are self descriptive. End users may find the application mode interesting as it provides a fast and reliable telnet implementation to login to other workstations or text-based online games, such as MUDs. Regarding MAIN, the class I am attempting to run in my frame: The Application (Main) There are two ways to operate the program. One is to simply start it and to configure everything within the application or to give arguments, like host and port, on the command line. The first way may be the least complicated as the menu entries are self descriptive. You need to have installed a java runtime environment or java development kit to run the application. On Microsoft Windows systems an installed Internet Explorer with Java support should suffice though. Quickstart Make sure either the program java (JRE, JDK) or jview (Windows IE) is in your path. Optionally you may set the environment variable CLASSPATH to point to the file jta20.jar (see the box to the right for more information). Then try the following command: JRE or JDK on UNIX or Windows (for Windows and IE installed, use jview instead) java de.mud.jta.Main alternative: java -jar jta20.jar Now you should see the following output: ** JTA - Telnet/SSH for the JAVA(tm) platformn ** Version 2.0 for Java 1.1.x and Java 2 ** Copyright (c) 1996-2000 Matthias L. Jugel, Marcus Meissner ** Build: 20000627-1208 jta: loading plugin 'Status' ... jta: loading plugin 'Socket' ... jta: loading plugin 'Telnet' ... jta: loading plugin 'Terminal' ... Some other messages might appear, but unless you see an Exception a window should appear on your screen and prompt you for login into your local host. If you are running on windows you will probably see an error message and should append the target host you want to connect to to the command line above. Command Line Options The application understand several command line arguments to configure the way it looks and where to initially connect to. The following command line arguments are possible: de.mud.jta.Main [-plugins pluginlist] [-addplugin plugin] [-config file] [host [port]] (Options enclosed in brackets are optional and may be left out.) I have attempted to use this is a JInternalFrame and also in a new test application. For the sake of simplicity I'll post my test application: package applettester; import javax.swing.*; import java.awt.*; import de.mud.jta.*; /** * * @author anthony.schmitt */ class TestFrame extends JFrame { public TestFrame() { setTitle( "Test Application" ); setSize( 200, 100 ); setBackground( Color.gray ); Panel topPanel = new Panel(); topPanel.setLayout( new BorderLayout() ); getContentPane().add( topPanel ); Main amain = new de.mud.jta.Main(); topPanel.add(amain); } // Main program started public static void main( String args[] ) { // Create an instance of the test application TestFrame mainFrame = new TestFrame(); mainFrame.setVisible( true ); } }
repaint() becomes slower as program runs   (242 Views)
Probably not related to your problem, but you shouldn't dispose() a Graphics that you didn't create. And its usual for a painting method override to start by invoking the super implementation.
I cannot for the *life* of me set the focus to my desired window.   (157 Views)
I've been at this for hours. I've now distilled it down to a very simple test program. First, I'm running JRE 7 on Linux (I've heard that can make a difference). Here is what I'd like the following program to do: 1. Open 3 windows 2. Set the focus to "TestWindow 1" What it actually does: 1. Opens 3 windows 2. Sets the focus typically to "TestWindow 3" and sometimes to "TestWindow 2" After much reading, I've moved the focus request (and almost everything else gui related for that matter) into the event dispatch thread. Please let me know your ideas! Now I'm dying of curiosity as to the solution. Class TestWindow import javax.swing.*; public class TestWindow { JFrame jFrame; TestWindow(String name, int x, int y) { DefaultListModel defaultListModel = new DefaultListModel(); defaultListModel.addElement("one"); defaultListModel.addElement("two"); defaultListModel.addElement("three"); JList jList = new JList(defaultListModel); JPanel jPanel = new JPanel(); jPanel.add(jList); jFrame = new JFrame(); jFrame.add(jPanel); jFrame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); jFrame.setTitle(name); jFrame.setSize(200, 100); jFrame.setLocation(x,y); jFrame.setVisible(true); } public JFrame getJFrame(){ return jFrame; } }
How to implement collapse on select in JMenu with JRadioButton as items?   (163 Views)
As for a common JMenuItem, it seems to be defaulted to collapse on select. Now I added two jRadioButtons in a menu, when I click on one, the command finishes but the radio menu is still there seemingly requests another select. I need to make it a collapse on select mode for user friendliness. How can that be done Thank you .
Is my problem because of 'StringBuilder'? Or do I need to some memory management (somehow)?   (155 Views)
I can recall seeing this problem before, where outcome so I googled jtextarea read large files this might be worth a read , probably worth posting your problem in the netbeans forum (search first - might get lucky), where you'll have many dedicated users/contributors who may have come across this issue before.
Java grid colouring in game   (114 Views)
HI I am new to java and wanted to design a programme to do the following: 1-create a 6x6 grid 2-each time a button is pressed ask the user to select from 6 colours and colour in the selected button 3-if a button is clicked that has a colour already go to default 4-each row/column can have one instance of each colour 5-as soon as the fifth colour is filled in in a row or column the sixth colour appears in the final blank square automatically. 6-once a row is completed the squares can nopt be clicked on any more. 7-data should be read in and colour the squares from a file which is of the form R1 C2 Green R1=row number C2=column number. i have the 6x6 grid and a window for colour choice but it needs fine tuning. the window should appear only once and it appears each time teh same button is pressed. import java.awt.*; import java.awt.event.*; import javax.swing.*; public class ButtonGrid extends JFrame implements ActionListener { private int numClicks = 0; public static void main(String[] args) { int rowsGrid = 6; int colsGrid = 6; int sizeGrid = 600; ButtonGrid grid = new ButtonGrid(rowsGrid, colsGrid); grid.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); grid.setPreferredSize(new Dimension(sizeGrid, sizeGrid)); grid.pack(); grid.setLocationRelativeTo(null); grid.setVisible(true); }//end main public ButtonGrid(int rows, int cols) { int rowsGrid = 6; int colsGrid = 6; int sizeGrid = 600; JButton[][] buttons; buttons = new JButton[sizeGrid][sizeGrid]; Container pane = getContentPane(); pane.setLayout(new GridLayout(rows, cols)); for(int j =0; j
Difference between JFrame and JPanel   (102 Views)
I would like to know the differences between JFrame and JPanel
Jframe   (83 Views)
How to add image in a Jframe