Add scroll into text area

After adding JTextArea into JScrollPane here: scroll = new JScrollPane(display); You don’t need to add it again into other container like you do: middlePanel.add(display); Just remove that last line of code and it will work fine. Like this: middlePanel=new JPanel(); middlePanel.setBorder(new TitledBorder(new EtchedBorder(), “Display Area”)); // create the middle panel components display = new JTextArea(16, … Read more

Sizes of frame icons used in Swing

Typical views for this Windows 7 based PC Note: @bobbel reports the same sizes are used for Windows 10. Frame – 20×20 Task Bar – 40×40 in task bar itself, hover app shows 20×20 Windows+Tab – 20×20 Alt+Tab – 40×40 in lower right, shrunken 20×20 in upper left. Task Manager – 20×20

How To limit the number of characters in JTextField?

http://www.rgagnon.com/javadetails/java-0198.html import javax.swing.text.PlainDocument; import javax.swing.text.AttributeSet; import javax.swing.text.BadLocationException; public class JTextFieldLimit extends PlainDocument { private int limit; JTextFieldLimit(int limit) { super(); this.limit = limit; } public void insertString( int offset, String str, AttributeSet attr ) throws BadLocationException { if (str == null) return; if ((getLength() + str.length()) <= limit) { super.insertString(offset, str, attr); } } } … Read more

Text wrap in JOptionPane?

A JOptionPane will use a JLabel to display text by default. A label will format HTML. Set the maximum width in CSS. JOptionPane.showMessageDialog( this, “<html><body><p style=”width: 200px;”>”+exp.getMessage()+”</p></body></html>”, “Error”, JOptionPane.ERROR_MESSAGE); More generally, see How to Use HTML in Swing Components, as well as this simple example of using HTML in JLabel.

Please recommend pretty Java Swing components library [closed]

Why not use the standard java Look and Feels there are plenty: JGoodies JTatoo Jide look and feel Liquidlnf Napkin LaF PgsLookAndFeel Quaqua (looks like aqua from MacOS X) Seaglass The Alloy Look and Feel The native for your system The nimbus LaF The substance project (forked into the Insubstantial project) WebLookAndFeel Also see here … Read more

Deleting all the rows in a JTable

We can use DefaultTableModel.setRowCount(int) for this purpose, refering to Java’s Documentation: public void setRowCount(int rowCount) Sets the number of rows in the model. If the new size is greater than the current size, new rows are added to the end of the model If the new size is less than the current size, all rows … Read more

Filtering on a JTree [closed]

Take a look at this implementation: http://www.java2s.com/Code/Java/Swing-Components/InvisibleNodeTreeExample.htm It creates subclasses of DefaultMutableNode adding a “isVisible” property rather then actually removing/adding nodes from the TreeModel. Pretty sweet I think, and it solved my filtering problem neatly.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)