How to print hidden and visible content of a Container with ScrollBars

These sets of methods allow to print the content of a ScrollableControl to a Bitmap. A description of the procedure: The control is first scrolled back to the origin ([ScrollableControl].AutoScrollPosition = new Point(0, 0) (an exception is raised otherwise: the Bitmap has a wrong size. You may want to store the current scroll position and … Read more

Chat Client emoticons window JAVA

This ListPanel might be a useful, as the DefaultListCellRenderer can display an Icon. Icon icon = UIManager.getIcon(“html.pendingImage”); … @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { JLabel label = (JLabel) super.getListCellRendererComponent( list, value, index, isSelected, cellHasFocus); label.setBorder(BorderFactory.createEmptyBorder(N, N, N, N)); label.setIcon(icon); label.setHorizontalTextPosition(JLabel.CENTER); label.setVerticalTextPosition(JLabel.BOTTOM); return label; }

Create Java console inside a GUI panel

Here’s a functioning class. You can install an instance of this into the system out and err using: PrintStream con=new PrintStream(new TextAreaOutputStream(…)); System.setOut(con); System.setErr(con); Updated 2014-02-19: To use EventQueue.invokeLater() to avoid GUI threading issues which can crop up very rarely with the original. Updated 2014-02-27: Better implementation Updated 2014-03-25: Correct recording & deletion of lines … Read more

Panel not getting focus

The Panel class was designed as container, it avoids taking the focus so a child control will always get it. You’ll need some surgery to fix that. I threw in the code to get cursor key strokes in the KeyDown event as well: using System; using System.Drawing; using System.Windows.Forms; class SelectablePanel : Panel { public … Read more