These images show a chat box that needs to be resized with the application frame. I'm using GroupLayout to do so. The hierarchy of the frame goes something like this
chatDiv(JPanel, GroupLayout)->chatTabbedPane(JTabbedPane, GroupLayout)
->chatPanel(extended JPanel, GroupLayout)
But, these individual chat_tabs(chatPanel) are added to the chatTabbedPane dynamically during application runtime.
Problem is: These chatPanel(s) are expanding with the expansion of application
frame but they are not shrinking with the shrink in width of application frame.
initialized frame
and when I expand and again shrink the application frame this happens (size of chatPanel doesn't shrink leading to invisible overflown region)..
expanded and again shrinked frame
Here is the class chatPanel that extends JPanel:
class chatPanel extends JPanel{
private static final long serialVersionUID = 1L;
GroupLayout gl_panel;
JTextArea textArea;
JTextField textField;
JButton sendTextButton;
JButton closeChatButton;
int replyRef;
public chatPanel(int ref){
//this.setLayout(null);
closeChatButton = new JButton("");
sendTextButton = new JButton("SEND");
textField = new JTextField();
textArea = new JTextArea();
replyRef = ref;
textArea.setWrapStyleWord(true);
textArea.setEditable(false);
textArea.setLineWrap(true);
//textArea.setBounds(0, 0, 370, 99);
this.add(textArea);
//textField.setBounds(0, 101, 290, 20);
//textField.setColumns(10);
this.add(textField);
sendTextButton.setFont(new Font("Tahoma", Font.PLAIN, 10));
//sendTextButton.setBounds(290, 101, 60, 19);
this.add(sendTextButton);
closeChatButton.setIcon(new ImageIcon("files/close.png"));
closeChatButton.setSelectedIcon(null);
closeChatButton.setToolTipText("CLOSE");
closeChatButton.setFont(new Font("Tahoma", Font.PLAIN, 5));
//closeChatButton.setBounds(350, 101, 20, 19);
this.add(closeChatButton);
gl_panel = new GroupLayout(this);
gl_panel.setHorizontalGroup(
gl_panel.createParallelGroup(Alignment.TRAILING)
.addGroup(gl_panel.createSequentialGroup()
.addGap(1)
.addComponent(textField, GroupLayout.DEFAULT_SIZE, 286, Short.MAX_VALUE)
.addGap(1)
.addComponent(sendTextButton, GroupLayout.PREFERRED_SIZE, 60, GroupLayout.PREFERRED_SIZE)
.addGap(1)
.addComponent(closeChatButton, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE)
.addGap(1))
.addComponent(textArea, GroupLayout.DEFAULT_SIZE, 370, Short.MAX_VALUE)
);
gl_panel.setVerticalGroup(
gl_panel.createParallelGroup(Alignment.LEADING)
.addGroup(gl_panel.createSequentialGroup()
.addComponent(textArea, GroupLayout.PREFERRED_SIZE, 100, GroupLayout.PREFERRED_SIZE)
.addGroup(gl_panel.createParallelGroup(Alignment.LEADING)
.addGroup(gl_panel.createSequentialGroup()
.addGap(1)
.addGroup(gl_panel.createParallelGroup(Alignment.TRAILING, false)
.addGroup(gl_panel.createSequentialGroup()
.addComponent(sendTextButton, GroupLayout.PREFERRED_SIZE, 19, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(ComponentPlacement.RELATED))
.addGroup(gl_panel.createSequentialGroup()
.addComponent(closeChatButton, GroupLayout.PREFERRED_SIZE, 19, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(ComponentPlacement.RELATED)))
.addGap(0, 0, Short.MAX_VALUE))
.addGroup(gl_panel.createSequentialGroup()
.addGap(1)
.addComponent(textField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addGap(1))))
);
this.setLayout(gl_panel);
}
}
and this is how I add these chatPanel(s) to chatTabbedPane
chatPanel newChat = new chatPanel(chatRef);
chatTabbedPane.addTab("title", null, newChat, null);
I want to shrink the size of chatPanel with shrink in size of application frame.
I've just run into this issue as well, and an answer like "just use another layout manager" isn't an answer I'm willing to accept.
To answer your question, the line wrap is messing things up.
textArea.setLineWrap(true);
Comment that line out and test again to see it will resize down with the window/frame like expected.
However, the side effect is obviously no line wraps. What's not so obvious is when your text length becomes greater than the textarea's width, when you resize the window the textarea's width will lock to the text's length. I still haven't found a fix for this new problem yet.
Related
im trying now for some hours to set the width of my TextPane.
My Code is like this :
private JTextPane eingabe = new JTextPane ();
private JTextPane ausgabe = new JTextPane ();
private JScrollPane scrollbar_eingabe = new JScrollPane(eingabe);
private JScrollPane scrollbar_ausgabe = new JScrollPane(ausgabe);
......
.......
private void createLayout(JComponent... arg) {
Container pane = this.getContentPane();
GroupLayout layout = new GroupLayout(pane);
pane.setLayout(layout);
layout.setAutoCreateContainerGaps(true);
layout.setAutoCreateGaps(true);
layout.setHorizontalGroup(
layout.createSequentialGroup() // ------
.addComponent(arg[0])
.addGroup(layout.createParallelGroup()
.addComponent(arg[1])
.addComponent(arg[2]))
.addGroup(layout.createParallelGroup()
.addComponent(arg[3])
.addComponent(arg[4]))
)
;
layout.setVerticalGroup(layout.createParallelGroup() // |||||
.addComponent(arg[0])
.addGroup(layout.createSequentialGroup()
.addComponent(arg[1])
.addComponent(arg[2]))
.addGroup(layout.createSequentialGroup()
.addComponent(arg[3])
.addComponent(arg[4]))
);
//gl.linkSize(pwd_text, user_text ,user, pwd, start);
pack();
}
protected void initWindow()
{
.....
createLayout(start, eingabe_text, scrollbar_eingabe,script_text, scrollbar_ausgabe);
}
The first arg is a button, the second one a label, then the first Textpane/ScrollPane, then another label and another ScrollPane.
The arrangement of the components is working so far, but i realy dont get it how to set the width of one of those text/scrollpanes.
The first one should have max a 1/3 of the width of the second Pane.
Everything in my program is working fine, but im just to dumb to set the width of this Scrollpane :(
Edit:
It should lock like this:
A1 A2 A4
A3 A5
And A3 should have the width A5/3.
Edit:
Okay, i solved the problem with this:
Dimension d = new Dimension();
d.height = 610;
d.width = 250;
arg[2].setPreferredSize(d);
Dimension d1 = new Dimension();
d1.height = 610;
d1.width = d.width * 4;
arg[4].setPreferredSize(d1);
layout.setHorizontalGroup(
layout.createSequentialGroup() // ------
.addComponent(arg[0])
.addGroup(layout.createParallelGroup()
.addComponent(arg[1])
.addComponent(arg[2], GroupLayout.PREFERRED_SIZE,
GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createParallelGroup()
.addComponent(arg[3])
.addComponent(arg[4], GroupLayout.PREFERRED_SIZE,
GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE))
)
;
layout.setVerticalGroup(layout.createParallelGroup() // |||||
.addComponent(arg[0])
.addGroup(layout.createSequentialGroup()
.addComponent(arg[1])
.addComponent(arg[2], GroupLayout.PREFERRED_SIZE,
GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addComponent(arg[3])
.addComponent(arg[4], GroupLayout.PREFERRED_SIZE,
GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE))
);
Working with grouplayout and other layouts is realy confusing in java ;D
If GroupLayout is not required to use, I would suggest other layout instead like GridLayout or GridBagLayout
or
JtextPane must be under different layout
The horizontal layout:
layout.setHorizontalGroup(
layout.createSequentialGroup()
.addComponent(find)
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING, false)
.addComponent(input, 0, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(amountWords, 0, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(displayWords, 0, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addComponent(clearButton)
);
The vertical layout:
layout.setVerticalGroup(
layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING, false)
.addComponent(find)
.addComponent(input)
.addComponent(clearButton))
.addComponent(amountWords)
.addComponent(displayWords)
);
I'm trying the make the input (JTextField), amountWords (JLabel) and the displayWords (JTextArea) resizable depending on the width and height of the screen. The height/length of the display words is already resizing depending of the height of the screen.
But how can I make the JTextField and the JTextArea resizable?
Thanks!
I'm attempting to create a small Jpanel with a GroupLayout infront of it. Having followed the documentation as much as possible as well as looked at a number of StackOverflow questions, I'm still stuck.
The error is as follows:
Exception in thread "AWT-EventQueue-0"
java.lang.IllegalStateException:
javax.swing.JButton[,0,0,0x0,invalid,alignmentX=0.0,alignmentY=0.5,border=com.apple.laf.AquaButtonBorder$Dynamic#5eef2e7c,flags=288,maximumSize=,minimumSize=,preferredSize=,defaultIcon=,disabledIcon=,disabledSelectedIcon=,margin=javax.swing.plaf.InsetsUIResource[top=0,left=2,bottom=0,right=2],paintBorder=true,paintFocus=true,pressedIcon=,rolloverEnabled=false,rolloverIcon=,rolloverSelectedIcon=,selectedIcon=,text=Invest,defaultCapable=true] is not attached to a vertical group
I know that the problem is related to where the buttons are being attached. After all the error says it explicitly. However, I just can't figure out in what manner I'm supposed to attach them. Any ideas?
JPanel panel = new JPanel();
GroupLayout layout = new GroupLayout(panel);
panel.setLayout(layout);
panel.setMinimumSize(new Dimension(2000,100));
panel.setBorder(BorderFactory.createTitledBorder((cdo.getTicker()) + " : (" + cdo.getCurrency() + ")"));
layout.setVerticalGroup(
layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(new JButton("Invest")))
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(new JButton("Ignore")))
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(new JButton("Article")))
);
layout.setHorizontalGroup(
layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(new JButton("Invest"))
.addComponent(new JButton("Ignore"))
.addComponent(new JButton("Article"))
)
);
new JButton("Invest") creates a new button, which is different from the button previously created using new JButton("Invest").
Move the initializations of the buttons before the layout:
JButton investButton = new JButton("Invest");
JButton articleButton = new JButton("Article");
JButton ignoreButton = new JButton("Ignore");
layout.setVerticalGroup(
layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(investButton))
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(ignoreButton))
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(articleButton)));
layout.setHorizontalGroup(
layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(investButton)
.addComponent(ignoreButton)
.addComponent(articleButton)));
I have following code for my java swing application which is executing fine in eclipse IDE but when I am embedding it in HTML then not executing in browser,just showing blank box.
Java swing code:
import javax.swing.*;
import java.applet.*;
import java.awt.*;
public class Form extends JApplet{
public void init()
{
JFrame frame = new JFrame("Form");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setResizable(false);
JPanel panel = new JPanel();
JLabel label1 = new JLabel("");
JTextField field = new JTextField(20);
//JButton button1 = new JButton("OK");
//JButton button2 = new JButton("Cancel");
Container c;
c=frame.getContentPane();
c.setLayout(null);
JLabel name=new JLabel("Name :");
JLabel compcode=new JLabel("Company Code :");
JLabel cardno=new JLabel("Card Number: ");
JLabel cardtype=new JLabel("Card Type :");
JLabel pin=new JLabel("Pin :");
JLabel bldgrp=new JLabel("Blood Group :");
JLabel empcode=new JLabel("Employee Code :");
JLabel dob=new JLabel("DOB :");
JLabel valupto=new JLabel("Valid Upto :");
JLabel jdate=new JLabel("Joining Date :");
JLabel dept=new JLabel("Department :");
JLabel uid=new JLabel("UID :");
JTextField nametxt=new JTextField(10);
JComboBox compcodetxt=new JComboBox();
JTextField cardnumtxt=new JTextField(10);
JTextField cardtypetxt=new JTextField(10);
JTextField pintxt=new JTextField(10);
JComboBox bldgrptxt=new JComboBox();
JTextField empcodetxt=new JTextField(10);
JTextField dobtxt=new JTextField(10);
JTextField valuptotxt=new JTextField(10);
JTextField jdatetxt=new JTextField(10);
JTextField depttxt=new JTextField(10);
JTextField uidtxt=new JTextField(10);
name.setBounds(10, 10, 100, 25);
nametxt.setBounds(110, 10, 100, 25);
compcode.setBounds(10, 40, 100, 25);
compcodetxt.setBounds(110, 40, 100, 25);
cardno.setBounds(10, 70, 100, 25);
cardnumtxt.setBounds(110, 70, 100, 25);
pin.setBounds(10, 110, 100, 25);
pintxt.setBounds(110, 110, 100, 25);
bldgrp.setBounds(10, 140, 100, 25);
bldgrptxt.setBounds(110, 140, 100, 25);
empcode.setBounds(10, 170, 100, 25);
empcodetxt.setBounds(110, 170, 100, 25);
dob.setBounds(10, 200, 100, 25);
dobtxt.setBounds(110, 200, 100, 25);
valupto.setBounds(10, 230, 100, 25);
valuptotxt.setBounds(110, 230, 100, 25);
jdate.setBounds(10, 260, 100, 25);
jdatetxt.setBounds(110, 260, 100, 25);
dept.setBounds(10, 290, 100, 25);
depttxt.setBounds(110, 290, 100, 25);
uid.setBounds(10, 320, 100, 25);
uidtxt.setBounds(110, 320, 100, 25);
//button1.setBounds(10, 50, 75, 25);
//button2.setBounds(10, 70, 75, 25);
c.add(name); c.add(nametxt);
c.add(compcode); c.add(compcodetxt);
c.add(cardno); c.add(cardnumtxt);
c.add(pin); c.add(pintxt);
c.add(bldgrp); c.add(bldgrptxt);
c.add(empcode); c.add(empcodetxt);
c.add(dob); c.add(dobtxt);
c.add(valupto); c.add(valuptotxt);
c.add(jdate); c.add(jdatetxt);
c.add(dept); c.add(depttxt);
c.add(uid); c.add(uidtxt);
//panel.add(button1);
//panel.add(button2);
//frame.add(panel);
frame.setSize(350,400);
//frame.pack();
frame.setVisible(true);
}
}
HTML code for embedding it in is as follows:
<html>
<head>
<title>Test Page</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<applet Archive ="Form.jar" Code="com.vms.util.Form" WIDTH="250" HEIGHT="300" >
</applet>
</html>
I generated JAR for my swing class Form.jar with package com.vms.util
I kept it in my D: drive form directory and put all html and jar in form directory.
I am able to run my swing application in HTML, how do I run it?
When I am running above code using appletviewer I am getting following error
D:\form>appletviewer Form2.html
java.security.AccessControlException: access denied (java.lang.RuntimePermission
exitVM.0)
at java.security.AccessControlContext.checkPermission(AccessControlConte
xt.java:374)
at java.security.AccessController.checkPermission(AccessController.java:
546)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
at java.lang.SecurityManager.checkExit(SecurityManager.java:744)
at javax.swing.JFrame.setDefaultCloseOperation(JFrame.java:372)
at Form.init(Form.java:10)
at sun.applet.AppletPanel.run(AppletPanel.java:424)
at java.lang.Thread.run(Thread.java:662)
comment following line
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Applets are not allowed (except by modifying directly the Java Security Policy on the client machine) to perform some critical calls. Even if using signed applets.
In your case, at javax.swing.JFrame.setDefaultCloseOperation is triggering the exception
it seems to be a small mistake, just enable java console and run the application.
it will help you to know what is the issue
PS: to enable java console on windows
go to control panel
select java
go to advance tab
Select applet lifecycle exception under Debugging section
Select Show console under Java Console Section.
Hope this will help you
i'm new in java and recently started to develop an simple application. For the moment i have a problem with JScrollPanne, it's not able to scroll down (or up) when the text in textarea more than size of area. I have looked to some solutions, but all of them were for FlowLayot (GridLayout and BoxLayout), but not for GroupLayout. Here is the code:
JPanel conent_p = new JPanel();
conent_p.setBorder(new TitledBorder(null, "", TitledBorder.LEADING, TitledBorder.TOP, null, null));
JLabel lblItemName = new JLabel("Item name:");
itemField = new JTextField();
itemField.setColumns(10);
JLabel lblMxPrice = new JLabel("Max price:");
mpriceField = new JTextField();
mpriceField.setColumns(10);
JLabel lblQuantity = new JLabel("Quantity:");
quanField = new JTextField();
quanField.setColumns(10);
JLabel lblDelivery = new JLabel("Delivery:");
delivField = new JTextField();
delivField.setColumns(10);
JLabel lblLogcat = new JLabel("LogCat:");
final JTextArea txtConsole = new JTextArea();
txtConsole.setEditable(false);
txtConsole.setLineWrap(true);
txtConsole.setWrapStyleWord(true);
sbrText = new JScrollPane(txtConsole);
sbrText.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
// Now create a new TextAreaOutputStream to write to our JTextArea control and wrap a
// PrintStream around it to support the println/printf methods.
PrintStream out = new PrintStream(new TextAreaOutputStream(txtConsole));
// redirect standard output stream to the TextAreaOutputStream
System.setOut(out);
// redirect standard error stream to the TextAreaOutputStream
System.setErr(out);
GroupLayout gl_conent_p = new GroupLayout(conent_p);
gl_conent_p.setHorizontalGroup(
gl_conent_p.createParallelGroup(Alignment.LEADING)
.addGroup(gl_conent_p.createSequentialGroup()
.addContainerGap()
.addGroup(gl_conent_p.createParallelGroup(Alignment.LEADING)
.addComponent(lblMxPrice, Alignment.TRAILING)
.addComponent(lblItemName, Alignment.TRAILING)
.addComponent(lblLogcat, Alignment.TRAILING))
.addGap(18)
.addGroup(gl_conent_p.createParallelGroup(Alignment.LEADING)
.addGroup(gl_conent_p.createSequentialGroup()
.addGroup(gl_conent_p.createParallelGroup(Alignment.LEADING, false)
.addComponent(itemField, GroupLayout.PREFERRED_SIZE, 365, GroupLayout.PREFERRED_SIZE)
.addGroup(gl_conent_p.createSequentialGroup()
.addComponent(mpriceField, GroupLayout.PREFERRED_SIZE, 80, GroupLayout.PREFERRED_SIZE)
.addGap(18)
.addComponent(lblQuantity)
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(quanField, 0, 0, Short.MAX_VALUE)
.addGap(18)
.addComponent(lblDelivery)
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(delivField, GroupLayout.PREFERRED_SIZE, 80, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(ComponentPlacement.RELATED)))
.addGap(100))
.addGroup(gl_conent_p.createSequentialGroup()
.addComponent(txtConsole, GroupLayout.PREFERRED_SIZE, 345, GroupLayout.PREFERRED_SIZE)
.addComponent(sbrText)
.addContainerGap())))
);
gl_conent_p.setVerticalGroup(
gl_conent_p.createParallelGroup(Alignment.LEADING)
.addGroup(gl_conent_p.createSequentialGroup()
.addContainerGap()
.addGroup(gl_conent_p.createParallelGroup(Alignment.BASELINE)
.addComponent(lblItemName)
.addComponent(itemField, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE))
.addGap(20)
.addGroup(gl_conent_p.createParallelGroup(Alignment.LEADING)
.addGroup(gl_conent_p.createParallelGroup(Alignment.BASELINE)
.addComponent(lblDelivery)
.addComponent(delivField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addGroup(gl_conent_p.createParallelGroup(Alignment.BASELINE)
.addComponent(lblMxPrice)
.addComponent(mpriceField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addComponent(lblQuantity)
.addComponent(quanField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)))
.addGap(55)
.addGroup(gl_conent_p.createParallelGroup(Alignment.BASELINE)
.addComponent(lblLogcat)
.addComponent(txtConsole, GroupLayout.PREFERRED_SIZE, 200, GroupLayout.PREFERRED_SIZE)
.addComponent(sbrText))
.addContainerGap())
);
conent_p.setLayout(gl_conent_p);
getContentPane().add(conent_p, BorderLayout.NORTH);
JButton btnBuy = new JButton("Buy");
btnBuy.addActionListener( new ActionListener() {
public void actionPerformed(ActionEvent ev) {
try {
String title = itemField.getText().trim();
String mprice = mpriceField.getText().trim();
String quantity = quanField.getText().trim();
String deliver = delivField.getText().trim();
Item_CONCEPT item = new Item_CONCEPT();
item.setName(title);
item.setDelivery(Integer.parseInt(deliver));
item.setStartPrice(0);
item.setMaxPrice(Integer.parseInt(mprice));
myAgent.existsSeller(item);
Date date = new Date();
DateFormat df = new SimpleDateFormat("dd.MM.yy HH:mm");
System.out.println(df.format(date)+": Buyer orders an item: "+item.getName());
//Clearing all fields
itemField.setText("");
quanField.setText("");
delivField.setText("");
//txtConsole.setText("");
mpriceField.setText("");
}
catch (Exception e) {
JOptionPane.showMessageDialog(BuyerGUI.this, "A field is filled incorrectly. "+e.getMessage()+" is invalid.", "Error", JOptionPane.ERROR_MESSAGE);
}
}
} );![enter image description here][1]
The issue you observe comes from two facts:
You are adding your content panel to BorderLayout.NORTH
You add the text console as well as the scroll pane as separate components
For the first one: replace
getContentPane().add(conent_p, BorderLayout.NORTH);
with
getContentPane().add(conent_p, BorderLayout.CENTER);
and for the second: do not add the txtConsole separately, i.e.
inside the horizontal group substitute
.addGroup(gl_conent_p.createSequentialGroup()
.addComponent(txtConsole, GroupLayout.PREFERRED_SIZE, 345, GroupLayout.PREFERRED_SIZE)
.addComponent(sbrText).addContainerGap());
with
.addComponent(sbrText);
and inside the vertical group
.addGroup(gl_conent_p.createParallelGroup(Alignment.BASELINE)
.addComponent(lblLogcat)
.addComponent(txtConsole, GroupLayout.PREFERRED_SIZE, 200, GroupLayout.PREFERRED_SIZE)
.addComponent(sbrText)).addContainerGap()));
with
.addGroup(gl_conent_p.createParallelGroup(Alignment.BASELINE)
.addComponent(lblLogcat)
.addComponent(sbrText)).addContainerGap()));
Not sure whether this is the problem (as you did not provide an SSCCE, just a piece of code), but you are both adding the txtConsole and the sbrText:
.addComponent(txtConsole, GroupLayout.PREFERRED_SIZE, 200, GroupLayout.PREFERRED_SIZE)
.addComponent(sbrText)
When you put the text area in a scrollpane, it is sufficient to add the scrollpane.
Further, I would recommend to set the preferred size of the scroll pane, as shown in the scroll pane tutorial