| | |
Swing Problem
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Jan 2006
Posts: 4
Reputation:
Solved Threads: 0
im new with Swing..im having problem on gridbag layout(my classwork)... im trying to stick a header(label) and a scrollpane(with a JList attach to scrollpane) to a tabbedpane
which the outcome may look like this
but for some reason..my scrollpane doesnt want to show up...
i need some help and tips from you guys and girls..
which the outcome may look like this
but for some reason..my scrollpane doesnt want to show up...
i need some help and tips from you guys and girls..
Java Syntax (Toggle Plain Text)
import java.awt.*; import java.awt.event.*; import javax.swing.UIManager; import javax.swing.*; import javax.swing.event.*; import java.util.*; import java.text.*; //Start of Assign2 public class Assign2 { Dimension screenSize, frameSize; // screen size variables Font largeFont = new Font("Default", Font.BOLD, 18); JFrame thisFrame; //Standard constructor, most of the code for the program will be run from here public Assign2() { disclaimer(); Assign2Frame frame = new Assign2Frame(); frame.setSize(500,350); //Set Screen Size //frame.validate(); //Exit Listener frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); frame.setVisible(true); //Must sets frame as visibles //Position the Frame to the centre of the screen, everytime the program starts // frame.setLocation((screenSize.width - frameSize.width) / 2, // (screenSize.height - frameSize.height) /2 ); } public static void main(String [] args) { try { UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); } catch (Exception e) { e.printStackTrace(); } new Assign2(); } public void disclaimer() { System.out.println("My work + Other ppl's help too"); } } //End
Java Syntax (Toggle Plain Text)
import java.awt.*; import java.awt.event.*; import javax.swing.UIManager; import javax.swing.*; import javax.swing.event.*; import java.util.*; import java.text.*; import javax.swing.JTabbedPane; import javax.swing.ImageIcon; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JFrame; import javax.swing.JComponent; import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.GridLayout; import java.awt.event.KeyEvent; //Start of Assign2Frame public class Assign2Frame extends JFrame { private JTabbedPane tabbedPane; private JPanel panel1; private JPanel panel2; private JPanel panel3; private JList list; private JScrollPane scroll; public Assign2Frame() { //Set the default window close operation setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setSize(new Dimension(500,350)); this.setTitle("Geeky's DVD Database"); JPanel contentPane; contentPane = (JPanel)this.getContentPane(); BorderLayout borderLayout = new BorderLayout(); contentPane.setLayout(borderLayout); // Video Information JTabbedPane tabbedPane = new JTabbedPane(); //Create new panel panel1 = new JPanel(); tabbedPane.addTab("Video Information", panel1); //Panel1 = GridBagLayout panel1.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.gridx=0; c.gridy=0; c.anchor = GridBagConstraints.WEST; panel1.add(new JLabel("Video Database System"), c); /*Panel1 = BorderLayout panel1.setLayout(new BorderLayout()); panel1.add(new JLabel("<html><font size = 18><b>Video Database System</b></font></html>"), BorderLayout.NORTH); */ // JList in Panel1 String[] titleDVD = { "Wargames", "Apt Pupil", "Pitch Black", "Swordfish", "Phantom Menace", "Attack of the Clones", "Dark City", "Cube", "Mask", "Dogma", "RoboTech", "Spiderman", "Daredevil", "Contact", "The Lost Boys", "Dune", "Mars Attacks", "Austin Powers", "The One", "Superman" }; c.gridx=0; c.gridy=1; JList list = new JList(titleDVD); JScrollPane scroll = new JScrollPane(list); //list.setMinimumSize(new Dimension(100,100)); scroll.getViewport().add(list); // Genre Filter //Create new panel panel2 = new JPanel(); tabbedPane.addTab("Genre Filter", panel2); // Statistics //Create new panel panel3 = new JPanel(); tabbedPane.addTab("Statistics", panel3); getContentPane().add(tabbedPane); getContentPane().add(scroll); setResizable(false); setVisible (true); } } //End
•
•
Join Date: Jan 2006
Posts: 4
Reputation:
Solved Threads: 0
thx for the help...i will try to look for the code in the api...
My new question:
how to group JLabels together? and put the grouping to a GridBagLayout?
i uploaded a picture...
im trying to group "Movie Time" "Duration" "Time Now" and "Estimated Finish Time"
thx in advance
cheers
My new question:
how to group JLabels together? and put the grouping to a GridBagLayout?
i uploaded a picture...
im trying to group "Movie Time" "Duration" "Time Now" and "Estimated Finish Time"
thx in advance
cheers
*BUSY*Debugging Swing
•
•
Join Date: Jan 2006
Posts: 4
Reputation:
Solved Threads: 0
ermm..what layout would you recommend? the picture i uploaded..my task is to create a similar one using swing..and im not sure how to do the "Movie Time" "Duration" "Time Now" and "Estimated Finish Time" part...
i used gridbaglayout but they("Movie Time" "Duration" "Time Now" and "Estimated Finish Time") .. move out of their assigned places...
i used gridbaglayout but they("Movie Time" "Duration" "Time Now" and "Estimated Finish Time") .. move out of their assigned places...
*BUSY*Debugging Swing
![]() |
Similar Threads
- Problem in Timer thread (Java)
- Aurora and more (Viruses, Spyware and other Nasties)
Other Threads in the Java Forum
- Previous Thread: producing javadoc
- Next Thread: Time delay
| Thread Tools | Search this Thread |
Tag cloud for Java
2dgraphics addball android api apple applet application arguments array arrays automation bidirectional binary blackberry bluetooth business chat class classes client code collections component database derby dragging draw eclipse error event exception formatingtextintooltipjava fractal froglogic game givemetehcodez graphics gui hql html hyper ide image input integer internet ip j2me java javadesktopapplications javaprojects jmf jni jpanel julia linux list loop looping map method methods mobile myregfun mysql netbeans newbie number numbers oracle phone print problem producer program programming project recursion scanner screen server set size sms smsspam socket sort sql string swing swt tcp test threads time tree ubuntu ui websites windows






