Hi,
für ein Projekt an der Hochschule soll ich eine Startseite für eine Applikation basteln.
Dabei habe ich den GUI-Builder Jigloo zu Hilfe genommen.
Mein Problem ist das ScrollPane. Sobald ich nur ein TextPane innerhalb des ScrollPanes erzeuge, ändert das ScrollPane seine Größe und ich habe keine Ahnung wieso...
Zur Verdeutlichung meines Problems hänge ich noch 2 Bilder an.
Vielen Dank schon mal im Vorraus.
mr baam
Diese Größe soll das ScrollPane behalten.
So sieht es aus, wenn nur ein TextPane im ScrollPane vorhanden ist.
für ein Projekt an der Hochschule soll ich eine Startseite für eine Applikation basteln.
Dabei habe ich den GUI-Builder Jigloo zu Hilfe genommen.
Mein Problem ist das ScrollPane. Sobald ich nur ein TextPane innerhalb des ScrollPanes erzeuge, ändert das ScrollPane seine Größe und ich habe keine Ahnung wieso...
Zur Verdeutlichung meines Problems hänge ich noch 2 Bilder an.
Vielen Dank schon mal im Vorraus.
mr baam
Diese Größe soll das ScrollPane behalten.
So sieht es aus, wenn nur ein TextPane im ScrollPane vorhanden ist.
Java:
import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextPane;
import javax.swing.SwingConstants;
import javax.swing.WindowConstants;
import java.awt.GridLayout;
import javax.swing.BoxLayout;
/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit [url=http://www.cloudgarden.com]Cloud Garden (Java Resources)[/url] for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class NewJPanel extends javax.swing.JPanel {
private JPanel jPanelLeft;
private JPanel jPanelRightTop;
private JPanel jPanelRightBottom;
private JPanel jPanelRequest;
private JPanel jPanelProjects;
private JPanel jPanelNewsfeed;
private JPanel jPanelNews;
private JLabel jLabelAnfragen;
private JLabel jLabelProjekte;
private JLabel jLabelNews;
private JScrollPane scrollPane;
/**
* Auto-generated main method to display this
* JPanel inside a new JFrame.
*/
public static void main(String[] args) {
JFrame frame = new JFrame();
frame.getContentPane().add(new NewJPanel());
frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
frame.pack();
frame.setVisible(true);
}
public NewJPanel() {
super();
initGUI();
}
private void initGUI() {
try {
GridBagLayout thisLayout = new GridBagLayout();
setPreferredSize(new Dimension(784, 509));
thisLayout.rowWeights = new double[] {0.1, 0.1, 0.1, 0.1, 0.1, 0.1};
thisLayout.rowHeights = new int[] {7, 7, 7, 7, 7, 7};
thisLayout.columnWeights = new double[] {0.1, 0.1, 0.1, 0.1, 0.1, 0.1};
thisLayout.columnWidths = new int[] {7, 7, 7, 7, 7, 7};
this.setLayout(thisLayout);
this.setBackground(new java.awt.Color(64,64,64));
jPanelLeft = new JPanel();
GridBagLayout jPanelRotLayout = new GridBagLayout();
this.add(jPanelLeft, new GridBagConstraints(0, 0, 3, 6, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(40, 10, 10, 10), 0, 0));
jPanelLeft.setBackground(new java.awt.Color(64,64,64));
jPanelRotLayout.rowWeights = new double[] {0.1, 0.1, 0.1, 0.1};
jPanelRotLayout.rowHeights = new int[] {7, 7, 7, 7};
jPanelRotLayout.columnWeights = new double[] {0.1, 0.1, 0.1, 0.1};
jPanelRotLayout.columnWidths = new int[] {7, 7, 7, 7};
jPanelLeft.setLayout(jPanelRotLayout);
jPanelLeft.setSize(370, 422);
jLabelNews = new JLabel();
jPanelLeft.add(jLabelNews, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(3, 3, 0, 0), 0, 0));
jLabelNews.setText("Newsfeed");
jLabelNews.setBackground(new java.awt.Color(255,108,108));
jLabelNews.setForeground(new java.awt.Color(255,255,255));
jPanelNewsfeed = new JPanel();
jPanelLeft.add(jPanelNewsfeed, new GridBagConstraints(0, 0, 4, 4, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(25, 0, 0, 0), 0, 0));
jPanelNewsfeed.setBackground(new java.awt.Color(255,200,0));
jPanelNewsfeed.setSize(344, 390);
jPanelNewsfeed.setLayout(new GridLayout(0, 1, 0, 0));
jPanelNews = new JPanel();
GridLayout jPanelNewsLayout = new GridLayout(0, 1);
jPanelNewsLayout.setColumns(1);
jPanelNewsLayout.setHgap(5);
jPanelNewsLayout.setVgap(5);
jPanelNews.setLayout(jPanelNewsLayout);
jPanelNews.setBackground(new java.awt.Color(255,200,0));
for(int i = 0; i < 20; i++) {
JTextPane t_pane = new JTextPane();
t_pane.setText("Lorem ipsum dolor sit amet, consetetur sadipscing elitrsf asfs afsafsa asf asf asf asf asfas");
t_pane.setPreferredSize(new Dimension(300,40));
t_pane.setBackground(Color.ORANGE);
jPanelNews.add(t_pane);
}
scrollPane = new JScrollPane(jPanelNews);
scrollPane.setBackground(new java.awt.Color(255,108,108));
jPanelNewsfeed.add(scrollPane);
jPanelRightTop = new JPanel();
GridBagLayout jPanelBlauLayout = new GridBagLayout();
this.add(jPanelRightTop, new GridBagConstraints(3, 0, 3, 3, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(40, 10, 5, 10), 0, 0));
jPanelRightTop.setBackground(new java.awt.Color(64,64,64));
jPanelBlauLayout.rowWeights = new double[] {0.1, 0.1, 0.1, 0.1};
jPanelBlauLayout.rowHeights = new int[] {7, 7, 7, 7};
jPanelBlauLayout.columnWeights = new double[] {0.1, 0.1, 0.1, 0.1};
jPanelBlauLayout.columnWidths = new int[] {7, 7, 7, 7};
jPanelRightTop.setLayout(jPanelBlauLayout);
jPanelRightTop.setSize(370, 181);
jLabelProjekte = new JLabel();
jPanelRightTop.add(jLabelProjekte, new GridBagConstraints(0, 0, 4, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(3, 3, 0, 0), 0, 0));
jLabelProjekte.setText("Meine Projekte");
jLabelProjekte.setForeground(new java.awt.Color(255,255,255));
jPanelProjects = new JPanel();
jPanelRightTop.add(jPanelProjects, new GridBagConstraints(0, 0, 4, 4, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(25, 0, 0, 0), 0, 0));
jPanelProjects.setBackground(new java.awt.Color(255,200,0));
jPanelRightBottom = new JPanel();
GridBagLayout jPanelGelbLayout = new GridBagLayout();
this.add(jPanelRightBottom, new GridBagConstraints(3, 3, 3, 3, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(30, 10, 10, 10), 0, 0));
jPanelRightBottom.setBackground(new java.awt.Color(64,64,64));
jPanelGelbLayout.rowWeights = new double[] {0.1, 0.1, 0.1, 0.1};
jPanelGelbLayout.rowHeights = new int[] {7, 7, 7, 7};
jPanelGelbLayout.columnWeights = new double[] {0.1, 0.1, 0.1, 0.1};
jPanelGelbLayout.columnWidths = new int[] {7, 7, 7, 7};
jPanelRightBottom.setLayout(jPanelGelbLayout);
jPanelRightBottom.setSize(370, 181);
jLabelAnfragen = new JLabel();
jPanelRightBottom.add(jLabelAnfragen, new GridBagConstraints(0, 0, 4, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(3, 3, 0, 0), 0, 0));
jLabelAnfragen.setText("Meine Projektanfragen");
jLabelAnfragen.setForeground(new java.awt.Color(255,255,255));
jPanelRequest = new JPanel();
FlowLayout jPanelRequestLayout = new FlowLayout();
jPanelRequest.setLayout(jPanelRequestLayout);
jPanelRightBottom.add(jPanelRequest, new GridBagConstraints(0, 0, 4, 4, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(25, 0, 0, 0), 0, 0));
jPanelRequest.setBackground(new java.awt.Color(255,200,0));
} catch (Exception e) {
e.printStackTrace();
}
}
}