Fixed spacing in ComponentList
This commit is contained in:
parent
2fb419b0e7
commit
07b5ee841a
@ -166,14 +166,17 @@ public class ChatWindow extends JFrame {
|
|||||||
final JList<User> selectedUserList = (JList<User>) listSelectionEvent.getSource();
|
final JList<User> selectedUserList = (JList<User>) listSelectionEvent.getSource();
|
||||||
final User user = selectedUserList.getSelectedValue();
|
final User user = selectedUserList.getSelectedValue();
|
||||||
|
|
||||||
|
// Select current chat
|
||||||
currentChat = localDB.getChats().stream().filter(chat -> chat.getRecipient().getId() == user.getId()).findFirst().get();
|
currentChat = localDB.getChats().stream().filter(chat -> chat.getRecipient().getId() == user.getId()).findFirst().get();
|
||||||
|
|
||||||
// Set all unread messages in the chat to read
|
// Read current Chat
|
||||||
currentChat.read();
|
currentChat.read();
|
||||||
|
|
||||||
|
// Set recipient in client and chat title
|
||||||
client.setRecipient(user);
|
client.setRecipient(user);
|
||||||
textPane.setText(currentChat.getRecipient().getName());
|
textPane.setText(currentChat.getRecipient().getName());
|
||||||
|
|
||||||
|
// Update model and scroll down
|
||||||
messageList.setModel(currentChat.getModel());
|
messageList.setModel(currentChat.getModel());
|
||||||
scrollPane.setChatOpened(true);
|
scrollPane.setChatOpened(true);
|
||||||
|
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
package envoy.client.ui.list;
|
package envoy.client.ui.list;
|
||||||
|
|
||||||
|
import java.awt.Dimension;
|
||||||
|
|
||||||
import javax.swing.BoxLayout;
|
import javax.swing.BoxLayout;
|
||||||
|
import javax.swing.JComponent;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -57,10 +60,8 @@ public class ComponentList<E> extends JPanel {
|
|||||||
*/
|
*/
|
||||||
public void setModel(ComponentListModel<E> model) {
|
public void setModel(ComponentListModel<E> model) {
|
||||||
// Remove old model
|
// Remove old model
|
||||||
if (this.model != null) {
|
if (this.model != null)
|
||||||
this.model.clear();
|
|
||||||
this.model.setComponentList(null);
|
this.model.setComponentList(null);
|
||||||
}
|
|
||||||
|
|
||||||
// Synchronize with new model
|
// Synchronize with new model
|
||||||
this.model = model;
|
this.model = model;
|
||||||
@ -75,7 +76,14 @@ public class ComponentList<E> extends JPanel {
|
|||||||
* @param elem the element to add
|
* @param elem the element to add
|
||||||
* @since Envoy v0.3-alpha
|
* @since Envoy v0.3-alpha
|
||||||
*/
|
*/
|
||||||
void add(E elem) { add(renderer.getListCellComponent(this, elem, false)); }
|
void add(E elem) {
|
||||||
|
JComponent c = renderer.getListCellComponent(this, elem, false);
|
||||||
|
Dimension size = new Dimension(getWidth(), 50);
|
||||||
|
c.setMaximumSize(size);
|
||||||
|
c.setMinimumSize(size);
|
||||||
|
c.setPreferredSize(size);
|
||||||
|
add(c);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes all child components and then adds all components representing the
|
* Removes all child components and then adds all components representing the
|
||||||
@ -86,6 +94,6 @@ public class ComponentList<E> extends JPanel {
|
|||||||
void synchronizeModel() {
|
void synchronizeModel() {
|
||||||
removeAll();
|
removeAll();
|
||||||
if (model != null) for (E elem : model)
|
if (model != null) for (E elem : model)
|
||||||
add(renderer.getListCellComponent(this, elem, false));
|
add(elem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user