Typed the code but it is not showing the GUI components
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
I am trying to create a small application using Java Swing concept. But facing some issues.
Here is my code:
import javax.swing.*;
import java.awt.*;
@SuppressWarnings("serial")
public class FirstFrame extends JFrame {
JLabel l1,l2,l3,l4;
JButton student,staff,trainer,admin;
JPanel p;
//Button b;
public FirstFrame() {
setTitle("SPARK-DB");
setSize(1500,1000);
setLayout(null);
setVisible(true);
p = new JPanel();
p.setSize(1500,1000);
p.setLayout(null);
add(p);
l1 = new JLabel("WELCOME TO SPARK DB");
//jLabel1.setFont(new Font("Serif", Font.BOLD, 12));
l1.setFont(new Font("Serif",Font.BOLD,30));
l1.setBounds(700, 950, 400, 40);
p.add(l1);
l2 = new JLabel("CREATED BY : ANUP TIWARY AND MEHUL DUBEY");
l2.setBounds(600, 900, 500, 30);
p.add(l2);
l3 = new JLabel("SELECT LOGIN TYPE");
l3.setBounds(700,800, 400, 50);
p.add(l3);
}
}
The above code does not show the labels created. I am not able to figure out what is missing here.
java swing
add a comment |
I am trying to create a small application using Java Swing concept. But facing some issues.
Here is my code:
import javax.swing.*;
import java.awt.*;
@SuppressWarnings("serial")
public class FirstFrame extends JFrame {
JLabel l1,l2,l3,l4;
JButton student,staff,trainer,admin;
JPanel p;
//Button b;
public FirstFrame() {
setTitle("SPARK-DB");
setSize(1500,1000);
setLayout(null);
setVisible(true);
p = new JPanel();
p.setSize(1500,1000);
p.setLayout(null);
add(p);
l1 = new JLabel("WELCOME TO SPARK DB");
//jLabel1.setFont(new Font("Serif", Font.BOLD, 12));
l1.setFont(new Font("Serif",Font.BOLD,30));
l1.setBounds(700, 950, 400, 40);
p.add(l1);
l2 = new JLabel("CREATED BY : ANUP TIWARY AND MEHUL DUBEY");
l2.setBounds(600, 900, 500, 30);
p.add(l2);
l3 = new JLabel("SELECT LOGIN TYPE");
l3.setBounds(700,800, 400, 50);
p.add(l3);
}
}
The above code does not show the labels created. I am not able to figure out what is missing here.
java swing
2
1) Only set the GUI visible once the components have been added. Special measures are required to make components visible if added after that. 2) Java GUIs have to work on different OS', screen size, screen resolution etc. using different PLAFs in different locales. As such, they are not conducive to pixel perfect layout. Instead use layout managers, or combinations of them along with layout padding and borders for white space.
– Andrew Thompson
Jan 3 at 6:33
1
Given the 4 extra buttons and the gaping space in the GUI (even once the last label has been shoved upwards into view), I'm guessing there was more to this GUI. I'll show you how to position them using layouts, but first need to know how the GUI is supposed to look. Provide ASCII art or a simple drawing of the intended layout of the GUI at minimum size, and if resizable, with more width and height - to show how the extra space should be used.
– Andrew Thompson
Jan 3 at 7:16
add a comment |
I am trying to create a small application using Java Swing concept. But facing some issues.
Here is my code:
import javax.swing.*;
import java.awt.*;
@SuppressWarnings("serial")
public class FirstFrame extends JFrame {
JLabel l1,l2,l3,l4;
JButton student,staff,trainer,admin;
JPanel p;
//Button b;
public FirstFrame() {
setTitle("SPARK-DB");
setSize(1500,1000);
setLayout(null);
setVisible(true);
p = new JPanel();
p.setSize(1500,1000);
p.setLayout(null);
add(p);
l1 = new JLabel("WELCOME TO SPARK DB");
//jLabel1.setFont(new Font("Serif", Font.BOLD, 12));
l1.setFont(new Font("Serif",Font.BOLD,30));
l1.setBounds(700, 950, 400, 40);
p.add(l1);
l2 = new JLabel("CREATED BY : ANUP TIWARY AND MEHUL DUBEY");
l2.setBounds(600, 900, 500, 30);
p.add(l2);
l3 = new JLabel("SELECT LOGIN TYPE");
l3.setBounds(700,800, 400, 50);
p.add(l3);
}
}
The above code does not show the labels created. I am not able to figure out what is missing here.
java swing
I am trying to create a small application using Java Swing concept. But facing some issues.
Here is my code:
import javax.swing.*;
import java.awt.*;
@SuppressWarnings("serial")
public class FirstFrame extends JFrame {
JLabel l1,l2,l3,l4;
JButton student,staff,trainer,admin;
JPanel p;
//Button b;
public FirstFrame() {
setTitle("SPARK-DB");
setSize(1500,1000);
setLayout(null);
setVisible(true);
p = new JPanel();
p.setSize(1500,1000);
p.setLayout(null);
add(p);
l1 = new JLabel("WELCOME TO SPARK DB");
//jLabel1.setFont(new Font("Serif", Font.BOLD, 12));
l1.setFont(new Font("Serif",Font.BOLD,30));
l1.setBounds(700, 950, 400, 40);
p.add(l1);
l2 = new JLabel("CREATED BY : ANUP TIWARY AND MEHUL DUBEY");
l2.setBounds(600, 900, 500, 30);
p.add(l2);
l3 = new JLabel("SELECT LOGIN TYPE");
l3.setBounds(700,800, 400, 50);
p.add(l3);
}
}
The above code does not show the labels created. I am not able to figure out what is missing here.
java swing
java swing
edited Jan 3 at 6:34


Andrew Thompson
154k29165349
154k29165349
asked Jan 3 at 6:14


Mehulkumar DubeyMehulkumar Dubey
1
1
2
1) Only set the GUI visible once the components have been added. Special measures are required to make components visible if added after that. 2) Java GUIs have to work on different OS', screen size, screen resolution etc. using different PLAFs in different locales. As such, they are not conducive to pixel perfect layout. Instead use layout managers, or combinations of them along with layout padding and borders for white space.
– Andrew Thompson
Jan 3 at 6:33
1
Given the 4 extra buttons and the gaping space in the GUI (even once the last label has been shoved upwards into view), I'm guessing there was more to this GUI. I'll show you how to position them using layouts, but first need to know how the GUI is supposed to look. Provide ASCII art or a simple drawing of the intended layout of the GUI at minimum size, and if resizable, with more width and height - to show how the extra space should be used.
– Andrew Thompson
Jan 3 at 7:16
add a comment |
2
1) Only set the GUI visible once the components have been added. Special measures are required to make components visible if added after that. 2) Java GUIs have to work on different OS', screen size, screen resolution etc. using different PLAFs in different locales. As such, they are not conducive to pixel perfect layout. Instead use layout managers, or combinations of them along with layout padding and borders for white space.
– Andrew Thompson
Jan 3 at 6:33
1
Given the 4 extra buttons and the gaping space in the GUI (even once the last label has been shoved upwards into view), I'm guessing there was more to this GUI. I'll show you how to position them using layouts, but first need to know how the GUI is supposed to look. Provide ASCII art or a simple drawing of the intended layout of the GUI at minimum size, and if resizable, with more width and height - to show how the extra space should be used.
– Andrew Thompson
Jan 3 at 7:16
2
2
1) Only set the GUI visible once the components have been added. Special measures are required to make components visible if added after that. 2) Java GUIs have to work on different OS', screen size, screen resolution etc. using different PLAFs in different locales. As such, they are not conducive to pixel perfect layout. Instead use layout managers, or combinations of them along with layout padding and borders for white space.
– Andrew Thompson
Jan 3 at 6:33
1) Only set the GUI visible once the components have been added. Special measures are required to make components visible if added after that. 2) Java GUIs have to work on different OS', screen size, screen resolution etc. using different PLAFs in different locales. As such, they are not conducive to pixel perfect layout. Instead use layout managers, or combinations of them along with layout padding and borders for white space.
– Andrew Thompson
Jan 3 at 6:33
1
1
Given the 4 extra buttons and the gaping space in the GUI (even once the last label has been shoved upwards into view), I'm guessing there was more to this GUI. I'll show you how to position them using layouts, but first need to know how the GUI is supposed to look. Provide ASCII art or a simple drawing of the intended layout of the GUI at minimum size, and if resizable, with more width and height - to show how the extra space should be used.
– Andrew Thompson
Jan 3 at 7:16
Given the 4 extra buttons and the gaping space in the GUI (even once the last label has been shoved upwards into view), I'm guessing there was more to this GUI. I'll show you how to position them using layouts, but first need to know how the GUI is supposed to look. Provide ASCII art or a simple drawing of the intended layout of the GUI at minimum size, and if resizable, with more width and height - to show how the extra space should be used.
– Andrew Thompson
Jan 3 at 7:16
add a comment |
1 Answer
1
active
oldest
votes
The y value is beyond the visible space of a typical monitor. To fix the issue you need to reduce your y coordinate, for example 950 to 95.
l1.setBounds(700, 950, 400, 40);
I assume this is just a test code though. null layout is not recommended and ideally you should use one of the available layout managers.
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%2f54017186%2ftyped-the-code-but-it-is-not-showing-the-gui-components%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
The y value is beyond the visible space of a typical monitor. To fix the issue you need to reduce your y coordinate, for example 950 to 95.
l1.setBounds(700, 950, 400, 40);
I assume this is just a test code though. null layout is not recommended and ideally you should use one of the available layout managers.
add a comment |
The y value is beyond the visible space of a typical monitor. To fix the issue you need to reduce your y coordinate, for example 950 to 95.
l1.setBounds(700, 950, 400, 40);
I assume this is just a test code though. null layout is not recommended and ideally you should use one of the available layout managers.
add a comment |
The y value is beyond the visible space of a typical monitor. To fix the issue you need to reduce your y coordinate, for example 950 to 95.
l1.setBounds(700, 950, 400, 40);
I assume this is just a test code though. null layout is not recommended and ideally you should use one of the available layout managers.
The y value is beyond the visible space of a typical monitor. To fix the issue you need to reduce your y coordinate, for example 950 to 95.
l1.setBounds(700, 950, 400, 40);
I assume this is just a test code though. null layout is not recommended and ideally you should use one of the available layout managers.
answered Jan 3 at 7:32
javalearnerjavalearner
3215
3215
add a comment |
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%2f54017186%2ftyped-the-code-but-it-is-not-showing-the-gui-components%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
2
1) Only set the GUI visible once the components have been added. Special measures are required to make components visible if added after that. 2) Java GUIs have to work on different OS', screen size, screen resolution etc. using different PLAFs in different locales. As such, they are not conducive to pixel perfect layout. Instead use layout managers, or combinations of them along with layout padding and borders for white space.
– Andrew Thompson
Jan 3 at 6:33
1
Given the 4 extra buttons and the gaping space in the GUI (even once the last label has been shoved upwards into view), I'm guessing there was more to this GUI. I'll show you how to position them using layouts, but first need to know how the GUI is supposed to look. Provide ASCII art or a simple drawing of the intended layout of the GUI at minimum size, and if resizable, with more width and height - to show how the extra space should be used.
– Andrew Thompson
Jan 3 at 7:16