我所有的其他onClick方法都有效,除了我必须给布局充气才能获得按钮!我究竟做错了什么!这是一些代码:
package com.games.think;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.RadioButton;
import android.widget.TableLayout;
public class Think extends Activity{
//What question are we on?
int question = 1;
//What level are we on?
String lvl ="1";
//Radio buttons we need to access them global
RadioButton lvl1;
RadioButton lvl2;
RadioButton lvl3;
RadioButton lvl4;
RadioButton lvl5;
/** Called when the activity is first created. */
public void onCreate(Bundle savedInstanceState) …Run Code Online (Sandbox Code Playgroud) 最近我做了一个Netbeans项目,我正在使用SVN.我看到重复的类错误,并在控制台中说
java.lang.VerifyError: (class: pie/chart/explorer/PieChartExplorer, method: <init> signature: ()V) Constructor must call super() or this()
Could not find the main class: pie.chart.explorer.PieChartExplorer. Program will exit.
Exception in thread "main" Java Result: 1
这是PieChartExplorer.java:
package pie.chart.explorer;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
public class PieChartExplorer extends JFrame implements ActionListener {
JTextField one = new JTextField(10);
JTextField two = new JTextField(10);
JTextField three = new JTextField(10);
JButton sub = new JButton("Click to be amazed");
public PieChartExplorer() {
super("Pie Chart Explorer");
setSize(300,100); …Run Code Online (Sandbox Code Playgroud) 我想制作一个简单的涂鸦应用程序,用于android,但我不知道如何从android获取一些数据!我需要:
拖动前后鼠标的位置或者如果是简单的触摸如何获得触摸的位置.
我该如何画线?
有人能帮帮我吗?
这是我收到的错误消息:
Exception in thread "AWT-EventQueue-0" java.lang.IndexOutOfBoundsException: Index: 2, Size: 2
at java.util.ArrayList.RangeCheck(ArrayList.java:547)
at java.util.ArrayList.get(ArrayList.java:322)
at pie.chart.explorer.alpha.ShowPieChart.<init>(ShowPieChart.java:28)
at pie.chart.explorer.alpha.PieChartMain.jButton2ActionPerformed(PieChartMain.java:101)
at pie.chart.explorer.alpha.PieChartMain.access$100(PieChartMain.java:22)
at pie.chart.explorer.alpha.PieChartMain$2.actionPerformed(PieChartMain.java:63)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
at java.awt.Component.processMouseEvent(Component.java:6267)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
at java.awt.Component.processEvent(Component.java:6032)
at java.awt.Container.processEvent(Container.java:2041)
at java.awt.Component.dispatchEventImpl(Component.java:4630)
at java.awt.Container.dispatchEventImpl(Container.java:2099)
at java.awt.Component.dispatchEvent(Component.java:4460)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4577)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4238)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168)
at java.awt.Container.dispatchEventImpl(Container.java:2085)
at java.awt.Window.dispatchEventImpl(Window.java:2478)
at java.awt.Component.dispatchEvent(Component.java:4460)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
BUILD SUCCESSFUL (total time: 14 seconds)
Run Code Online (Sandbox Code Playgroud)
以下是代码:
/* …Run Code Online (Sandbox Code Playgroud) 我正在寻找一种方法来在Android中居中UI元素.特别是ImageView.因为我知道我将要显示的图像不像我需要居中的屏幕那么宽!关于如何做到这一点的任何想法?
可以说我有一张桌子.其中一个细胞拥有一个JLabel.如果我更改文本,JLabel我该如何JTable显示更改?看下面的代码,我应该更改什么才能让它显示更改JLabel?
public class ActivTimerFrame extends JFrame implements ActionListener{
//Data for table and Combo Box
String timePlay = "1 Hour";
String timeDev = "2 Hours";
String[] comboChoices = {"Play Time", "Dev Time"};
String[] columnNames = {"Activity", "Time Allowed", "Time Left"};
Object[][] data = {{"Play Time", "1 Hour", timePlay }, {"Dev Time", "2 Hours", timeDev }};
//This is where the UI stuff is...
JTable table = new JTable(data, columnNames);
JScrollPane scrollPane = new JScrollPane(table); …Run Code Online (Sandbox Code Playgroud) 我知道这可能与编程中的许多一般规则背道而驰,但你会怎么做呢?我问这个有两个原因: