0 Members and 1 Guest are viewing this topic.
JTabbedPane tabPane = new JTabbedPane();tabPane.add(panel1);tabPane.add(panel2);.....tabPane.add(panelX);
public void loader(JTabbedPane tabPane, Component[] comp){ for(int i = 0; i < comp.length; i++){ if(comp[i] != null && tabPane != null) tabPane.add(comp[i]); }}
public void loader(JTabbedPane tabPane, Component[] comp, String[] names){ for(int i = 0; i < comp.length; i++){ if(comp[i] != null && tabPane != null) tabPane.add(comp[i], names[i]); }}
package launch;import java.awt.BorderLayout;import java.awt.Component;import javax.swing.JPanel;import javax.swing.JTabbedPane;import org.jdesktop.swingx.JXEditorPane;@SuppressWarnings("serial")public class InfoPanel extends MainScreen{ //General section static JPanel shipTab, planetsTab, forumTab, ircTab, wikiTab, mtGeneralTab = new JPanel(); static JPanel[] generalTabs = {shipTab, planetsTab, forumTab, ircTab, wikiTab, mtGeneralTab}; static String[] generalNames = {"Ship", "Planets", "Forum", "IRC channel", "Wiki", "MotionTwin"}; //MotionTwin section static JPanel mtTab = new JPanel(new BorderLayout()); static JPanel twinoidTab = new JPanel(); static JXEditorPane mtLabel = new JXEditorPane(); /** * This method will quickly add all components to the JTabbedPane specified. * @author ElementCoder (with help from HOMER-16) * @param tabPane - the JTabbedPane to which the tabs will be added * @param comp - array of panels to add * @param names - names for the tabs * @since Alpha */ public static void createTabs(JTabbedPane tabPane, Component[] comp, String[] names){ for (int i = 0; i < comp.length; i++){ if (comp[i] != null && tabPane != null){ tabPane.add(comp[i], names[i]); } } } /** * Change the tabs to display the info associated with the general button. * @author ElementCoder * @param none * @since Alpha */ public static void setInfoPanelGeneral(){ tabPane.removeAll(); tabPane.addTab("Galaxy55 Application", infoTab); infoTab.add(introLabel, BorderLayout.CENTER); introLabel.setLineWrap(true); introLabel.setWrapStyleWord(true); introLabel.setBackground(null); introLabel.setEditable(false); createTabs(tabPane, generalTabs, generalNames); } /** * Change the tabs to display the info associated with the twinoid button. * @author ElementCoder * @param none * @since Alpha */ public static void setInfoPanelMT(){ tabPane.removeAll(); tabPane.add("MotionTwin", mtTab); mtTab.add(mtLabel); mtLabel.setBackground(null); mtLabel.setEditable(false); mtLabel.setContentType("text/html"); mtLabel.setText("Besides Galaxy55, MotionTwin has other services too. The main service connecting all of their " + "games is Twinoid. On the next tab you will find a link to visit twinoid." + " Below you can find some other services/games provided by MotionTwin." + "<ul type=\"square\">" + "<li>KadoKado</li>" + "</ul>"); }}
Object o;
o = new Object();
Object o;//null valueo = new Object;//Object is created
static JPanel shipTab, planetsTab, forumTab, ircTab, wikiTab, mtGeneralTab = new JPanel();
static JPanel shipTab = new JPanel();static JPanel planetsTab = new JPanel();static JPanel forumTab = new JPanel();static JPanel ircTab = new JPanel();static JPanel wikiTab = new JPanel();static JPanel mtGeneralTab = new JPanel();
static JPanel[] generalTabs = {shipTab, planetsTab, forumTab, ircTab, wikiTab, mtGeneralTab}; for (int j =0; j < comp.length; j++){ generalTabs[j] = new JPanel(); }
MainScreen: --Creates frame to hold everything as well as the initial layout private class ActionHandler for button presses. if the event is from the general button, InfoPanel.setInfoPanelGeneral() is called.
his keeps giving me an error "cannot make a static reference to the non-static method setInfoPanelGeneral()". Subsequently, when I make setInfoPanelGeneral static, it makes me make everything else static too. It can very well be that I'm just not writing my code correctly. It works now, but as I haven't made that much progress yet, I am considering rewriting it.