JTextArea on JScrollPane not appearing on JPanel












2















I'm writing a program that's supposed to print text. I need it to be on a JScrollPane and I also need to be able to go to the next page of text by clicking on a next page button.



The only way I can get any text to show up is by adding the text directly to the pane. (line 91 ctPanel.add(bText);)



public class RP extends JPanel{

private Border simpleBorder;
private JPanel iPanel;
private JPanel ctPanel;
private JPanel nPanel;
private JLabel T;
private JLabel A;
private JLabel P;
private JButton upButton;
private JButton downButton;
public JTextArea bText;
private JScrollPane Scroll;
private String placeholder;

public RP()
{

this.setPreferredSize(new Dimension(720,700));

simpleBorder = BorderFactory.createLineBorder(Color.GRAY);
//this.setBorder(BorderFactory.createTitledBorder(simpleBorder, "R"));
this.setLayout(new BorderLayout());

// start of i panel:

placeholder = new String("nothing right now");

iPanel = new JPanel();
this.add(iPanel, BorderLayout.NORTH);
iPanel.setBorder(BorderFactory.createTitledBorder(simpleBorder, "I"));

T = new JLabel();
T.setText("T: " + placeholder);
iPanel.add(T, BorderLayout.WEST);

A = new JLabel();
A.setText("B: " + placeholder);
iPanel.add(A, BorderLayout.CENTER);

P = new JLabel();
P.setText("P: " + placeholder);
iPanel.add(P, BorderLayout.EAST);


// start of ct panel (RP -> Ct Panel):

ctPanel = new JPanel();
ctPanel.setBorder(BorderFactory.createTitledBorder(simpleBorder, "C"));
ctPanel.setLayout(new BorderLayout());



// Create JScrollPane and add it to Ct Panel
Scroll = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);



// create btext area
bText = new JTextArea();
bText.setEditable(false);
bText.setText("Nothing right now.");

//add text to scroll pane
Scroll.add(bText);



//add scroll pane to ct panel
ctPanel.add(Scroll, BorderLayout.CENTER);




//add ct panel to RP
ctPanel.add(bText); // IF I COMMENT THIS OUT, THE TEXT WON'T APPEAR IN THE
CONTENT PANEL
this.add(ctPanel, BorderLayout.CENTER);

// start of navigation panel:

nPanel = new JPanel();
this.add(nPanel, BorderLayout.SOUTH);
nPanel.setBorder(BorderFactory.createTitledBorder(simpleBorder,"Navigation")
);

upButton = new JButton();
upButton.setText("Up");
nPanel.add(upButton, BorderLayout.WEST);

downButton = new JButton();
downButton.setText("Down");
nPanel.add(downButton, BorderLayout.EAST);

// revalidate and repaint:
this.revalidate();
this.repaint();
}


// method to set text in bText JTextField from another class
public void setBText(String text)
{
bText.setText(text);
}

// method to set T info to i panel from another class
public void setTInfo(String text)
{
T.setText("T: " + text);
}

// method to set A info to i panel from another class
public void setAInfo(String text)
{
A.setText("B " + text);
}

}









share|improve this question

























  • "Any help is appreciated.." What is the question? General tips: 1) For better help sooner, edit to add a Minimal, Complete, and Verifiable example or Short, Self Contained, Correct Example. 2) Use a logical and consistent form of indenting code lines and blocks. The indentation is intended to make the flow of the code easier to follow! 3) A single blank line of white space in source code is all that is ever needed. Blank lines after { or before } are also typically redundant. 4) bText = new JTextArea(); should be more like bText = new JTextArea(20,4); // suggest a size ..

    – Andrew Thompson
    Nov 21 '18 at 1:11











  • 5) this.setPreferredSize(new Dimension(720,700)); This is just a guess. Remove it and instead pack() the top level window once all components are added. The panel will end up the smallest size it needs to be in order to display the components it contains (and their borders and padding as coded). 6) Please learn common Java nomenclature (naming conventions - e.g. EachWordUpperCaseClass, firstWordLowerCaseMethod(), firstWordLowerCaseAttribute unless it is an UPPER_CASE_CONSTANT) and use it consistently.

    – Andrew Thompson
    Nov 21 '18 at 1:12













  • @AndrewThompson thank you! This was my first post, so I felt pretty unsure about how to do it properly. My main problem was that I couldn't get bText to show up on the JScrollPane. The suggestion from camickr to use the .setViewportView did the trick.

    – J.S.M.
    Nov 21 '18 at 3:06
















2















I'm writing a program that's supposed to print text. I need it to be on a JScrollPane and I also need to be able to go to the next page of text by clicking on a next page button.



The only way I can get any text to show up is by adding the text directly to the pane. (line 91 ctPanel.add(bText);)



public class RP extends JPanel{

private Border simpleBorder;
private JPanel iPanel;
private JPanel ctPanel;
private JPanel nPanel;
private JLabel T;
private JLabel A;
private JLabel P;
private JButton upButton;
private JButton downButton;
public JTextArea bText;
private JScrollPane Scroll;
private String placeholder;

public RP()
{

this.setPreferredSize(new Dimension(720,700));

simpleBorder = BorderFactory.createLineBorder(Color.GRAY);
//this.setBorder(BorderFactory.createTitledBorder(simpleBorder, "R"));
this.setLayout(new BorderLayout());

// start of i panel:

placeholder = new String("nothing right now");

iPanel = new JPanel();
this.add(iPanel, BorderLayout.NORTH);
iPanel.setBorder(BorderFactory.createTitledBorder(simpleBorder, "I"));

T = new JLabel();
T.setText("T: " + placeholder);
iPanel.add(T, BorderLayout.WEST);

A = new JLabel();
A.setText("B: " + placeholder);
iPanel.add(A, BorderLayout.CENTER);

P = new JLabel();
P.setText("P: " + placeholder);
iPanel.add(P, BorderLayout.EAST);


// start of ct panel (RP -> Ct Panel):

ctPanel = new JPanel();
ctPanel.setBorder(BorderFactory.createTitledBorder(simpleBorder, "C"));
ctPanel.setLayout(new BorderLayout());



// Create JScrollPane and add it to Ct Panel
Scroll = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);



// create btext area
bText = new JTextArea();
bText.setEditable(false);
bText.setText("Nothing right now.");

//add text to scroll pane
Scroll.add(bText);



//add scroll pane to ct panel
ctPanel.add(Scroll, BorderLayout.CENTER);




//add ct panel to RP
ctPanel.add(bText); // IF I COMMENT THIS OUT, THE TEXT WON'T APPEAR IN THE
CONTENT PANEL
this.add(ctPanel, BorderLayout.CENTER);

// start of navigation panel:

nPanel = new JPanel();
this.add(nPanel, BorderLayout.SOUTH);
nPanel.setBorder(BorderFactory.createTitledBorder(simpleBorder,"Navigation")
);

upButton = new JButton();
upButton.setText("Up");
nPanel.add(upButton, BorderLayout.WEST);

downButton = new JButton();
downButton.setText("Down");
nPanel.add(downButton, BorderLayout.EAST);

// revalidate and repaint:
this.revalidate();
this.repaint();
}


// method to set text in bText JTextField from another class
public void setBText(String text)
{
bText.setText(text);
}

// method to set T info to i panel from another class
public void setTInfo(String text)
{
T.setText("T: " + text);
}

// method to set A info to i panel from another class
public void setAInfo(String text)
{
A.setText("B " + text);
}

}









share|improve this question

























  • "Any help is appreciated.." What is the question? General tips: 1) For better help sooner, edit to add a Minimal, Complete, and Verifiable example or Short, Self Contained, Correct Example. 2) Use a logical and consistent form of indenting code lines and blocks. The indentation is intended to make the flow of the code easier to follow! 3) A single blank line of white space in source code is all that is ever needed. Blank lines after { or before } are also typically redundant. 4) bText = new JTextArea(); should be more like bText = new JTextArea(20,4); // suggest a size ..

    – Andrew Thompson
    Nov 21 '18 at 1:11











  • 5) this.setPreferredSize(new Dimension(720,700)); This is just a guess. Remove it and instead pack() the top level window once all components are added. The panel will end up the smallest size it needs to be in order to display the components it contains (and their borders and padding as coded). 6) Please learn common Java nomenclature (naming conventions - e.g. EachWordUpperCaseClass, firstWordLowerCaseMethod(), firstWordLowerCaseAttribute unless it is an UPPER_CASE_CONSTANT) and use it consistently.

    – Andrew Thompson
    Nov 21 '18 at 1:12













  • @AndrewThompson thank you! This was my first post, so I felt pretty unsure about how to do it properly. My main problem was that I couldn't get bText to show up on the JScrollPane. The suggestion from camickr to use the .setViewportView did the trick.

    – J.S.M.
    Nov 21 '18 at 3:06














2












2








2








I'm writing a program that's supposed to print text. I need it to be on a JScrollPane and I also need to be able to go to the next page of text by clicking on a next page button.



The only way I can get any text to show up is by adding the text directly to the pane. (line 91 ctPanel.add(bText);)



public class RP extends JPanel{

private Border simpleBorder;
private JPanel iPanel;
private JPanel ctPanel;
private JPanel nPanel;
private JLabel T;
private JLabel A;
private JLabel P;
private JButton upButton;
private JButton downButton;
public JTextArea bText;
private JScrollPane Scroll;
private String placeholder;

public RP()
{

this.setPreferredSize(new Dimension(720,700));

simpleBorder = BorderFactory.createLineBorder(Color.GRAY);
//this.setBorder(BorderFactory.createTitledBorder(simpleBorder, "R"));
this.setLayout(new BorderLayout());

// start of i panel:

placeholder = new String("nothing right now");

iPanel = new JPanel();
this.add(iPanel, BorderLayout.NORTH);
iPanel.setBorder(BorderFactory.createTitledBorder(simpleBorder, "I"));

T = new JLabel();
T.setText("T: " + placeholder);
iPanel.add(T, BorderLayout.WEST);

A = new JLabel();
A.setText("B: " + placeholder);
iPanel.add(A, BorderLayout.CENTER);

P = new JLabel();
P.setText("P: " + placeholder);
iPanel.add(P, BorderLayout.EAST);


// start of ct panel (RP -> Ct Panel):

ctPanel = new JPanel();
ctPanel.setBorder(BorderFactory.createTitledBorder(simpleBorder, "C"));
ctPanel.setLayout(new BorderLayout());



// Create JScrollPane and add it to Ct Panel
Scroll = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);



// create btext area
bText = new JTextArea();
bText.setEditable(false);
bText.setText("Nothing right now.");

//add text to scroll pane
Scroll.add(bText);



//add scroll pane to ct panel
ctPanel.add(Scroll, BorderLayout.CENTER);




//add ct panel to RP
ctPanel.add(bText); // IF I COMMENT THIS OUT, THE TEXT WON'T APPEAR IN THE
CONTENT PANEL
this.add(ctPanel, BorderLayout.CENTER);

// start of navigation panel:

nPanel = new JPanel();
this.add(nPanel, BorderLayout.SOUTH);
nPanel.setBorder(BorderFactory.createTitledBorder(simpleBorder,"Navigation")
);

upButton = new JButton();
upButton.setText("Up");
nPanel.add(upButton, BorderLayout.WEST);

downButton = new JButton();
downButton.setText("Down");
nPanel.add(downButton, BorderLayout.EAST);

// revalidate and repaint:
this.revalidate();
this.repaint();
}


// method to set text in bText JTextField from another class
public void setBText(String text)
{
bText.setText(text);
}

// method to set T info to i panel from another class
public void setTInfo(String text)
{
T.setText("T: " + text);
}

// method to set A info to i panel from another class
public void setAInfo(String text)
{
A.setText("B " + text);
}

}









share|improve this question
















I'm writing a program that's supposed to print text. I need it to be on a JScrollPane and I also need to be able to go to the next page of text by clicking on a next page button.



The only way I can get any text to show up is by adding the text directly to the pane. (line 91 ctPanel.add(bText);)



public class RP extends JPanel{

private Border simpleBorder;
private JPanel iPanel;
private JPanel ctPanel;
private JPanel nPanel;
private JLabel T;
private JLabel A;
private JLabel P;
private JButton upButton;
private JButton downButton;
public JTextArea bText;
private JScrollPane Scroll;
private String placeholder;

public RP()
{

this.setPreferredSize(new Dimension(720,700));

simpleBorder = BorderFactory.createLineBorder(Color.GRAY);
//this.setBorder(BorderFactory.createTitledBorder(simpleBorder, "R"));
this.setLayout(new BorderLayout());

// start of i panel:

placeholder = new String("nothing right now");

iPanel = new JPanel();
this.add(iPanel, BorderLayout.NORTH);
iPanel.setBorder(BorderFactory.createTitledBorder(simpleBorder, "I"));

T = new JLabel();
T.setText("T: " + placeholder);
iPanel.add(T, BorderLayout.WEST);

A = new JLabel();
A.setText("B: " + placeholder);
iPanel.add(A, BorderLayout.CENTER);

P = new JLabel();
P.setText("P: " + placeholder);
iPanel.add(P, BorderLayout.EAST);


// start of ct panel (RP -> Ct Panel):

ctPanel = new JPanel();
ctPanel.setBorder(BorderFactory.createTitledBorder(simpleBorder, "C"));
ctPanel.setLayout(new BorderLayout());



// Create JScrollPane and add it to Ct Panel
Scroll = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);



// create btext area
bText = new JTextArea();
bText.setEditable(false);
bText.setText("Nothing right now.");

//add text to scroll pane
Scroll.add(bText);



//add scroll pane to ct panel
ctPanel.add(Scroll, BorderLayout.CENTER);




//add ct panel to RP
ctPanel.add(bText); // IF I COMMENT THIS OUT, THE TEXT WON'T APPEAR IN THE
CONTENT PANEL
this.add(ctPanel, BorderLayout.CENTER);

// start of navigation panel:

nPanel = new JPanel();
this.add(nPanel, BorderLayout.SOUTH);
nPanel.setBorder(BorderFactory.createTitledBorder(simpleBorder,"Navigation")
);

upButton = new JButton();
upButton.setText("Up");
nPanel.add(upButton, BorderLayout.WEST);

downButton = new JButton();
downButton.setText("Down");
nPanel.add(downButton, BorderLayout.EAST);

// revalidate and repaint:
this.revalidate();
this.repaint();
}


// method to set text in bText JTextField from another class
public void setBText(String text)
{
bText.setText(text);
}

// method to set T info to i panel from another class
public void setTInfo(String text)
{
T.setText("T: " + text);
}

// method to set A info to i panel from another class
public void setAInfo(String text)
{
A.setText("B " + text);
}

}






java swing jscrollpane jtextarea






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 21 '18 at 1:08









Andrew Thompson

153k27163341




153k27163341










asked Nov 21 '18 at 0:32









J.S.M.J.S.M.

214




214













  • "Any help is appreciated.." What is the question? General tips: 1) For better help sooner, edit to add a Minimal, Complete, and Verifiable example or Short, Self Contained, Correct Example. 2) Use a logical and consistent form of indenting code lines and blocks. The indentation is intended to make the flow of the code easier to follow! 3) A single blank line of white space in source code is all that is ever needed. Blank lines after { or before } are also typically redundant. 4) bText = new JTextArea(); should be more like bText = new JTextArea(20,4); // suggest a size ..

    – Andrew Thompson
    Nov 21 '18 at 1:11











  • 5) this.setPreferredSize(new Dimension(720,700)); This is just a guess. Remove it and instead pack() the top level window once all components are added. The panel will end up the smallest size it needs to be in order to display the components it contains (and their borders and padding as coded). 6) Please learn common Java nomenclature (naming conventions - e.g. EachWordUpperCaseClass, firstWordLowerCaseMethod(), firstWordLowerCaseAttribute unless it is an UPPER_CASE_CONSTANT) and use it consistently.

    – Andrew Thompson
    Nov 21 '18 at 1:12













  • @AndrewThompson thank you! This was my first post, so I felt pretty unsure about how to do it properly. My main problem was that I couldn't get bText to show up on the JScrollPane. The suggestion from camickr to use the .setViewportView did the trick.

    – J.S.M.
    Nov 21 '18 at 3:06



















  • "Any help is appreciated.." What is the question? General tips: 1) For better help sooner, edit to add a Minimal, Complete, and Verifiable example or Short, Self Contained, Correct Example. 2) Use a logical and consistent form of indenting code lines and blocks. The indentation is intended to make the flow of the code easier to follow! 3) A single blank line of white space in source code is all that is ever needed. Blank lines after { or before } are also typically redundant. 4) bText = new JTextArea(); should be more like bText = new JTextArea(20,4); // suggest a size ..

    – Andrew Thompson
    Nov 21 '18 at 1:11











  • 5) this.setPreferredSize(new Dimension(720,700)); This is just a guess. Remove it and instead pack() the top level window once all components are added. The panel will end up the smallest size it needs to be in order to display the components it contains (and their borders and padding as coded). 6) Please learn common Java nomenclature (naming conventions - e.g. EachWordUpperCaseClass, firstWordLowerCaseMethod(), firstWordLowerCaseAttribute unless it is an UPPER_CASE_CONSTANT) and use it consistently.

    – Andrew Thompson
    Nov 21 '18 at 1:12













  • @AndrewThompson thank you! This was my first post, so I felt pretty unsure about how to do it properly. My main problem was that I couldn't get bText to show up on the JScrollPane. The suggestion from camickr to use the .setViewportView did the trick.

    – J.S.M.
    Nov 21 '18 at 3:06

















"Any help is appreciated.." What is the question? General tips: 1) For better help sooner, edit to add a Minimal, Complete, and Verifiable example or Short, Self Contained, Correct Example. 2) Use a logical and consistent form of indenting code lines and blocks. The indentation is intended to make the flow of the code easier to follow! 3) A single blank line of white space in source code is all that is ever needed. Blank lines after { or before } are also typically redundant. 4) bText = new JTextArea(); should be more like bText = new JTextArea(20,4); // suggest a size ..

– Andrew Thompson
Nov 21 '18 at 1:11





"Any help is appreciated.." What is the question? General tips: 1) For better help sooner, edit to add a Minimal, Complete, and Verifiable example or Short, Self Contained, Correct Example. 2) Use a logical and consistent form of indenting code lines and blocks. The indentation is intended to make the flow of the code easier to follow! 3) A single blank line of white space in source code is all that is ever needed. Blank lines after { or before } are also typically redundant. 4) bText = new JTextArea(); should be more like bText = new JTextArea(20,4); // suggest a size ..

– Andrew Thompson
Nov 21 '18 at 1:11













5) this.setPreferredSize(new Dimension(720,700)); This is just a guess. Remove it and instead pack() the top level window once all components are added. The panel will end up the smallest size it needs to be in order to display the components it contains (and their borders and padding as coded). 6) Please learn common Java nomenclature (naming conventions - e.g. EachWordUpperCaseClass, firstWordLowerCaseMethod(), firstWordLowerCaseAttribute unless it is an UPPER_CASE_CONSTANT) and use it consistently.

– Andrew Thompson
Nov 21 '18 at 1:12







5) this.setPreferredSize(new Dimension(720,700)); This is just a guess. Remove it and instead pack() the top level window once all components are added. The panel will end up the smallest size it needs to be in order to display the components it contains (and their borders and padding as coded). 6) Please learn common Java nomenclature (naming conventions - e.g. EachWordUpperCaseClass, firstWordLowerCaseMethod(), firstWordLowerCaseAttribute unless it is an UPPER_CASE_CONSTANT) and use it consistently.

– Andrew Thompson
Nov 21 '18 at 1:12















@AndrewThompson thank you! This was my first post, so I felt pretty unsure about how to do it properly. My main problem was that I couldn't get bText to show up on the JScrollPane. The suggestion from camickr to use the .setViewportView did the trick.

– J.S.M.
Nov 21 '18 at 3:06





@AndrewThompson thank you! This was my first post, so I felt pretty unsure about how to do it properly. My main problem was that I couldn't get bText to show up on the JScrollPane. The suggestion from camickr to use the .setViewportView did the trick.

– J.S.M.
Nov 21 '18 at 3:06












1 Answer
1






active

oldest

votes


















0














First of all variable names should NOT start with an upper case character.



Scroll.add(bText);


Don't add components to the scroll pane directly. Components are added to the viewport of the scroll pane using;



//Scroll.add(bText);
scroll.setViewportView( bText );


Also a component can only be added to a single component. So get rid of:



//ctPanel.add(bText);


since you already added the text area to the viewport of the scroll pane.






share|improve this answer
























  • Thank you! Using scroll.setViewportView(bText) fixed it.

    – J.S.M.
    Nov 21 '18 at 3:07











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53403671%2fjtextarea-on-jscrollpane-not-appearing-on-jpanel%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














First of all variable names should NOT start with an upper case character.



Scroll.add(bText);


Don't add components to the scroll pane directly. Components are added to the viewport of the scroll pane using;



//Scroll.add(bText);
scroll.setViewportView( bText );


Also a component can only be added to a single component. So get rid of:



//ctPanel.add(bText);


since you already added the text area to the viewport of the scroll pane.






share|improve this answer
























  • Thank you! Using scroll.setViewportView(bText) fixed it.

    – J.S.M.
    Nov 21 '18 at 3:07
















0














First of all variable names should NOT start with an upper case character.



Scroll.add(bText);


Don't add components to the scroll pane directly. Components are added to the viewport of the scroll pane using;



//Scroll.add(bText);
scroll.setViewportView( bText );


Also a component can only be added to a single component. So get rid of:



//ctPanel.add(bText);


since you already added the text area to the viewport of the scroll pane.






share|improve this answer
























  • Thank you! Using scroll.setViewportView(bText) fixed it.

    – J.S.M.
    Nov 21 '18 at 3:07














0












0








0







First of all variable names should NOT start with an upper case character.



Scroll.add(bText);


Don't add components to the scroll pane directly. Components are added to the viewport of the scroll pane using;



//Scroll.add(bText);
scroll.setViewportView( bText );


Also a component can only be added to a single component. So get rid of:



//ctPanel.add(bText);


since you already added the text area to the viewport of the scroll pane.






share|improve this answer













First of all variable names should NOT start with an upper case character.



Scroll.add(bText);


Don't add components to the scroll pane directly. Components are added to the viewport of the scroll pane using;



//Scroll.add(bText);
scroll.setViewportView( bText );


Also a component can only be added to a single component. So get rid of:



//ctPanel.add(bText);


since you already added the text area to the viewport of the scroll pane.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 21 '18 at 0:36









camickrcamickr

275k15127239




275k15127239













  • Thank you! Using scroll.setViewportView(bText) fixed it.

    – J.S.M.
    Nov 21 '18 at 3:07



















  • Thank you! Using scroll.setViewportView(bText) fixed it.

    – J.S.M.
    Nov 21 '18 at 3:07

















Thank you! Using scroll.setViewportView(bText) fixed it.

– J.S.M.
Nov 21 '18 at 3:07





Thank you! Using scroll.setViewportView(bText) fixed it.

– J.S.M.
Nov 21 '18 at 3:07


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53403671%2fjtextarea-on-jscrollpane-not-appearing-on-jpanel%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Can a sorcerer learn a 5th-level spell early by creating spell slots using the Font of Magic feature?

Does disintegrating a polymorphed enemy still kill it after the 2018 errata?

A Topological Invariant for $pi_3(U(n))$