中央にあるJTextPaneを保持しているJScrollPaneを隠しているように見える境界線レイアウトを使用しています。Center JScrollPaneを強制的に表示するにはどうすればよいですか?
package net.bounceme.dur.usenet.swing;
import java.util.Observable;
import java.util.Observer;
import java.util.logging.Logger;
import javax.mail.Folder;
import javax.swing.ListModel;
import net.bounceme.dur.usenet.controller.Controller;
import net.bounceme.dur.usenet.controller.MessageBean;
import net.bounceme.dur.usenet.controller.MessagesDefaultListModel;
public class MessageSelect extends javax.swing.JPanel implements Observer {
private static final Logger LOG = Logger.getLogger(MessageSelect.class.getName());
private Controller controller = Controller.getInstance();
private ListModel messages = new MessagesDefaultListModel();
private MessageBean messageBean = new MessageBean();
public MessageSelect() {
controller.addObserver(this);
initComponents();
messageContent.setText("hello world");
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
center = new javax.swing.JScrollPane();
messageContent = new javax.swing.JTextPane();
south = new javax.swing.JPanel();
commentJButton = new javax.swing.JButton();
west = new javax.swing.JScrollPane();
messagesJList = new javax.swing.JList();
setLayout(new java.awt.BorderLayout());
messageContent.setContentType("text/html"); // NOI18N
center.setViewportView(messageContent);
add(center, java.awt.BorderLayout.CENTER);
south.setLayout(new java.awt.BorderLayout());
commentJButton.setText("comment");
commentJButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
commentJButtonActionPerformed(evt);
}
});
south.add(commentJButton, java.awt.BorderLayout.CENTER);
add(south, java.awt.BorderLayout.SOUTH);
messagesJList.setModel(new javax.swing.AbstractListModel() {
String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
public int getSize() { return strings.length; }
public Object getElementAt(int i) { return strings[i]; }
});
messagesJList.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseReleased(java.awt.event.MouseEvent evt) {
messagesJListMouseReleased(evt);
}
});
messagesJList.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyReleased(java.awt.event.KeyEvent evt) {
messagesJListKeyReleased(evt);
}
});
west.setViewportView(messagesJList);
add(west, java.awt.BorderLayout.WEST);
}// </editor-fold>
private void commentJButtonActionPerformed(java.awt.event.ActionEvent evt) {
LOG.fine("button clicked" + messageBean);
}
private void messagesJListKeyReleased(java.awt.event.KeyEvent evt) {
userSelectedRow();
}
private void messagesJListMouseReleased(java.awt.event.MouseEvent evt) {
userSelectedRow();
}
// Variables declaration - do not modify
private javax.swing.JScrollPane center;
private javax.swing.JButton commentJButton;
private javax.swing.JTextPane messageContent;
private javax.swing.JList messagesJList;
private javax.swing.JPanel south;
private javax.swing.JScrollPane west;
// End of variables declaration
@Override
@SuppressWarnings("unchecked")
public void update(Observable o, Object arg) {
LOG.fine("trying folder: " + arg);
//Folder folder = null;
try {
Folder folder = (Folder) arg;
messages = new MessagesDefaultListModel(folder);
LOG.fine("how many messages? " + messages.getSize());
messagesJList.setModel(messages);
LOG.fine("loaded messages..");
} catch (Exception e) { //err, class cast exception?
LOG.fine("not a valid folder " + arg);
}
}
private void userSelectedRow() {
messageBean = (MessageBean) messagesJList.getSelectedValue();
LOG.fine(messageBean.toString());
messageContent.setText(messageBean.getContent());
LOG.fine("..gotMessageBean: " + messageBean);
}
}
下の最初のタブでは、USENETグループを選択できます。一部のグループは、他のグループよりも適切に動作します。androidグループは、通常のサイズのウィンドウにCENTERJScrollPaneが表示されないという点で独特です。
ただし、ウィンドウを最大化すると、CENTERJSCrollPaneが正しく表示されます。