I've added JPanel to JFrame and it still isn't showing
So this question has been asked a lot, but I've searched through several of them and it seems that everyone is forgetting to add the panel to the frame. I have added the panel to my frame, but I still am not seeing my JPanel.
public class AddSomethingFrame extends JFrame{
private JFrame application;
JPanel viewPanel = new JPanel();
public AddSomethingFrame(JFrame application) {
super("Add");
this.application = application;
setDefaultCloseOperation(EXIT_ON_CLOSE);
setPreferredSize(new Dimension(300, 200));
placeComponents(viewPanel);
viewPanel.setBorder(new EmptyBorder(13, 25, 13, 25));
setLayout(new FlowLayout());
setLocationRelativeTo(null);
setResizable(true);
pack();
setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
this.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
application.setVisible(true);
setVisible(false);
dispose();
}
});
setVisible(true);
}
private void placeComponents (JPanel panel) {
panel.setLayout(null);
JLabel nameLabel = new JLabel("Name");
nameLabel.setBounds(10, 10, 80, 25);
panel.add(nameLabel);
JTextField nameText = new JTextField(20);
nameText.setBounds(100, 10, 160, 25);
panel.add(nameText);
JLabel brandLabel = new JLabel("Brand");
brandLabel.setBounds(10, 40, 80, 25);
panel.add(brandLabel);
JTextField brandText = new JTextField(20);
brandText.setBounds(100, 40, 160, 25);
panel.add(brandText);
JLabel costLabel = new JLabel("Cost");
costLabel.setBounds(10, 10, 80, 25);
panel.add(costLabel);
JTextField costText = new JTextField(20);
costText.setBounds(100, 10, 160, 25);
panel.add(costText);
JButton storeGearButton = new JButton("Store");
storeGearButton.setBounds(10, 80, 80, 25);
panel.add(storeGearButton);
this.add(viewPanel, BorderLayout.NORTH);
}
}
I've tried moving around the setVisible for the JFrame and the JPanel. I've tried changing the sizes of each and I tried changing the BorderLayout of the panel, but nothing is working. Please help.
java swing jframe jpanel
add a comment |
So this question has been asked a lot, but I've searched through several of them and it seems that everyone is forgetting to add the panel to the frame. I have added the panel to my frame, but I still am not seeing my JPanel.
public class AddSomethingFrame extends JFrame{
private JFrame application;
JPanel viewPanel = new JPanel();
public AddSomethingFrame(JFrame application) {
super("Add");
this.application = application;
setDefaultCloseOperation(EXIT_ON_CLOSE);
setPreferredSize(new Dimension(300, 200));
placeComponents(viewPanel);
viewPanel.setBorder(new EmptyBorder(13, 25, 13, 25));
setLayout(new FlowLayout());
setLocationRelativeTo(null);
setResizable(true);
pack();
setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
this.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
application.setVisible(true);
setVisible(false);
dispose();
}
});
setVisible(true);
}
private void placeComponents (JPanel panel) {
panel.setLayout(null);
JLabel nameLabel = new JLabel("Name");
nameLabel.setBounds(10, 10, 80, 25);
panel.add(nameLabel);
JTextField nameText = new JTextField(20);
nameText.setBounds(100, 10, 160, 25);
panel.add(nameText);
JLabel brandLabel = new JLabel("Brand");
brandLabel.setBounds(10, 40, 80, 25);
panel.add(brandLabel);
JTextField brandText = new JTextField(20);
brandText.setBounds(100, 40, 160, 25);
panel.add(brandText);
JLabel costLabel = new JLabel("Cost");
costLabel.setBounds(10, 10, 80, 25);
panel.add(costLabel);
JTextField costText = new JTextField(20);
costText.setBounds(100, 10, 160, 25);
panel.add(costText);
JButton storeGearButton = new JButton("Store");
storeGearButton.setBounds(10, 80, 80, 25);
panel.add(storeGearButton);
this.add(viewPanel, BorderLayout.NORTH);
}
}
I've tried moving around the setVisible for the JFrame and the JPanel. I've tried changing the sizes of each and I tried changing the BorderLayout of the panel, but nothing is working. Please help.
java swing jframe jpanel
1
We often tell folks here thatpanel.setLayout(null)
is dangerous code, but unfortunately not enough listen. Please be the exception and listen and believe. Understand also what this does to your JPanel's preferred size
– Hovercraft Full Of Eels
Nov 25 '18 at 19:47
1
Also where do you ask the panel to the gui?? Your main problem appears to be this, a somewhat careless error. You're adding the viewpanel but not the panel.
– Hovercraft Full Of Eels
Nov 25 '18 at 19:48
add a comment |
So this question has been asked a lot, but I've searched through several of them and it seems that everyone is forgetting to add the panel to the frame. I have added the panel to my frame, but I still am not seeing my JPanel.
public class AddSomethingFrame extends JFrame{
private JFrame application;
JPanel viewPanel = new JPanel();
public AddSomethingFrame(JFrame application) {
super("Add");
this.application = application;
setDefaultCloseOperation(EXIT_ON_CLOSE);
setPreferredSize(new Dimension(300, 200));
placeComponents(viewPanel);
viewPanel.setBorder(new EmptyBorder(13, 25, 13, 25));
setLayout(new FlowLayout());
setLocationRelativeTo(null);
setResizable(true);
pack();
setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
this.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
application.setVisible(true);
setVisible(false);
dispose();
}
});
setVisible(true);
}
private void placeComponents (JPanel panel) {
panel.setLayout(null);
JLabel nameLabel = new JLabel("Name");
nameLabel.setBounds(10, 10, 80, 25);
panel.add(nameLabel);
JTextField nameText = new JTextField(20);
nameText.setBounds(100, 10, 160, 25);
panel.add(nameText);
JLabel brandLabel = new JLabel("Brand");
brandLabel.setBounds(10, 40, 80, 25);
panel.add(brandLabel);
JTextField brandText = new JTextField(20);
brandText.setBounds(100, 40, 160, 25);
panel.add(brandText);
JLabel costLabel = new JLabel("Cost");
costLabel.setBounds(10, 10, 80, 25);
panel.add(costLabel);
JTextField costText = new JTextField(20);
costText.setBounds(100, 10, 160, 25);
panel.add(costText);
JButton storeGearButton = new JButton("Store");
storeGearButton.setBounds(10, 80, 80, 25);
panel.add(storeGearButton);
this.add(viewPanel, BorderLayout.NORTH);
}
}
I've tried moving around the setVisible for the JFrame and the JPanel. I've tried changing the sizes of each and I tried changing the BorderLayout of the panel, but nothing is working. Please help.
java swing jframe jpanel
So this question has been asked a lot, but I've searched through several of them and it seems that everyone is forgetting to add the panel to the frame. I have added the panel to my frame, but I still am not seeing my JPanel.
public class AddSomethingFrame extends JFrame{
private JFrame application;
JPanel viewPanel = new JPanel();
public AddSomethingFrame(JFrame application) {
super("Add");
this.application = application;
setDefaultCloseOperation(EXIT_ON_CLOSE);
setPreferredSize(new Dimension(300, 200));
placeComponents(viewPanel);
viewPanel.setBorder(new EmptyBorder(13, 25, 13, 25));
setLayout(new FlowLayout());
setLocationRelativeTo(null);
setResizable(true);
pack();
setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
this.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
application.setVisible(true);
setVisible(false);
dispose();
}
});
setVisible(true);
}
private void placeComponents (JPanel panel) {
panel.setLayout(null);
JLabel nameLabel = new JLabel("Name");
nameLabel.setBounds(10, 10, 80, 25);
panel.add(nameLabel);
JTextField nameText = new JTextField(20);
nameText.setBounds(100, 10, 160, 25);
panel.add(nameText);
JLabel brandLabel = new JLabel("Brand");
brandLabel.setBounds(10, 40, 80, 25);
panel.add(brandLabel);
JTextField brandText = new JTextField(20);
brandText.setBounds(100, 40, 160, 25);
panel.add(brandText);
JLabel costLabel = new JLabel("Cost");
costLabel.setBounds(10, 10, 80, 25);
panel.add(costLabel);
JTextField costText = new JTextField(20);
costText.setBounds(100, 10, 160, 25);
panel.add(costText);
JButton storeGearButton = new JButton("Store");
storeGearButton.setBounds(10, 80, 80, 25);
panel.add(storeGearButton);
this.add(viewPanel, BorderLayout.NORTH);
}
}
I've tried moving around the setVisible for the JFrame and the JPanel. I've tried changing the sizes of each and I tried changing the BorderLayout of the panel, but nothing is working. Please help.
java swing jframe jpanel
java swing jframe jpanel
edited Nov 26 '18 at 15:55
Ace of Spade
10413
10413
asked Nov 25 '18 at 19:32
B. MarsB. Mars
4
4
1
We often tell folks here thatpanel.setLayout(null)
is dangerous code, but unfortunately not enough listen. Please be the exception and listen and believe. Understand also what this does to your JPanel's preferred size
– Hovercraft Full Of Eels
Nov 25 '18 at 19:47
1
Also where do you ask the panel to the gui?? Your main problem appears to be this, a somewhat careless error. You're adding the viewpanel but not the panel.
– Hovercraft Full Of Eels
Nov 25 '18 at 19:48
add a comment |
1
We often tell folks here thatpanel.setLayout(null)
is dangerous code, but unfortunately not enough listen. Please be the exception and listen and believe. Understand also what this does to your JPanel's preferred size
– Hovercraft Full Of Eels
Nov 25 '18 at 19:47
1
Also where do you ask the panel to the gui?? Your main problem appears to be this, a somewhat careless error. You're adding the viewpanel but not the panel.
– Hovercraft Full Of Eels
Nov 25 '18 at 19:48
1
1
We often tell folks here that
panel.setLayout(null)
is dangerous code, but unfortunately not enough listen. Please be the exception and listen and believe. Understand also what this does to your JPanel's preferred size– Hovercraft Full Of Eels
Nov 25 '18 at 19:47
We often tell folks here that
panel.setLayout(null)
is dangerous code, but unfortunately not enough listen. Please be the exception and listen and believe. Understand also what this does to your JPanel's preferred size– Hovercraft Full Of Eels
Nov 25 '18 at 19:47
1
1
Also where do you ask the panel to the gui?? Your main problem appears to be this, a somewhat careless error. You're adding the viewpanel but not the panel.
– Hovercraft Full Of Eels
Nov 25 '18 at 19:48
Also where do you ask the panel to the gui?? Your main problem appears to be this, a somewhat careless error. You're adding the viewpanel but not the panel.
– Hovercraft Full Of Eels
Nov 25 '18 at 19:48
add a comment |
1 Answer
1
active
oldest
votes
I suggest you to avoid a "placeComponents(viewPanel)" construction and directly add the "JPanle panel" elements to your JFrame that will make your code easier. Somthing like that:
public class AddSomethingFrame extends JFrame{
static JFrame application;
//JPanel viewPanel = new JPanel();
public AddSomethingFrame(JFrame application) {
super("Add");
// this.application = application;
setBounds(300, 200, 1000, 200);
setDefaultCloseOperation(EXIT_ON_CLOSE);
// placeComponents(viewPanel);
// viewPanel.setBorder(new EmptyBorder(10, 25, 2, 25));
// setLayout(new FlowLayout());
// setLocationRelativeTo(null);
// setResizable(true);
// pack();
// setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
// this.addWindowListener(new WindowAdapter() {
// public void windowClosing(WindowEvent e) {
// application.setVisible(true);
// setVisible(false);
// dispose();
// }
// });
// setVisible(true);
//}
//
// private void placeComponents (JPanel panel) {
JPanel panel = new JPanel();
// panel.setLayout(null);
JLabel nameLabel = new JLabel("Name");
nameLabel.setBounds(10, 10, 80, 25);
panel.add(nameLabel);
JTextField nameText = new JTextField(20);
nameText.setBounds(100, 10, 160, 25);
panel.add(nameText);
JLabel brandLabel = new JLabel("Brand");
brandLabel.setBounds(10, 40, 80, 25);
panel.add(brandLabel);
JTextField brandText = new JTextField(20);
brandText.setBounds(100, 40, 160, 25);
panel.add(brandText);
JLabel costLabel = new JLabel("Cost");
costLabel.setBounds(10, 10, 80, 25);
panel.add(costLabel);
JTextField costText = new JTextField(20);
costText.setBounds(100, 10, 160, 25);
panel.add(costText);
JButton storeGearButton = new JButton("Store");
storeGearButton.setBounds(10, 80, 80, 25);
panel.add(storeGearButton);
this.add(panel, BorderLayout.NORTH);
}
public static void main(String args) {
AddSomethingFrame app= new AddSomethingFrame(application);
app.setVisible(true);
}
}
AddSomethingFrame
is a JFrame. No need to pass it a reference to one. Removeapplication
.
– c0der
Nov 26 '18 at 5:54
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53471107%2five-added-jpanel-to-jframe-and-it-still-isnt-showing%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
I suggest you to avoid a "placeComponents(viewPanel)" construction and directly add the "JPanle panel" elements to your JFrame that will make your code easier. Somthing like that:
public class AddSomethingFrame extends JFrame{
static JFrame application;
//JPanel viewPanel = new JPanel();
public AddSomethingFrame(JFrame application) {
super("Add");
// this.application = application;
setBounds(300, 200, 1000, 200);
setDefaultCloseOperation(EXIT_ON_CLOSE);
// placeComponents(viewPanel);
// viewPanel.setBorder(new EmptyBorder(10, 25, 2, 25));
// setLayout(new FlowLayout());
// setLocationRelativeTo(null);
// setResizable(true);
// pack();
// setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
// this.addWindowListener(new WindowAdapter() {
// public void windowClosing(WindowEvent e) {
// application.setVisible(true);
// setVisible(false);
// dispose();
// }
// });
// setVisible(true);
//}
//
// private void placeComponents (JPanel panel) {
JPanel panel = new JPanel();
// panel.setLayout(null);
JLabel nameLabel = new JLabel("Name");
nameLabel.setBounds(10, 10, 80, 25);
panel.add(nameLabel);
JTextField nameText = new JTextField(20);
nameText.setBounds(100, 10, 160, 25);
panel.add(nameText);
JLabel brandLabel = new JLabel("Brand");
brandLabel.setBounds(10, 40, 80, 25);
panel.add(brandLabel);
JTextField brandText = new JTextField(20);
brandText.setBounds(100, 40, 160, 25);
panel.add(brandText);
JLabel costLabel = new JLabel("Cost");
costLabel.setBounds(10, 10, 80, 25);
panel.add(costLabel);
JTextField costText = new JTextField(20);
costText.setBounds(100, 10, 160, 25);
panel.add(costText);
JButton storeGearButton = new JButton("Store");
storeGearButton.setBounds(10, 80, 80, 25);
panel.add(storeGearButton);
this.add(panel, BorderLayout.NORTH);
}
public static void main(String args) {
AddSomethingFrame app= new AddSomethingFrame(application);
app.setVisible(true);
}
}
AddSomethingFrame
is a JFrame. No need to pass it a reference to one. Removeapplication
.
– c0der
Nov 26 '18 at 5:54
add a comment |
I suggest you to avoid a "placeComponents(viewPanel)" construction and directly add the "JPanle panel" elements to your JFrame that will make your code easier. Somthing like that:
public class AddSomethingFrame extends JFrame{
static JFrame application;
//JPanel viewPanel = new JPanel();
public AddSomethingFrame(JFrame application) {
super("Add");
// this.application = application;
setBounds(300, 200, 1000, 200);
setDefaultCloseOperation(EXIT_ON_CLOSE);
// placeComponents(viewPanel);
// viewPanel.setBorder(new EmptyBorder(10, 25, 2, 25));
// setLayout(new FlowLayout());
// setLocationRelativeTo(null);
// setResizable(true);
// pack();
// setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
// this.addWindowListener(new WindowAdapter() {
// public void windowClosing(WindowEvent e) {
// application.setVisible(true);
// setVisible(false);
// dispose();
// }
// });
// setVisible(true);
//}
//
// private void placeComponents (JPanel panel) {
JPanel panel = new JPanel();
// panel.setLayout(null);
JLabel nameLabel = new JLabel("Name");
nameLabel.setBounds(10, 10, 80, 25);
panel.add(nameLabel);
JTextField nameText = new JTextField(20);
nameText.setBounds(100, 10, 160, 25);
panel.add(nameText);
JLabel brandLabel = new JLabel("Brand");
brandLabel.setBounds(10, 40, 80, 25);
panel.add(brandLabel);
JTextField brandText = new JTextField(20);
brandText.setBounds(100, 40, 160, 25);
panel.add(brandText);
JLabel costLabel = new JLabel("Cost");
costLabel.setBounds(10, 10, 80, 25);
panel.add(costLabel);
JTextField costText = new JTextField(20);
costText.setBounds(100, 10, 160, 25);
panel.add(costText);
JButton storeGearButton = new JButton("Store");
storeGearButton.setBounds(10, 80, 80, 25);
panel.add(storeGearButton);
this.add(panel, BorderLayout.NORTH);
}
public static void main(String args) {
AddSomethingFrame app= new AddSomethingFrame(application);
app.setVisible(true);
}
}
AddSomethingFrame
is a JFrame. No need to pass it a reference to one. Removeapplication
.
– c0der
Nov 26 '18 at 5:54
add a comment |
I suggest you to avoid a "placeComponents(viewPanel)" construction and directly add the "JPanle panel" elements to your JFrame that will make your code easier. Somthing like that:
public class AddSomethingFrame extends JFrame{
static JFrame application;
//JPanel viewPanel = new JPanel();
public AddSomethingFrame(JFrame application) {
super("Add");
// this.application = application;
setBounds(300, 200, 1000, 200);
setDefaultCloseOperation(EXIT_ON_CLOSE);
// placeComponents(viewPanel);
// viewPanel.setBorder(new EmptyBorder(10, 25, 2, 25));
// setLayout(new FlowLayout());
// setLocationRelativeTo(null);
// setResizable(true);
// pack();
// setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
// this.addWindowListener(new WindowAdapter() {
// public void windowClosing(WindowEvent e) {
// application.setVisible(true);
// setVisible(false);
// dispose();
// }
// });
// setVisible(true);
//}
//
// private void placeComponents (JPanel panel) {
JPanel panel = new JPanel();
// panel.setLayout(null);
JLabel nameLabel = new JLabel("Name");
nameLabel.setBounds(10, 10, 80, 25);
panel.add(nameLabel);
JTextField nameText = new JTextField(20);
nameText.setBounds(100, 10, 160, 25);
panel.add(nameText);
JLabel brandLabel = new JLabel("Brand");
brandLabel.setBounds(10, 40, 80, 25);
panel.add(brandLabel);
JTextField brandText = new JTextField(20);
brandText.setBounds(100, 40, 160, 25);
panel.add(brandText);
JLabel costLabel = new JLabel("Cost");
costLabel.setBounds(10, 10, 80, 25);
panel.add(costLabel);
JTextField costText = new JTextField(20);
costText.setBounds(100, 10, 160, 25);
panel.add(costText);
JButton storeGearButton = new JButton("Store");
storeGearButton.setBounds(10, 80, 80, 25);
panel.add(storeGearButton);
this.add(panel, BorderLayout.NORTH);
}
public static void main(String args) {
AddSomethingFrame app= new AddSomethingFrame(application);
app.setVisible(true);
}
}
I suggest you to avoid a "placeComponents(viewPanel)" construction and directly add the "JPanle panel" elements to your JFrame that will make your code easier. Somthing like that:
public class AddSomethingFrame extends JFrame{
static JFrame application;
//JPanel viewPanel = new JPanel();
public AddSomethingFrame(JFrame application) {
super("Add");
// this.application = application;
setBounds(300, 200, 1000, 200);
setDefaultCloseOperation(EXIT_ON_CLOSE);
// placeComponents(viewPanel);
// viewPanel.setBorder(new EmptyBorder(10, 25, 2, 25));
// setLayout(new FlowLayout());
// setLocationRelativeTo(null);
// setResizable(true);
// pack();
// setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
// this.addWindowListener(new WindowAdapter() {
// public void windowClosing(WindowEvent e) {
// application.setVisible(true);
// setVisible(false);
// dispose();
// }
// });
// setVisible(true);
//}
//
// private void placeComponents (JPanel panel) {
JPanel panel = new JPanel();
// panel.setLayout(null);
JLabel nameLabel = new JLabel("Name");
nameLabel.setBounds(10, 10, 80, 25);
panel.add(nameLabel);
JTextField nameText = new JTextField(20);
nameText.setBounds(100, 10, 160, 25);
panel.add(nameText);
JLabel brandLabel = new JLabel("Brand");
brandLabel.setBounds(10, 40, 80, 25);
panel.add(brandLabel);
JTextField brandText = new JTextField(20);
brandText.setBounds(100, 40, 160, 25);
panel.add(brandText);
JLabel costLabel = new JLabel("Cost");
costLabel.setBounds(10, 10, 80, 25);
panel.add(costLabel);
JTextField costText = new JTextField(20);
costText.setBounds(100, 10, 160, 25);
panel.add(costText);
JButton storeGearButton = new JButton("Store");
storeGearButton.setBounds(10, 80, 80, 25);
panel.add(storeGearButton);
this.add(panel, BorderLayout.NORTH);
}
public static void main(String args) {
AddSomethingFrame app= new AddSomethingFrame(application);
app.setVisible(true);
}
}
answered Nov 25 '18 at 23:14
Sergei VoychukSergei Voychuk
14627
14627
AddSomethingFrame
is a JFrame. No need to pass it a reference to one. Removeapplication
.
– c0der
Nov 26 '18 at 5:54
add a comment |
AddSomethingFrame
is a JFrame. No need to pass it a reference to one. Removeapplication
.
– c0der
Nov 26 '18 at 5:54
AddSomethingFrame
is a JFrame. No need to pass it a reference to one. Remove application
.– c0der
Nov 26 '18 at 5:54
AddSomethingFrame
is a JFrame. No need to pass it a reference to one. Remove application
.– c0der
Nov 26 '18 at 5:54
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53471107%2five-added-jpanel-to-jframe-and-it-still-isnt-showing%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
1
We often tell folks here that
panel.setLayout(null)
is dangerous code, but unfortunately not enough listen. Please be the exception and listen and believe. Understand also what this does to your JPanel's preferred size– Hovercraft Full Of Eels
Nov 25 '18 at 19:47
1
Also where do you ask the panel to the gui?? Your main problem appears to be this, a somewhat careless error. You're adding the viewpanel but not the panel.
– Hovercraft Full Of Eels
Nov 25 '18 at 19:48