当前位置: 首页 > news >正文

导航站 wordpress成都企业做网站多少钱

导航站 wordpress,成都企业做网站多少钱,邢台123交友信息手机版,常见的网络营销有哪些我有一个JFrame,它有一些选项.当按下OK按钮时,我想要相同的JFrame清除内容并添加新内容.我试过了,但问题是新的JFrame被弹出.我究竟做错了什么#xff1f;import java.awt.*;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.io.IOExcept…我有一个JFrame,它有一些选项.当按下OK按钮时,我想要相同的JFrame清除内容并添加新内容.我试过了,但问题是新的JFrame被弹出.我究竟做错了什么import java.awt.*;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.io.IOException;import java.net.InetAddress;import java.net.UnknownHostException;import java.util.logging.Level;import java.util.logging.Logger;import javax.swing.*;public class GuiFrame extends JFrame {final JFrame f new JFrame(Test);public void Starter(){ImageIcon img new ImageIcon(C:\\Users\\neal\\Desktop\\no.png);f.setIconImage(img.getImage());ButtonGroup group new ButtonGroup();final JRadioButton Acess new JRadioButton(Acess);final JRadioButton Chat new JRadioButton(Chat);group.add(Acess);group.add(Chat);f.setSize(400,100);f.setLocationRelativeTo(null);JButton OptionOk new JButton(OK);Label option new Label(Choose a Option);final Container content f.getContentPane();content.setBackground(Color.white);content.setLayout(new FlowLayout());content.add(option);content.add(Acess);content.add(Chat);content.add(OptionOk);f.setVisible(true);f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);OptionOk.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {try {new GuiFrame().Initiate();} catch (UnknownHostException ex) {Logger.getLogger(GuiFrame.class.getName()).log(Level.SEVERE, null, ex);}}});}public void Initiate() throws UnknownHostException {f.removeAll();ButtonGroup group new ButtonGroup();final JRadioButton ButtonServer new JRadioButton(Server);final JRadioButton ButtonClient new JRadioButton(Client);group.add(ButtonServer);group.add(ButtonClient);f.setSize(400, 100);f.setLocationRelativeTo(null);InetAddress thisIp InetAddress.getLocalHost();ImageIcon img new ImageIcon(C:\\Users\\neal\\Desktop\\no.png);f.setIconImage(img.getImage());Label lip new Label(Your IP is : thisIp.getHostAddress());Label setup new Label(Setup as );JButton ButtonOk new JButton(OK);final Container content f.getContentPane();content.setBackground(Color.white);content.setLayout(new FlowLayout());content.add(lip);content.add(setup);content.add(ButtonServer);content.add(ButtonClient);content.add(ButtonOk);f.setVisible(true);f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);}public static void main(String[] args) throws UnknownHostException {GuiFrame gf new GuiFrame();gf.Starter();}}解决方法:解决方案很简单使用CardLayout,让这个布局管理器为您完成所有繁重的工作.有关如何执行此操作的更多详细信息,请参阅教程How to use CardLayout至于你的代码,请注意你实际上在启动时创建了2个JFrame,如果推送了JButton则还有两个GuiFrame类本身扩展了JFrame,但它似乎是一个你永远不会使用的JFrame,因此被浪费了,但它在程序启动时以及每当创建GuiFrame实例时创建,例如按下按钮时.然后在这个类的内部创建另一个JFrame f,一个在程序启动时再次按下按钮,我不认为这是你想要做的.因此,更改代码以使类不扩展JFrame,并且不要在按钮的ActionListener中创建类的新实例.而是使用CardLayout交换视图.例如import java.awt.*;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import javax.swing.*;public class GuiFrame {private static final String FIRST_PANEL First Panel;private static final String SECOND_PANEL Second Panel;final JFrame f new JFrame(Test);private CardLayout cardLayout new CardLayout();private JPanel content;public void Starter() {f.setSize(400, 100);f.setLocationRelativeTo(null);JButton OptionOk new JButton(OK);Label option new Label(Choose a Option);content (JPanel) f.getContentPane();content.setLayout(cardLayout);JPanel firstPanel new JPanel();firstPanel.setBackground(Color.white);firstPanel.setLayout(new FlowLayout());firstPanel.add(option);firstPanel.add(OptionOk);content.add(firstPanel, FIRST_PANEL);content.add(createSecondPanel(), SECOND_PANEL);f.setVisible(true);f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);OptionOk.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {cardLayout.show(content, SECOND_PANEL);}});}private JPanel createSecondPanel() {JPanel secondPanel new JPanel();secondPanel.add(new JButton(new AbstractAction(Go Back) {public void actionPerformed(ActionEvent e) {cardLayout.show(content, FIRST_PANEL);}}));return secondPanel;}public static void main(String[] args) {GuiFrame gf new GuiFrame();gf.Starter();}}来源https://www.icode9.com/content-1-463801.html
http://www.pierceye.com/news/38831/

相关文章:

  • 长春网站制作公司手机商城网站源码
  • 手淘网站建设需求分析太原推广型网站制作
  • 洛阳seo网站北京影视后期制作公司排名
  • 品牌企业建站wordpress 小人
  • 大良建网站服务网络推广
  • 辽宁网站建设生态文明建设网站
  • 网站信息内容建设微信服务号开发方案
  • 网站建设所需资料泉州住房建设局网站
  • 短网址网站建设郑州有做网站的公司没
  • 机票酒店 网站建设给厂家做代理上什么网站
  • 做站群网站好优化吗2019长沙企业网站建设优惠
  • 长春市网站制作公司景乔网站建设
  • 秦皇岛建设管理中心网站莱芜雪野湖风景区介绍
  • 网站建设管理韩国怎么出线
  • 重庆做网站优化金蝶软件官网首页
  • 大学网站建设情况汇报中国网站建设第一品牌
  • SEO案例网站建设公司青岛经济师考试
  • 200m的空间可以做大大的网站市桥网站建设培训
  • 用vps做网站百度手机网站自助建站
  • 零基础 网站简网app工场官网是不是不可以用了
  • 做网站市场分析网络营销推广的重要性
  • 哪个网站的品牌特卖做的好wordpress产品数量
  • 高唐建筑公司网站吉林省建设集团有限公司网站
  • 门户网站整站源码超级优化空间
  • 网站开发工具 售价电子商务网站设计原理知识点
  • 简述网站规划的流程开什么加工厂不愁销路
  • 尚仁网站建设wordpress 婚恋模板
  • 重庆企业网站推广代理建设网站网页打不开
  • 江汉区建设局官方网站电子商务公司注册资金最低多少
  • 上海免费模板建站网店代运营正规公司