• Some shitty error i'm making in Java.
    1 replies, posted
[code]package Malgava; import java.awt.*; import javax.swing.*; import javax.swing.SwingConstants; import javax.swing.BoxLayout; import javax.swing.JButton; import javax.swing.JComboBox; import javax.swing.JComponent; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.SwingUtilities; import javax.swing.ImageIcon; public class Malgava extends JFrame { public static void main(String args[]) { new Malgava(); public Malgava() // the frame constructor { super("Malgava Client"); setBounds(100,100,900,550); [b]JButton b1 = new JButton("Launch"); JLabel l1 = new JLabel("TestLabel");[/b] b1.setVerticalAlignment(SwingConstants.CENTER); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setVisible(true); // make frame visible } } }[/code] The Jbutton and JLabel aren't visible, what gives? I know next to nothing about Java, just having a mess around.
You never added those components to the frame. [CODE] this.add(b1); this.add(l1); [/CODE] or to add with a layout [CODE]this.add(b1,BorderLayout.NORTH);[/CODE] There are a few different kinds of layouts, you should look them up. You also might wanna look into panels.
Sorry, you need to Log In to post a reply to this thread.