List of usage examples for javax.swing JScrollPane getBorder
public Border getBorder()
null
if no border is currently set. From source file:es.emergya.ui.gis.popups.SDSDialog.java
public SDSDialog(Recurso r) { super();/*from www. j a v a 2 s . c o m*/ setAlwaysOnTop(true); setResizable(false); iconTransparente = LogicConstants.getIcon("48x48_transparente"); iconEnviando = LogicConstants.getIcon("anim_enviando"); destino = r; setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { super.windowClosing(e); cancel.doClick(); } }); // setPreferredSize(new Dimension(400, 150)); setTitle(i18n.getString("window.sds.titleBar") + " " + r.getIdentificador()); try { setIconImage(((BasicWindow) GoClassLoader.getGoClassLoader().load(BasicWindow.class)).getFrame() .getIconImage()); } catch (Throwable e) { LOG.error("There is no icon image", e); } JPanel base = new JPanel(); base.setBackground(Color.WHITE); base.setLayout(new BoxLayout(base, BoxLayout.Y_AXIS)); // Icono del titulo JPanel title = new JPanel(new FlowLayout(FlowLayout.LEADING)); final JLabel titleLabel = new JLabel(i18n.getString("window.sds.title"), LogicConstants.getIcon("tittleventana_icon_enviarsds"), JLabel.LEFT); titleLabel.setFont(LogicConstants.deriveBoldFont(12f)); title.add(titleLabel); title.setOpaque(false); base.add(title); // Espacio para el mensaje sds = new JTextArea(7, 40); sds.setLineWrap(true); final JScrollPane sdsp = new JScrollPane(sds); sdsp.setOpaque(false); sdsp.setBorder(new TitledBorder(BorderFactory.createLineBorder(Color.BLACK), i18n.getString("Admin.message") + "\t (0/" + maxChars + ")")); sds.setDocument(new PlainDocument() { @Override public void insertString(int offs, String str, AttributeSet a) throws BadLocationException { if (this.getLength() + str.length() <= maxChars) { super.insertString(offs, str, a); } } }); sds.getDocument().addDocumentListener(new DocumentListener() { @Override public void removeUpdate(DocumentEvent e) { updateChars(e); } @Override public void insertUpdate(DocumentEvent e) { updateChars(e); } @Override public void changedUpdate(DocumentEvent e) { updateChars(e); } private void updateChars(DocumentEvent e) { ((TitledBorder) sdsp.getBorder()).setTitle( i18n.getString("Admin.message") + "\t (" + sds.getText().length() + "/" + maxChars + ")"); sdsp.repaint(); send.setEnabled(!sds.getText().isEmpty()); notification.setForeground(Color.WHITE); notification.setText("PLACEHOLDER"); } }); base.add(sdsp); // Area para mensajes JPanel notificationArea = new JPanel(); notificationArea.setOpaque(false); notification = new JLabel("TEXT"); notification.setForeground(Color.WHITE); notificationArea.add(notification); base.add(notificationArea); JPanel buttons = new JPanel(); buttons.setOpaque(false); buttons.setLayout(new BoxLayout(buttons, BoxLayout.X_AXIS)); send = new JButton(i18n.getString("Buttons.send"), LogicConstants.getIcon("ventanacontextual_button_enviarsds")); send.addActionListener(this); send.setEnabled(false); buttons.add(send); buttons.add(Box.createHorizontalGlue()); progressIcon = new JLabel(iconTransparente); buttons.add(progressIcon); buttons.add(Box.createHorizontalGlue()); cancel = new JButton(i18n.getString("Buttons.cancel"), LogicConstants.getIcon("button_cancel")); cancel.addActionListener(this); buttons.add(cancel); base.add(buttons); getContentPane().add(base); pack(); int x; int y; Container myParent; try { myParent = ((BasicWindow) GoClassLoader.getGoClassLoader().load(BasicWindow.class)).getFrame() .getContentPane(); java.awt.Point topLeft = myParent.getLocationOnScreen(); Dimension parentSize = myParent.getSize(); Dimension mySize = getSize(); if (parentSize.width > mySize.width) x = ((parentSize.width - mySize.width) / 2) + topLeft.x; else x = topLeft.x; if (parentSize.height > mySize.height) y = ((parentSize.height - mySize.height) / 2) + topLeft.y; else y = topLeft.y; setLocation(x, y); } catch (Throwable e1) { LOG.error("There is no basic window!", e1); } this.addWindowListener(new WindowAdapter() { @Override public void windowOpened(WindowEvent arg0) { deleteErrorMessage(); } @Override public void windowClosed(WindowEvent arg0) { deleteErrorMessage(); } private void deleteErrorMessage() { SwingWorker<Object, Object> sw = new SwingWorker<Object, Object>() { @Override protected Object doInBackground() throws Exception { if (bandejaSalida != null) { MessageGenerator.remove(bandejaSalida.getId()); } bandejaSalida = null; return null; } @Override protected void done() { super.done(); SDSDialog.this.sds.setText(""); SDSDialog.this.sds.setEnabled(true); SDSDialog.this.sds.repaint(); SDSDialog.this.progressIcon.setIcon(iconTransparente); SDSDialog.this.progressIcon.repaint(); SDSDialog.this.notification.setText(""); SDSDialog.this.notification.repaint(); } }; sw.execute(); } }); }
From source file:pcgen.gui2.dialog.ExportDialog.java
private void initLayout() { Container contentPane = getContentPane(); contentPane.setLayout(new BorderLayout()); Box topPanel = Box.createHorizontalBox(); topPanel.add(new JLabel("Select Character:")); topPanel.add(Box.createHorizontalStrut(5)); topPanel.add(characterBox);/*w w w . j a v a 2 s . c om*/ topPanel.add(Box.createHorizontalStrut(5)); topPanel.add(partyBox); topPanel.add(Box.createHorizontalGlue()); topPanel.add(Box.createHorizontalStrut(50)); topPanel.add(new JLabel("Export to:")); topPanel.add(Box.createHorizontalStrut(5)); topPanel.add(exportBox); contentPane.add(topPanel, BorderLayout.NORTH); JScrollPane scrollPane = new JScrollPane(fileList); scrollPane.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("Templates"), scrollPane.getBorder())); contentPane.add(scrollPane, BorderLayout.CENTER); Box bottomPanel = Box.createHorizontalBox(); bottomPanel.add(progressBar); bottomPanel.add(Box.createHorizontalGlue()); bottomPanel.add(Box.createHorizontalStrut(5)); bottomPanel.add(exportButton); bottomPanel.add(Box.createHorizontalStrut(5)); bottomPanel.add(closeButton); contentPane.add(bottomPanel, BorderLayout.SOUTH); topPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); bottomPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); pack(); }